mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-24 04:29:34 -04:00
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:
parent
e3dfec919b
commit
ae746f5dc5
@ -196,6 +196,8 @@ enum
|
|||||||
MOUSE_BUTTON_X2,
|
MOUSE_BUTTON_X2,
|
||||||
MOUSE_BUTTON_WHEELUP,
|
MOUSE_BUTTON_WHEELUP,
|
||||||
MOUSE_BUTTON_WHEELDOWN,
|
MOUSE_BUTTON_WHEELDOWN,
|
||||||
|
MOUSE_BUTTON_WHEELLEFT,
|
||||||
|
MOUSE_BUTTON_WHEELRIGHT,
|
||||||
|
|
||||||
NUM_MOUSE_BUTTONS
|
NUM_MOUSE_BUTTONS
|
||||||
};
|
};
|
||||||
|
@ -497,14 +497,26 @@ static void MapMouseWheelToButtons(SDL_MouseWheelEvent *wheel)
|
|||||||
static event_t down;
|
static event_t down;
|
||||||
int button;
|
int button;
|
||||||
|
|
||||||
if (wheel->y <= 0)
|
if (wheel->y < 0)
|
||||||
{ // scroll down
|
{ // scroll down
|
||||||
button = MOUSE_BUTTON_WHEELDOWN;
|
button = MOUSE_BUTTON_WHEELDOWN;
|
||||||
}
|
}
|
||||||
else
|
else if (wheel->y >0)
|
||||||
{ // scroll up
|
{ // scroll up
|
||||||
button = MOUSE_BUTTON_WHEELUP;
|
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
|
// post a button down event
|
||||||
down.type = ev_mouseb_down;
|
down.type = ev_mouseb_down;
|
||||||
|
@ -362,6 +362,8 @@ static const struct
|
|||||||
{ MOUSE_BUTTON_X2, "mouse5" },
|
{ MOUSE_BUTTON_X2, "mouse5" },
|
||||||
{ MOUSE_BUTTON_WHEELUP, "wheelup" },
|
{ MOUSE_BUTTON_WHEELUP, "wheelup" },
|
||||||
{ MOUSE_BUTTON_WHEELDOWN, "wheeldown" },
|
{ MOUSE_BUTTON_WHEELDOWN, "wheeldown" },
|
||||||
|
{ MOUSE_BUTTON_WHEELLEFT, "wheelleft" },
|
||||||
|
{ MOUSE_BUTTON_WHEELRIGHT, "wheelright" },
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* M_GetNameForKey(int key)
|
const char* M_GetNameForKey(int key)
|
||||||
|
@ -5830,8 +5830,9 @@ 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 ((ch == MOUSE_BUTTON_WHEELUP || ch == MOUSE_BUTTON_WHEELDOWN ||
|
||||||
s_input >= input_forward && s_input <= input_straferight)
|
ch == MOUSE_BUTTON_WHEELLEFT || ch == MOUSE_BUTTON_WHEELRIGHT) &&
|
||||||
|
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++)
|
||||||
|
@ -2738,8 +2738,9 @@ 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 ((value == MOUSE_BUTTON_WHEELUP || value == MOUSE_BUTTON_WHEELDOWN ||
|
||||||
dp->ident >= input_forward && dp->ident <= input_straferight)
|
value == MOUSE_BUTTON_WHEELLEFT || value == MOUSE_BUTTON_WHEELRIGHT) &&
|
||||||
|
dp->ident >= input_forward && dp->ident <= input_straferight)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else if (!M_InputAddMouseB(dp->ident, value))
|
else if (!M_InputAddMouseB(dp->ident, value))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user