summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author R. Belmont <rb6502@users.noreply.github.com>2019-03-01 11:56:21 -0500
committer GitHub <noreply@github.com>2019-03-01 11:56:21 -0500
commit9cf8cf0ed73e18578014951c738ae120dd84cd85 (patch)
treea5bafb76834b4e8072923447be39f3f54fa67475 /src
parentd443ac8cbba9956b768d4471bb494b0e65b2e4e6 (diff)
parentee2595d7c8a6501843a1a70a2677960b5ad4424b (diff)
Merge pull request #4698 from kiall/bug-4695
Linux X11 Input: Fix lightgun support
Diffstat (limited to 'src')
-rw-r--r--src/osd/modules/input/input_x11.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/osd/modules/input/input_x11.cpp b/src/osd/modules/input/input_x11.cpp
index 0762b5ae35d..f7c48a10d87 100644
--- a/src/osd/modules/input/input_x11.cpp
+++ b/src/osd/modules/input/input_x11.cpp
@@ -401,7 +401,23 @@ public:
else if (xevent.type == button_press_type || xevent.type == button_release_type)
{
XDeviceButtonEvent *button = reinterpret_cast<XDeviceButtonEvent *>(&xevent);
- lightgun.buttons[button->button] = (xevent.type == button_press_type) ? 0x80 : 0;
+
+ /*
+ * SDL/X11 Number the buttons 1,2,3, while windows and other parts of MAME
+ * like offscreen_reload expect 0,2,1. Transpose buttons 2 and 3, and then
+ * -1 the button number to align the numbering schemes.
+ */
+ int button_number = button->button;
+ switch (button_number)
+ {
+ case 2:
+ button_number = 3;
+ break;
+ case 3:
+ button_number = 2;
+ break;
+ }
+ lightgun.buttons[button_number - 1] = (xevent.type == button_press_type) ? 0x80 : 0;
}
}