Add mouse WheelLeft/WheelRight buttons (#756)

* Add mouse WheelLeft/WheelRight buttons

* Add else return clause

* Format long code lines

* Fix indentation

* Fix indentation for good
This commit is contained in:
rrPKrr 2022-10-03 02:47:23 +03:00 committed by GitHub
parent e3dfec919b
commit ae746f5dc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 6 deletions

View File

@ -196,6 +196,8 @@ enum
MOUSE_BUTTON_X2,
MOUSE_BUTTON_WHEELUP,
MOUSE_BUTTON_WHEELDOWN,
MOUSE_BUTTON_WHEELLEFT,
MOUSE_BUTTON_WHEELRIGHT,
NUM_MOUSE_BUTTONS
};

View File

@ -497,14 +497,26 @@ static void MapMouseWheelToButtons(SDL_MouseWheelEvent *wheel)
static event_t down;
int button;
if (wheel->y <= 0)
if (wheel->y < 0)
{ // scroll down
button = MOUSE_BUTTON_WHEELDOWN;
}
else
else if (wheel->y >0)
{ // scroll up
button = MOUSE_BUTTON_WHEELUP;
}
else if (wheel->x < 0)
{
button = MOUSE_BUTTON_WHEELLEFT;
}
else if (wheel->x > 0)
{
button = MOUSE_BUTTON_WHEELRIGHT;
}
else
{
return;
}
// post a button down event
down.type = ev_mouseb_down;

View File

@ -362,6 +362,8 @@ static const struct
{ MOUSE_BUTTON_X2, "mouse5" },
{ MOUSE_BUTTON_WHEELUP, "wheelup" },
{ MOUSE_BUTTON_WHEELDOWN, "wheeldown" },
{ MOUSE_BUTTON_WHEELLEFT, "wheelleft" },
{ MOUSE_BUTTON_WHEELRIGHT, "wheelright" },
};
const char* M_GetNameForKey(int key)

View File

@ -5830,8 +5830,9 @@ 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) &&
s_input >= input_forward && s_input <= input_straferight)
if ((ch == MOUSE_BUTTON_WHEELUP || ch == MOUSE_BUTTON_WHEELDOWN ||
ch == MOUSE_BUTTON_WHEELLEFT || ch == MOUSE_BUTTON_WHEELRIGHT) &&
s_input >= input_forward && s_input <= input_straferight)
return true;
for (i = 0 ; keys_settings[i] && search ; i++)
for (ptr2 = keys_settings[i] ; !(ptr2->m_flags & S_END) ; ptr2++)

View File

@ -2738,8 +2738,9 @@ 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) &&
dp->ident >= input_forward && dp->ident <= input_straferight)
if ((value == MOUSE_BUTTON_WHEELUP || value == MOUSE_BUTTON_WHEELDOWN ||
value == MOUSE_BUTTON_WHEELLEFT || value == MOUSE_BUTTON_WHEELRIGHT) &&
dp->ident >= input_forward && dp->ident <= input_straferight)
{
}
else if (!M_InputAddMouseB(dp->ident, value))