ref: 6e363ea1bad43a38b85882e89a9386566b512bf4
parent: 2ca5c793d6bc52ba2fda3cfe41d7adfeae20499c
author: RamonUnch <74856804+RamonUnch@users.noreply.github.com>
date: Wed Sep 7 10:24:30 EDT 2022
Fix Mouse wheel conflict with Xbuttons 1&2 (#1440) * Fix Mouse wheel conflict with Xbuttons 1&2 * Display WHEEL UP/DOWN in the setup * restore txt_main * Better input remapping * Adjust setup program * Shift Xbuttons 2 up for txt_main.h/txt_sdl.h
--- a/src/i_input.c
+++ b/src/i_input.c
@@ -318,6 +318,8 @@
// Note: button "0" is left, button "1" is right,
// button "2" is middle for Doom. This is different
// to how SDL sees things.
+ // In the end: Left=0, Right=1, Middle=2,
+ // WheelUp=3 WheelDown=4, XButton1=5, XButton2=6
switch (button)
{
@@ -335,7 +337,9 @@
default:
// SDL buttons are indexed from 1.
- --button;
+ // And the wheel is mapped to button 3/4
+ // So we have to increment 2 and decrement 1 => inc 1.
+ button++;
break;
}
--- a/src/setup/txt_mouseinput.c
+++ b/src/setup/txt_mouseinput.c
@@ -84,8 +84,14 @@
case 2:
M_StringCopy(buf, "MID", buf_len);
break;
+ case 3:
+ M_StringCopy(buf, "WHEEL UP", buf_len);
+ break;
+ case 4:
+ M_StringCopy(buf, "WHEEL DOWN", buf_len);
+ break;
default:
- M_snprintf(buf, buf_len, "BUTTON #%i", button + 1);
+ M_snprintf(buf, buf_len, "BUTTON #%i", button - 1);
break;
}
}
--- a/textscreen/txt_main.h
+++ b/textscreen/txt_main.h
@@ -43,6 +43,8 @@
#define TXT_MOUSE_MIDDLE (TXT_MOUSE_BASE + 2)
#define TXT_MOUSE_SCROLLUP (TXT_MOUSE_BASE + 3)
#define TXT_MOUSE_SCROLLDOWN (TXT_MOUSE_BASE + 4)
+#define TXT_MOUSE_X1 (TXT_MOUSE_BASE + 5)
+#define TXT_MOUSE_X2 (TXT_MOUSE_BASE + 6)
#define TXT_MAX_MOUSE_BUTTONS 16
#define TXT_KEY_TO_MOUSE_BUTTON(x) \
--- a/textscreen/txt_sdl.c
+++ b/textscreen/txt_sdl.c
@@ -567,7 +567,7 @@
case SDL_BUTTON_MIDDLE:
return TXT_MOUSE_MIDDLE;
default:
- return TXT_MOUSE_BASE + button - 1;
+ return TXT_MOUSE_BASE + button + 1;
}
}