diff options
Diffstat (limited to 'src/engine/client/ec_inp.c')
| -rw-r--r-- | src/engine/client/ec_inp.c | 141 |
1 files changed, 1 insertions, 140 deletions
diff --git a/src/engine/client/ec_inp.c b/src/engine/client/ec_inp.c index 74c79c90..2aff68d6 100644 --- a/src/engine/client/ec_inp.c +++ b/src/engine/client/ec_inp.c @@ -1,10 +1,6 @@ /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ #include <string.h> -#ifdef CONFIG_NO_SDL - #include <GL/glfw.h> -#else - #include "SDL.h" -#endif +#include "SDL.h" #include <base/system.h> #include <engine/e_client_interface.h> @@ -19,12 +15,8 @@ static struct static unsigned char input_state[2][1024] = {{0}, {0}}; static int input_current = 0; -#ifdef CONFIG_NO_SDL -static int keyboard_first = 1; -#else static int input_grabbed = 0; static int input_use_grab = 0; -#endif static unsigned int last_release = 0; static unsigned int release_delta = -1; @@ -43,17 +35,6 @@ void inp_mouse_relative(int *x, int *y) last_sens = config.inp_mousesens; } -#ifdef CONFIG_NO_SDL - glfwGetMousePos(&nx, &ny); - - nx *= sens; - ny *= sens; - - *x = nx-last_x; - *y = ny-last_y; - last_x = nx; - last_y = ny; -#else if(input_use_grab) SDL_GetRelativeMouseState(&nx, &ny); else @@ -68,7 +49,6 @@ void inp_mouse_relative(int *x, int *y) *x = nx*sens; *y = ny*sens; -#endif } enum @@ -111,98 +91,6 @@ INPUT_EVENT inp_get_event(int index) return input_events[index]; } -#ifdef CONFIG_NO_SDL -static void char_callback(int character, int action) -{ - if(action == GLFW_PRESS && character < 256) - add_event((char)character, 0, 0); -} - -static void key_callback(int key, int action) -{ - if(action == GLFW_PRESS) - add_event(0, key, INPFLAG_PRESS); - else - add_event(0, key, INPFLAG_RELEASE); - - if(action == GLFW_PRESS) - input_count[input_current^1][key].presses++; - if(action == GLFW_RELEASE) - input_count[input_current^1][key].releases++; - input_state[input_current^1][key] = action; -} - -static void mousebutton_callback(int button, int action) -{ - if(action == GLFW_PRESS) - add_event(0, KEY_MOUSE_FIRST+button, INPFLAG_PRESS); - else - add_event(0, KEY_MOUSE_FIRST+button, INPFLAG_RELEASE); - - if(action == GLFW_PRESS) - input_count[input_current^1][KEY_MOUSE_FIRST+button].presses++; - if(action == GLFW_RELEASE) - { - if(button == 0) - { - release_delta = time_get() - last_release; - last_release = time_get(); - } - input_count[input_current^1][KEY_MOUSE_FIRST+button].releases++; - } - input_state[input_current^1][KEY_MOUSE_FIRST+button] = action; -} - - -static void mousewheel_callback(int pos) -{ - if(pos > 0) - { - while(pos-- != 0) - { - input_count[input_current^1][KEY_MOUSE_WHEEL_UP].presses++; - input_count[input_current^1][KEY_MOUSE_WHEEL_UP].releases++; - } - - add_event(0, KEY_MOUSE_WHEEL_UP, INPFLAG_PRESS); - add_event(0, KEY_MOUSE_WHEEL_UP, INPFLAG_RELEASE); - } - else if(pos < 0) - { - while(pos++ != 0) - { - input_count[input_current^1][KEY_MOUSE_WHEEL_DOWN].presses++; - input_count[input_current^1][KEY_MOUSE_WHEEL_DOWN].releases++; - } - - add_event(0, KEY_MOUSE_WHEEL_DOWN, INPFLAG_PRESS); - add_event(0, KEY_MOUSE_WHEEL_DOWN, INPFLAG_RELEASE); - } - glfwSetMouseWheel(0); -} - - -void inp_init() -{ - glfwEnable(GLFW_KEY_REPEAT); - glfwSetCharCallback(char_callback); - glfwSetKeyCallback(key_callback); - glfwSetMouseButtonCallback(mousebutton_callback); - glfwSetMouseWheelCallback(mousewheel_callback); -} - -void inp_mouse_mode_absolute() -{ - glfwEnable(GLFW_MOUSE_CURSOR); -} - -void inp_mouse_mode_relative() -{ - /*if (!config.gfx_debug_resizable)*/ - glfwDisable(GLFW_MOUSE_CURSOR); -} -#else - void inp_init() { SDL_EnableUNICODE(1); @@ -224,7 +112,6 @@ void inp_mouse_mode_relative() if(input_use_grab) SDL_WM_GrabInput(SDL_GRAB_ON); } -#endif int inp_mouse_doubleclick() { @@ -259,31 +146,6 @@ int inp_button_pressed(int button) { return input_state[input_current][button]; void inp_update() { -#ifdef CONFIG_NO_SDL - int i, v; - - /* clear and begin count on the other one */ - mem_zero(&input_count[input_current], sizeof(input_count[input_current])); - mem_copy(input_state[input_current], input_state[input_current^1], sizeof(input_state[input_current])); - input_current^=1; - - if(keyboard_first) - { - /* make sure to reset */ - keyboard_first = 0; - inp_update(); - } - - /*keyboard_current = keyboard_current^1;*/ - for(i = 0; i < KEY_LAST; i++) - { - if (i >= KEY_MOUSE_FIRST) - v = glfwGetMouseButton(i-KEY_MOUSE_FIRST) == GLFW_PRESS ? 1 : 0; - else - v = glfwGetKey(i) == GLFW_PRESS ? 1 : 0; - input_state[input_current][i] = v; - } -#else int i; if(input_grabbed && !gfx_window_active()) @@ -368,5 +230,4 @@ void inp_update() } } -#endif } |