mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge pull request #7352 from Robyt3/Engine-Input-Antistatic
Replace static variables in `MouseRelative` with member variable
This commit is contained in:
commit
0666646f40
|
@ -259,23 +259,18 @@ bool CInput::MouseRelative(float *pX, float *pY)
|
||||||
if(!m_MouseFocus || !m_InputGrabbed)
|
if(!m_MouseFocus || !m_InputGrabbed)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int nx = 0, ny = 0;
|
ivec2 Relative;
|
||||||
#if defined(CONF_PLATFORM_ANDROID) // No relative mouse on Android
|
#if defined(CONF_PLATFORM_ANDROID) // No relative mouse on Android
|
||||||
static int s_LastX = 0;
|
ivec2 CurrentPos;
|
||||||
static int s_LastY = 0;
|
SDL_GetMouseState(&CurrentPos.x, &CurrentPos.y);
|
||||||
SDL_GetMouseState(&nx, &ny);
|
Relative = CurrentPos - m_LastMousePos;
|
||||||
int XTmp = nx - s_LastX;
|
m_LastMousePos = CurrentPos;
|
||||||
int YTmp = ny - s_LastY;
|
|
||||||
s_LastX = nx;
|
|
||||||
s_LastY = ny;
|
|
||||||
nx = XTmp;
|
|
||||||
ny = YTmp;
|
|
||||||
#else
|
#else
|
||||||
SDL_GetRelativeMouseState(&nx, &ny);
|
SDL_GetRelativeMouseState(&Relative.x, &Relative.y);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*pX = nx;
|
*pX = Relative.x;
|
||||||
*pY = ny;
|
*pY = Relative.y;
|
||||||
return *pX != 0.0f || *pY != 0.0f;
|
return *pX != 0.0f || *pY != 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,9 @@ private:
|
||||||
|
|
||||||
bool m_MouseFocus;
|
bool m_MouseFocus;
|
||||||
bool m_MouseDoubleClick;
|
bool m_MouseDoubleClick;
|
||||||
|
#if defined(CONF_PLATFORM_ANDROID) // No relative mouse on Android
|
||||||
|
ivec2 m_LastMousePos = ivec2(0, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
// IME support
|
// IME support
|
||||||
char m_aComposition[MAX_COMPOSITION_ARRAY_SIZE];
|
char m_aComposition[MAX_COMPOSITION_ARRAY_SIZE];
|
||||||
|
|
Loading…
Reference in a new issue