Improve CONTROL_GetMouseDelta()

git-svn-id: https://svn.eduke32.com/eduke32@7142 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2018-11-18 18:05:03 +00:00
parent 04e477557a
commit 9ab8ebce20
2 changed files with 7 additions and 10 deletions

View file

@ -69,7 +69,6 @@ static inline int32_t MOUSE_GetButtons(void)
#define MOUSE_ClearButton(b) (g_mouseBits &= ~b) #define MOUSE_ClearButton(b) (g_mouseBits &= ~b)
#define MOUSE_ClearAllButtons() g_mouseBits = 0 #define MOUSE_ClearAllButtons() g_mouseBits = 0
#define MOUSE_GetDelta(x, y) mouseReadPos(x, y)
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -111,22 +111,20 @@ void CONTROL_FreeMouseBind(int i)
#ifndef __ANDROID__ #ifndef __ANDROID__
static void CONTROL_GetMouseDelta(void) 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) if (CONTROL_SmoothMouse)
{ {
static vec2_t last; static vec2_t last;
finput = { float(input.x + last.x) * 0.5f, float(input.y + last.y) * 0.5f };
CONTROL_MouseAxes[0].analog = (int32_t)(((float)(pos.x + last.x) / 2.0f) * 4.0f * CONTROL_MouseSensitivity); last = input;
CONTROL_MouseAxes[1].analog = (int32_t)(((float)(pos.y + last.y) / 2.0f) * 4.0f * CONTROL_MouseSensitivity * 2.0f);
last = pos;
return;
} }
CONTROL_MouseAxes[0].analog = (int32_t)(pos.x * 4.0f * CONTROL_MouseSensitivity); CONTROL_MouseAxes[0].analog = Blrintf(finput.x * 4.f * CONTROL_MouseSensitivity);
CONTROL_MouseAxes[1].analog = (int32_t)(pos.y * 4.0f * CONTROL_MouseSensitivity * 2.0f); CONTROL_MouseAxes[1].analog = Blrintf(finput.y * 8.f * CONTROL_MouseSensitivity);
} }
#endif #endif