diff options
Diffstat (limited to 'src/engine/client')
| -rw-r--r-- | src/engine/client/inp.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/engine/client/inp.c b/src/engine/client/inp.c index ce973246..2a82196c 100644 --- a/src/engine/client/inp.c +++ b/src/engine/client/inp.c @@ -20,6 +20,8 @@ static struct static unsigned char input_state[2][1024] = {{0}, {0}}; static int input_current = 0; +static unsigned int last_release = 0; +static unsigned int release_delta = -1; void inp_mouse_relative(int *x, int *y) { @@ -72,7 +74,14 @@ static void mousebutton_callback(int button, int action) 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; } @@ -134,6 +143,11 @@ void inp_mouse_mode_relative() glfwDisable(GLFW_MOUSE_CURSOR); } +int inp_mouse_doubleclick() +{ + return release_delta < (time_freq() >> 2); +} + int inp_key_presses(int key) { return input_count[input_current][key].presses; |