introduce and use M_IsMouseWheel() (#757)

Thanks @kraflab
This commit is contained in:
Fabian Greffrath 2022-10-03 18:11:17 +02:00 committed by GitHub
parent ae746f5dc5
commit 445c049612
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 11 deletions

View File

@ -859,8 +859,7 @@ boolean AM_Responder
rc = false;
else if (M_InputActivated(input_map_zoomout))
{
if (ev->type == ev_mouseb_down &&
(ev->data1 == MOUSE_BUTTON_WHEELUP || ev->data1 == MOUSE_BUTTON_WHEELDOWN))
if (ev->type == ev_mouseb_down && M_IsMouseWheel(ev->data1))
{
mousewheelzoom = true;
mtof_zoommul = m_zoomout_mouse;
@ -874,8 +873,7 @@ boolean AM_Responder
}
else if (M_InputActivated(input_map_zoomin))
{
if (ev->type == ev_mouseb_down &&
(ev->data1 == MOUSE_BUTTON_WHEELUP || ev->data1 == MOUSE_BUTTON_WHEELDOWN))
if (ev->type == ev_mouseb_down && M_IsMouseWheel(ev->data1))
{
mousewheelzoom = true;
mtof_zoommul = m_zoomin_mouse;

View File

@ -431,3 +431,9 @@ int M_GetMouseBForName(const char* name)
}
return -1;
}
boolean M_IsMouseWheel(int mouseb)
{
return mouseb >= MOUSE_BUTTON_WHEELUP &&
mouseb <= MOUSE_BUTTON_WHEELRIGHT;
}

View File

@ -179,4 +179,6 @@ int M_GetJoyBForName(const char* name);
const char* M_GetNameForMouseB(int joyb);
int M_GetMouseBForName(const char* name);
boolean M_IsMouseWheel(int mouseb);
#endif

View File

@ -5830,8 +5830,7 @@ boolean M_Responder (event_t* ev)
// Don't bind movement and turning to mouse wheel. It needs to
// be impossible to input a one-frame of movement automatically
// in speedrunning.
if ((ch == MOUSE_BUTTON_WHEELUP || ch == MOUSE_BUTTON_WHEELDOWN ||
ch == MOUSE_BUTTON_WHEELLEFT || ch == MOUSE_BUTTON_WHEELRIGHT) &&
if (M_IsMouseWheel(ch) &&
s_input >= input_forward && s_input <= input_straferight)
return true;
for (i = 0 ; keys_settings[i] && search ; i++)

View File

@ -2738,8 +2738,7 @@ boolean M_ParseOption(const char *p, boolean wad)
// Don't bind movement and turning to mouse wheel. It needs to
// be impossible to input a one-frame of movement
// automatically in speedrunning.
if ((value == MOUSE_BUTTON_WHEELUP || value == MOUSE_BUTTON_WHEELDOWN ||
value == MOUSE_BUTTON_WHEELLEFT || value == MOUSE_BUTTON_WHEELRIGHT) &&
if (M_IsMouseWheel(value) &&
dp->ident >= input_forward && dp->ident <= input_straferight)
{
}