mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fix editor input on Android
This commit is contained in:
parent
a670348b88
commit
6cecffe67c
|
@ -4442,6 +4442,22 @@ void CEditor::UpdateAndRender()
|
|||
float rx, ry;
|
||||
{
|
||||
Input()->MouseRelative(&rx, &ry);
|
||||
#if defined(__ANDROID__)
|
||||
float tx, ty;
|
||||
tx = s_MouseX;
|
||||
ty = s_MouseY;
|
||||
|
||||
s_MouseX = (rx / (float)g_Config.m_GfxScreenWidth) * UI()->Screen()->w;
|
||||
s_MouseY = (ry / (float)g_Config.m_GfxScreenHeight) * UI()->Screen()->h;
|
||||
|
||||
s_MouseX = clamp(s_MouseX, 0.0f, UI()->Screen()->w);
|
||||
s_MouseY = clamp(s_MouseY, 0.0f, UI()->Screen()->h);
|
||||
|
||||
m_MouseDeltaX = s_MouseX - m_OldMouseX;
|
||||
m_MouseDeltaY = s_MouseY - m_OldMouseY;
|
||||
m_OldMouseX = tx;
|
||||
m_OldMouseY = ty;
|
||||
#else
|
||||
UI()->ConvertMouseMove(&rx, &ry);
|
||||
m_MouseDeltaX = rx;
|
||||
m_MouseDeltaY = ry;
|
||||
|
@ -4454,6 +4470,7 @@ void CEditor::UpdateAndRender()
|
|||
|
||||
s_MouseX = clamp(s_MouseX, 0.0f, UI()->Screen()->w);
|
||||
s_MouseY = clamp(s_MouseY, 0.0f, UI()->Screen()->h);
|
||||
#endif
|
||||
|
||||
// update the ui
|
||||
mx = s_MouseX;
|
||||
|
@ -4482,7 +4499,14 @@ void CEditor::UpdateAndRender()
|
|||
if(Input()->KeyPressed(KEY_MOUSE_2)) Buttons |= 2;
|
||||
if(Input()->KeyPressed(KEY_MOUSE_3)) Buttons |= 4;
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
static int ButtonsOneFrameDelay = 0; // For Android touch input
|
||||
|
||||
UI()->Update(mx,my,Mwx,Mwy,ButtonsOneFrameDelay);
|
||||
ButtonsOneFrameDelay = Buttons;
|
||||
#else
|
||||
UI()->Update(mx,my,Mwx,Mwy,Buttons);
|
||||
#endif
|
||||
}
|
||||
|
||||
// toggle gui
|
||||
|
|
|
@ -611,6 +611,10 @@ public:
|
|||
m_MouseDeltaY = 0;
|
||||
m_MouseDeltaWx = 0;
|
||||
m_MouseDeltaWy = 0;
|
||||
#if defined(__ANDROID__)
|
||||
m_OldMouseX = 0;
|
||||
m_OldMouseY = 0;
|
||||
#endif
|
||||
|
||||
m_GuiActive = true;
|
||||
m_ProofBorders = false;
|
||||
|
@ -773,6 +777,10 @@ public:
|
|||
float m_MouseDeltaY;
|
||||
float m_MouseDeltaWx;
|
||||
float m_MouseDeltaWy;
|
||||
#if defined(__ANDROID__)
|
||||
float m_OldMouseX;
|
||||
float m_OldMouseY;
|
||||
#endif
|
||||
|
||||
bool m_ShowTileInfo;
|
||||
bool m_ShowDetail;
|
||||
|
|
Loading…
Reference in a new issue