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

View File

@ -363,7 +363,7 @@ static const struct
{ MOUSE_BUTTON_WHEELUP, "wheelup" }, { MOUSE_BUTTON_WHEELUP, "wheelup" },
{ MOUSE_BUTTON_WHEELDOWN, "wheeldown" }, { MOUSE_BUTTON_WHEELDOWN, "wheeldown" },
{ MOUSE_BUTTON_WHEELLEFT, "wheelleft" }, { MOUSE_BUTTON_WHEELLEFT, "wheelleft" },
{ MOUSE_BUTTON_WHEELRIGHT, "wheelright" }, { MOUSE_BUTTON_WHEELRIGHT,"wheelright" },
}; };
const char* M_GetNameForKey(int key) const char* M_GetNameForKey(int key)
@ -431,3 +431,9 @@ int M_GetMouseBForName(const char* name)
} }
return -1; 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); const char* M_GetNameForMouseB(int joyb);
int M_GetMouseBForName(const char* name); int M_GetMouseBForName(const char* name);
boolean M_IsMouseWheel(int mouseb);
#endif #endif

View File

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

View File

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