Fix editor input on Android

This commit is contained in:
def 2014-09-29 13:13:56 +02:00
parent a670348b88
commit 6cecffe67c
2 changed files with 32 additions and 0 deletions

View file

@ -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

View file

@ -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;