Turned on warnings and fixed

This commit is contained in:
2022-02-06 16:14:57 +00:00
parent 76985519f1
commit 87df6921e8
50 changed files with 570 additions and 4246 deletions

View File

@@ -1,17 +1,35 @@
#include "input.h"
#include "window.h"
#include <SDL2/SDL.h>
int32_t mouseWheelX = 0;
int32_t mouseWheelY = 0;
int ychange = 0;
int xchange = 0;
float deltaT = 0;
int quit = 0;
SDL_Event e = { 0 };
uint8_t *currentKeystates = NULL;
static double c_xpos;
static double c_ypos;
static void cursor_pos_cb(GLFWwindow *w, double xpos, double ypos)
{
xchange = (int)xpos - c_xpos;
ychange = (int)ypos - c_ypos;
c_xpos = xpos;
c_ypos = ypos;
}
static void scroll_cb(GLFWwindow *w, double xoffset, double yoffset)
{
mouseWheelY = yoffset;
mouseWheelX = xoffset;
}
void input_init()
{
glfwSetCursorPosCallback(mainwin->window, cursor_pos_cb);
glfwSetScrollCallback(mainwin->window, scroll_cb);
}
void input_poll()
{
@@ -19,15 +37,25 @@ void input_poll()
xchange = 0;
mouseWheelX = 0;
mouseWheelY = 0;
currentKeystates = SDL_GetKeyboardState(NULL);
while (SDL_PollEvent(&e)) {
window_all_handle_events(&e);
glfwPollEvents();
#ifdef EDITOR
//editor_input(&e);
#endif
}
//editor_input(&e);
}
void cursor_hide()
{
glfwSetInputMode(mainwin->window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
}
void cursor_show()
{
glfwSetInputMode(mainwin->window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
}
int action_down(int scancode)
{
return glfwGetKey(mainwin->window, scancode);
}