From d313e2531a538b6660d8d63a626415ded70ce436 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 28 Apr 2015 21:30:42 +0000 Subject: [PATCH] Set up input so that the menus are navigable under iOS. This also enables the SELECTDIR back button unconditionally instead of restricting it to non-touch devices. DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@5169 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/sdlayer.c | 22 +++++++++++++++++++--- polymer/eduke32/source/input.c | 6 ++++++ polymer/eduke32/source/menus.c | 13 ++++++++----- polymer/eduke32/source/menus.h | 1 + 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 99db8836c..bc92321b9 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -708,7 +708,7 @@ int32_t initinput(void) W_SetKeyboardLayoutUS(0); #endif -#ifdef __APPLE__ +#if defined EDUKE32_OSX // force OS X to operate in >1 button mouse mode so that LMB isn't adulterated if (!getenv("SDL_HAS3BUTTONMOUSE")) putenv("SDL_HAS3BUTTONMOUSE=1"); @@ -1839,10 +1839,9 @@ void handleevents_updatemousestate(uint8_t state) int32_t handleevents_sdlcommon(SDL_Event *ev) { - int32_t j; - switch (ev->type) { +#if !defined EDUKE32_IOS case SDL_MOUSEMOTION: #ifndef GEKKO mouseabs.x = ev->motion.x; @@ -1871,6 +1870,9 @@ int32_t handleevents_sdlcommon(SDL_Event *ev) case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: + { + int32_t j; + // some of these get reordered to match winlayer switch (ev->button.button) { @@ -1912,6 +1914,20 @@ int32_t handleevents_sdlcommon(SDL_Event *ev) if (mousepresscallback) mousepresscallback(j+1, ev->button.state == SDL_PRESSED); break; + } +#else +# if SDL_MAJOR_VERSION != 1 + case SDL_FINGERUP: + mousepressstate = Mouse_Released; + break; + case SDL_FINGERDOWN: + mousepressstate = Mouse_Pressed; + case SDL_FINGERMOTION: + mouseabs.x = Blrintf(ev->tfinger.x * xdim); + mouseabs.y = Blrintf(ev->tfinger.y * ydim); + break; +# endif +#endif case SDL_JOYAXISMOTION: if (appactive && ev->jaxis.axis < joynumaxes) diff --git a/polymer/eduke32/source/input.c b/polymer/eduke32/source/input.c index f5ae0d813..044150395 100644 --- a/polymer/eduke32/source/input.c +++ b/polymer/eduke32/source/input.c @@ -33,6 +33,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. int32_t I_CheckAllInput(void) { return ( +#if defined EDUKE32_IOS + mousepressstate == Mouse_Pressed || +#endif KB_KeyWaiting() || MOUSE_GetButtons() || JOYSTICK_GetButtons() @@ -40,6 +43,9 @@ int32_t I_CheckAllInput(void) } void I_ClearAllInput(void) { +#if defined EDUKE32_IOS + mousepressstateadvance(); +#endif KB_FlushKeyboardQueue(); KB_ClearKeysDown(); MOUSE_ClearAllButtons(); diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 8cb5e50e5..be71df49f 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -4491,13 +4491,14 @@ static int32_t M_RunMenuInput_MouseAdvance(void) return MOUSEACTIVECONDITIONAL(!m_mousecaught && mousepressstate == Mouse_Released); } -#if !defined EDUKE32_TOUCH_DEVICES static int32_t M_RunMenuInput_MouseReturn_status; static void M_RunMenu_MouseReturn(Menu_t *cm, const vec2_t origin) { +#if !defined EDUKE32_TOUCH_DEVICES if (!MOUSEACTIVECONDITION) return; +#endif if (cm->menuID == MENU_MAIN) return; @@ -4507,7 +4508,6 @@ static void M_RunMenu_MouseReturn(Menu_t *cm, const vec2_t origin) 2 | 8 | 16 | RS_ALIGN_L, MOUSEALPHA, 0, xdim_from_320_16(origin.x + x_widescreen_left()), 0, xdim_from_320_16(origin.x + x_widescreen_left() + (tilesiz[SELECTDIR].y << 15)), ydim - 1); } -#endif static int32_t M_RunMenuInput_MouseReturn(void) { @@ -4517,6 +4517,7 @@ static int32_t M_RunMenuInput_MouseReturn(void) M_RunMenuInput_MouseReturn_status = 0; return 0; } +#endif if (g_currentMenu == MENU_MAIN) return 0; @@ -4525,12 +4526,16 @@ static int32_t M_RunMenuInput_MouseReturn(void) if (M_MouseWithinBounds(&m_mousepos, MouseReturnRegionX, 0, tilesiz[SELECTDIR].y<<15, tilesiz[SELECTDIR].x<<16)) { +#if !defined EDUKE32_TOUCH_DEVICES M_RunMenuInput_MouseReturn_status = 1; +#else + M_RunMenuInput_MouseReturn_status = (mousepressstate == Mouse_Pressed || mousepressstate == Mouse_Held); +#endif + return !m_mousecaught && mousepressstate == Mouse_Released && M_MouseWithinBounds(&m_mousedownpos, MouseReturnRegionX, 0, tilesiz[SELECTDIR].y<<15, tilesiz[SELECTDIR].x<<16); } M_RunMenuInput_MouseReturn_status = 0; -#endif return 0; } @@ -4804,9 +4809,7 @@ static void M_RunMenu(Menu_t *cm, const vec2_t origin) } } -#if !defined EDUKE32_TOUCH_DEVICES M_RunMenu_MouseReturn(cm, origin); -#endif } /* diff --git a/polymer/eduke32/source/menus.h b/polymer/eduke32/source/menus.h index 0e4d22496..d7dd85558 100644 --- a/polymer/eduke32/source/menus.h +++ b/polymer/eduke32/source/menus.h @@ -431,6 +431,7 @@ void M_DisplayMenus(void); extern int32_t m_mouselastactivity; #if defined EDUKE32_TOUCH_DEVICES +# define MOUSEALPHA 0 # define MOUSEACTIVECONDITIONAL(condition) (condition) # define MOUSEWATCHPOINTCONDITIONAL(condition) (condition) #else