From 9ab8ebce2013ad947a1ccb38c970ebf635e948ee Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 18 Nov 2018 18:05:03 +0000 Subject: [PATCH] Improve CONTROL_GetMouseDelta() git-svn-id: https://svn.eduke32.com/eduke32@7142 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/mact/include/mouse.h | 1 - source/mact/src/control.cpp | 16 +++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/source/mact/include/mouse.h b/source/mact/include/mouse.h index af06e88b8..45b36ba19 100644 --- a/source/mact/include/mouse.h +++ b/source/mact/include/mouse.h @@ -69,7 +69,6 @@ static inline int32_t MOUSE_GetButtons(void) #define MOUSE_ClearButton(b) (g_mouseBits &= ~b) #define MOUSE_ClearAllButtons() g_mouseBits = 0 -#define MOUSE_GetDelta(x, y) mouseReadPos(x, y) #ifdef __cplusplus } diff --git a/source/mact/src/control.cpp b/source/mact/src/control.cpp index 502bb1007..82348f073 100644 --- a/source/mact/src/control.cpp +++ b/source/mact/src/control.cpp @@ -111,22 +111,20 @@ void CONTROL_FreeMouseBind(int i) #ifndef __ANDROID__ static void CONTROL_GetMouseDelta(void) { - vec2_t pos; + vec2_t input; + mouseReadPos(&input.x, &input.y); - MOUSE_GetDelta(&pos.x, &pos.y); + vec2f_t finput = { float(input.x), float(input.y) }; if (CONTROL_SmoothMouse) { static vec2_t last; - - CONTROL_MouseAxes[0].analog = (int32_t)(((float)(pos.x + last.x) / 2.0f) * 4.0f * CONTROL_MouseSensitivity); - CONTROL_MouseAxes[1].analog = (int32_t)(((float)(pos.y + last.y) / 2.0f) * 4.0f * CONTROL_MouseSensitivity * 2.0f); - last = pos; - return; + finput = { float(input.x + last.x) * 0.5f, float(input.y + last.y) * 0.5f }; + last = input; } - CONTROL_MouseAxes[0].analog = (int32_t)(pos.x * 4.0f * CONTROL_MouseSensitivity); - CONTROL_MouseAxes[1].analog = (int32_t)(pos.y * 4.0f * CONTROL_MouseSensitivity * 2.0f); + CONTROL_MouseAxes[0].analog = Blrintf(finput.x * 4.f * CONTROL_MouseSensitivity); + CONTROL_MouseAxes[1].analog = Blrintf(finput.y * 8.f * CONTROL_MouseSensitivity); } #endif