commit 35f805c234a4fce24ecbe564b67fd0fd7acca699
Author: Jonathan Dowland <jon+github@alcopop.org>
AuthorDate: Mon Jul 4 21:17:46 2016 +0100
Commit: Jonathan Dowland <jon+github@alcopop.org>
CommitDate: Mon Jul 4 21:28:48 2016 +0100
Fix mix-up of up/down buttons; ignore OS invert
Don't bother trying to override the OS on the mouse wheel
axis inversion, to be consistent with SDL1.
Fix mixing up the up/down button numbers.
Rename some variables for clarity.
---
src/i_input.c | 33 ++++++++++++---------------------
textscreen/txt_sdl.c | 12 +-----------
2 files changed, 13 insertions(+), 32 deletions(-)
diff --git a/src/i_input.c b/src/i_input.c
index ca321234..e032dbf2 100644
--- a/src/i_input.c
+++ b/src/i_input.c
@@ -360,40 +360,31 @@ static void MapMouseWheelToButtons(SDL_MouseWheelEvent *wheel)
// SDL2 distinguishes button events from mouse wheel events.
// We want to treat the mouse wheel as two buttons, as per
// SDL1
- event_t event1, event2;
- int y = wheel->y;
+ event_t up, down;
int button;
-#if !(SDL_MAJOR_VERSION == 2 && SDL_MINOR_VERSION == 0 && SDL_PATCHLEVEL < 4)
- // Ignore OS axis inversion (so up is always up)
- if (wheel->direction == SDL_MOUSEWHEEL_FLIPPED)
- {
- y *= -1;
- }
-#endif
-
- if (y <= 0)
+ if (wheel->y <= 0)
{ // scroll down
- button = 3;
+ button = 4;
}
else
{ // scroll up
- button = 4;
+ button = 3;
}
// post a button down event
mouse_button_state |= (1 << button);
- event1.type = ev_mouse;
- event1.data1 = mouse_button_state;
- event1.data2 = event1.data3 = 0;
- D_PostEvent(&event1);
+ down.type = ev_mouse;
+ down.data1 = mouse_button_state;
+ down.data2 = down.data3 = 0;
+ D_PostEvent(&down);
// post a button up event
mouse_button_state &= ~(1 << button);
- event2.type = ev_mouse;
- event2.data1 = mouse_button_state;
- event2.data2 = event2.data3 = 0;
- D_PostEvent(&event2);
+ up.type = ev_mouse;
+ up.data1 = mouse_button_state;
+ up.data2 = up.data3 = 0;
+ D_PostEvent(&up);
}
void I_HandleMouseEvent(SDL_Event *sdlevent)
diff --git a/textscreen/txt_sdl.c b/textscreen/txt_sdl.c
index cb1da17a..a17feb18 100644
--- a/textscreen/txt_sdl.c
+++ b/textscreen/txt_sdl.c
@@ -535,17 +535,7 @@ static int SDLButtonToTXTButton(int button)
static int SDLWheelToTXTButton(SDL_MouseWheelEvent *wheel)
{
- int y = wheel->y;
-
-#if !(SDL_MAJOR_VERSION == 2 && SDL_MINOR_VERSION == 0 && SDL_PATCHLEVEL < 4)
- // Ignore OS axis inversion (so up is always up)
- if (wheel->direction == SDL_MOUSEWHEEL_FLIPPED)
- {
- y *= -1;
- }
-#endif
-
- if (y <= 0)
+ if (wheel->y <= 0)
{
return TXT_MOUSE_SCROLLDOWN;
}