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
This commit is contained in:
hendricks266 2014-12-27 18:36:58 +00:00
parent 598e33319c
commit 4f9831d45c
3 changed files with 33 additions and 8 deletions

View file

@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "joystick.h" #include "joystick.h"
#include "control.h" #include "control.h"
#include "input.h" #include "input.h"
#include "menus.h"
int32_t I_CheckAllInput(void) int32_t I_CheckAllInput(void)
{ {
@ -51,12 +52,18 @@ int32_t I_AdvanceTrigger(void)
return ( return (
KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_kpad_Enter) ||
KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_Enter) ||
(MOUSE_GetButtons()&LEFT_MOUSE) || #if !defined EDUKE32_TOUCH_DEVICES
MOUSEINACTIVECONDITIONAL(MOUSE_GetButtons()&LEFT_MOUSE) ||
#endif
#if defined(GEKKO) #if defined(GEKKO)
(JOYSTICK_GetButtons()&WII_A) MOUSEINACTIVECONDITIONAL(JOYSTICK_GetButtons()&WII_A)
#else #else
BUTTON(gamefunc_Open) || BUTTON(gamefunc_Open) ||
# if !defined EDUKE32_TOUCH_DEVICES
MOUSEINACTIVECONDITIONAL(BUTTON(gamefunc_Fire))
# else
BUTTON(gamefunc_Fire) BUTTON(gamefunc_Fire)
# endif
#endif #endif
); );
} }
@ -250,7 +257,9 @@ void I_PanelDownClear(void)
int32_t I_SliderLeft(void) int32_t I_SliderLeft(void)
{ {
return ( 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() I_MenuLeft()
); );
} }
@ -265,7 +274,9 @@ void I_SliderLeftClear(void)
int32_t I_SliderRight(void) int32_t I_SliderRight(void)
{ {
return ( 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() I_MenuRight()
); );
} }

View file

@ -3161,8 +3161,7 @@ static inline int32_t M_UpdateScreenOK(MenuID_t cm)
chances are you should scroll up. chances are you should scroll up.
*/ */
#define M_MOUSETIMEOUT 120 int32_t m_mouselastactivity;
static int32_t m_mouselastactivity;
static vec2_t m_prevmousepos, m_mousepos, m_mousedownpos; static vec2_t m_prevmousepos, m_mousepos, m_mousedownpos;
void M_OpenMenu(size_t playerID) void M_OpenMenu(size_t playerID)
@ -4898,6 +4897,7 @@ void M_DisplayMenus(void)
if (M_UpdateScreenOK(g_currentMenu)) if (M_UpdateScreenOK(g_currentMenu))
G_UpdateScreenArea(); G_UpdateScreenArea();
// Display the menu, with a transition animation if applicable.
if (totalclock < m_animation.start + m_animation.length) if (totalclock < m_animation.start + m_animation.length)
{ {
vec2_t previousOrigin = { 0, 0 }; vec2_t previousOrigin = { 0, 0 };
@ -4917,7 +4917,7 @@ void M_DisplayMenus(void)
if (mousestatus) 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_prevmousepos = m_mousepos;
m_mouselastactivity = totalclock; m_mouselastactivity = totalclock;
@ -4926,8 +4926,11 @@ void M_DisplayMenus(void)
else else
m_mouselastactivity = -M_MOUSETIMEOUT; 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); 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) if ((g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU)
{ {

View file

@ -402,6 +402,17 @@ void M_OpenMenu(size_t playerID);
void M_CloseMenu(size_t playerID); void M_CloseMenu(size_t playerID);
void M_DisplayMenus(void); 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 #ifdef __cplusplus
} }
#endif #endif