From 4f9831d45c5f459e6abee2fb65e764b95931ecb3 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sat, 27 Dec 2014 18:36:58 +0000 Subject: [PATCH] Menus: Disable normal left-click/touch menu functionality when the mouse is active. git-svn-id: https://svn.eduke32.com/eduke32@4854 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/input.c | 19 +++++++++++++++---- polymer/eduke32/source/menus.c | 11 +++++++---- polymer/eduke32/source/menus.h | 11 +++++++++++ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/polymer/eduke32/source/input.c b/polymer/eduke32/source/input.c index 076c3b9e9..f5ae0d813 100644 --- a/polymer/eduke32/source/input.c +++ b/polymer/eduke32/source/input.c @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "joystick.h" #include "control.h" #include "input.h" +#include "menus.h" int32_t I_CheckAllInput(void) { @@ -51,12 +52,18 @@ int32_t I_AdvanceTrigger(void) return ( KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Enter) || - (MOUSE_GetButtons()&LEFT_MOUSE) || +#if !defined EDUKE32_TOUCH_DEVICES + MOUSEINACTIVECONDITIONAL(MOUSE_GetButtons()&LEFT_MOUSE) || +#endif #if defined(GEKKO) - (JOYSTICK_GetButtons()&WII_A) + MOUSEINACTIVECONDITIONAL(JOYSTICK_GetButtons()&WII_A) #else BUTTON(gamefunc_Open) || +# if !defined EDUKE32_TOUCH_DEVICES + MOUSEINACTIVECONDITIONAL(BUTTON(gamefunc_Fire)) +# else BUTTON(gamefunc_Fire) +# endif #endif ); } @@ -250,7 +257,9 @@ void I_PanelDownClear(void) int32_t I_SliderLeft(void) { return ( - ((MOUSE_GetButtons()&LEFT_MOUSE) && (MOUSE_GetButtons()&WHEELUP_MOUSE)) || +#if !defined EDUKE32_TOUCH_DEVICES + MOUSEINACTIVECONDITIONAL((MOUSE_GetButtons()&LEFT_MOUSE) && (MOUSE_GetButtons()&WHEELUP_MOUSE)) || +#endif I_MenuLeft() ); } @@ -265,7 +274,9 @@ void I_SliderLeftClear(void) int32_t I_SliderRight(void) { return ( - ((MOUSE_GetButtons()&LEFT_MOUSE) && (MOUSE_GetButtons()&WHEELDOWN_MOUSE)) || +#if !defined EDUKE32_TOUCH_DEVICES + MOUSEINACTIVECONDITIONAL((MOUSE_GetButtons()&LEFT_MOUSE) && (MOUSE_GetButtons()&WHEELDOWN_MOUSE)) || +#endif I_MenuRight() ); } diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index d6030bfaa..991fbfb9d 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -3161,8 +3161,7 @@ static inline int32_t M_UpdateScreenOK(MenuID_t cm) chances are you should scroll up. */ -#define M_MOUSETIMEOUT 120 -static int32_t m_mouselastactivity; +int32_t m_mouselastactivity; static vec2_t m_prevmousepos, m_mousepos, m_mousedownpos; void M_OpenMenu(size_t playerID) @@ -4898,6 +4897,7 @@ void M_DisplayMenus(void) if (M_UpdateScreenOK(g_currentMenu)) G_UpdateScreenArea(); + // Display the menu, with a transition animation if applicable. if (totalclock < m_animation.start + m_animation.length) { vec2_t previousOrigin = { 0, 0 }; @@ -4917,7 +4917,7 @@ void M_DisplayMenus(void) if (mousestatus) { - if (((totalclock - m_mouselastactivity < M_MOUSETIMEOUT) && mousepressstateadvance()) || m_mousepos.x != m_prevmousepos.x || m_mousepos.y != m_prevmousepos.y) + if (MOUSEACTIVECONDITIONAL(mousepressstateadvance()) || m_mousepos.x != m_prevmousepos.x || m_mousepos.y != m_prevmousepos.y) { m_prevmousepos = m_mousepos; m_mouselastactivity = totalclock; @@ -4926,8 +4926,11 @@ void M_DisplayMenus(void) else m_mouselastactivity = -M_MOUSETIMEOUT; - if (totalclock - m_mouselastactivity < M_MOUSETIMEOUT) +#ifndef EDUKE32_TOUCH_DEVICES + // Display the mouse cursor, except on touch devices. + if (MOUSEACTIVECONDITION) rotatesprite_fs(m_mousepos.x,m_mousepos.y,65536,0,CROSSHAIR,0,CROSSHAIR_PAL,2|1); +#endif if ((g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) { diff --git a/polymer/eduke32/source/menus.h b/polymer/eduke32/source/menus.h index c1fa496e9..09b9ca2f3 100644 --- a/polymer/eduke32/source/menus.h +++ b/polymer/eduke32/source/menus.h @@ -402,6 +402,17 @@ void M_OpenMenu(size_t playerID); void M_CloseMenu(size_t playerID); void M_DisplayMenus(void); +#define M_MOUSETIMEOUT 120 +extern int32_t m_mouselastactivity; + +#if defined EDUKE32_TOUCH_DEVICES +# define MOUSEACTIVECONDITIONAL(condition) (condition) +#else +# define MOUSEACTIVECONDITION (totalclock - m_mouselastactivity < M_MOUSETIMEOUT) +# define MOUSEACTIVECONDITIONAL(condition) (MOUSEACTIVECONDITION && (condition)) +# define MOUSEINACTIVECONDITIONAL(condition) (!MOUSEACTIVECONDITION && (condition)) +#endif + #ifdef __cplusplus } #endif