Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux X11 Input: Fix lightgun support #4698

Merged
merged 1 commit into from
Mar 1, 2019
Merged

Conversation

kiall
Copy link
Contributor

@kiall kiall commented Feb 28, 2019

SDL/X11 number mouse/lighgun 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.

This fixes lightgun support on Linux - tested with an Ultimarc AimTrak and
the following config:

lightgun                  1
lightgun_device           lightgun
lightgunprovider          x11
lightgun_index1           "Ultimarc Ultimarc"
offscreen_reload          1

Note: MAME must be compiled with XInput support:

make -j10 NO_USE_XINPUT=0

Fixes bug #4695

With these changes, Lightguns on linux are perfectly accurate (well, as accurate as the gun itself allows... I miss real lightguns ;))

SDL/X11 number mouse/lighgun 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.

This fixes lightgun support on Linux - tested with an Ultimarc AimTrak and
the following config:

    lightgun                  1
    lightgun_device           lightgun
    lightgunprovider          x11
    lightgun_index1           "Ultimarc Ultimarc"
    offscreen_reload          1

Note: MAME must be compiled with XInput support:

    make -j10 NO_USE_XINPUT=0

Fixes bug mamedev#4695
@rb6502 rb6502 merged commit 9cf8cf0 into mamedev:master Mar 1, 2019
@kiall kiall deleted the bug-4695 branch March 2, 2019 14:45
@kiall
Copy link
Contributor Author

kiall commented Mar 2, 2019

Some extra tips in case anyone finds this PR on how to get these AimTrack lightguns working on Linux:

MAME Build:

  • Make sure MAME has been compiled with XInput support - make -j10 NO_USE_XINPUT=0

mame.ini:

lightgun                  1
lightgun_device           lightgun
lightgunprovider          x11
offscreen_reload          1
# If you have more than 1 gun, you must use the ID instead of name.
# The ID's can be found with `xinput list`. Note: The ID's are NOT
# predictable. IDs are assigned in the order the devices are detected.
# If you have multiple guns, I would highly recommend leaving them and
# all other input devices (mouse, keyboard, etc) plugged in at all times.
lightgun_index1           "Ultimarc Ultimarc"
#lightgun_index2           18
#lightgun_index3           19
#lightgun_index4           20

/etc/udev/rules.d/65-aimtrak.rules

# Set mode & disable libinput handling to avoid X11 picking up the wrong interfaces/devices.
SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="160*", MODE="0666", ENV{ID_INPUT}="", ENV{LIBINPUT_IGNORE_DEVICE}="1"

# For ID_USB_INTERFACE_NUM==2, enable libinput handling.
SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="160*", ENV{ID_USB_INTERFACE_NUM}=="02", ENV{ID_INPUT}="1", ENV{LIBINPUT_IGNORE_DEVICE}="0"

# For each gun, assign a predictable symlink. These are unused, but can be helpful when debugging. 
SUBSYSTEM=="input", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="1601", ENV{ID_INPUT}=="1", SYMLINK+="input/gun1"
SUBSYSTEM=="input", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="1602", ENV{ID_INPUT}=="1", SYMLINK+="input/gun2"
SUBSYSTEM=="input", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="1603", ENV{ID_INPUT}=="1", SYMLINK+="input/gun3"
SUBSYSTEM=="input", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="1604", ENV{ID_INPUT}=="1", SYMLINK+="input/gun4"

/etc/X11/xorg.conf.d/60-aimtrak.conf

Section "InputClass"
	Identifier "AimTrak Gun 1"
	MatchDevicePath "/dev/input/event*"
	MatchUSBID "d209:1601"
	Driver "libinput"
	Option "Floating" "yes"
	Option "AutoServerLayout" "no"
EndSection

Section "InputClass"
	Identifier "AimTrak Gun 2"
	MatchDevicePath "/dev/input/event*"
	MatchUSBID "d209:1602"
	Driver "libinput"
	Option "Floating" "yes"
	Option "AutoServerLayout" "no"
EndSection

Section "InputClass"
	Identifier "AimTrak Gun 3"
	MatchDevicePath "/dev/input/event*"
	MatchUSBID "d209:1603"
	Driver "libinput"
	Option "Floating" "yes"
	Option "AutoServerLayout" "no"
EndSection

Section "InputClass"
	Identifier "AimTrak Gun 4"
	MatchDevicePath "/dev/input/event*"
	MatchUSBID "d209:1604"
	Driver "libinput"
	Option "Floating" "yes"
	Option "AutoServerLayout" "no"
EndSection

@kiall
Copy link
Contributor Author

kiall commented Mar 5, 2019

I let Andy (from Ultimarc..) know about the difficulty with multiple Aimtrak guns, looks like it's something they will fix in the next firmware. Likely, any firmware AFTER after 1.19 (or is 2.19 current? Not at my cab to check...) will have a fix that means you can just specify the device names for each, and not have to worry about the ever changing X11 ID numbers.

NOTE: I say "likely" because they haven't committed to making the change... Just my guess given the response!

@kiall
Copy link
Contributor Author

kiall commented Apr 5, 2019

Another PR for Linux lightguns - #4862

@tonymaro
Copy link

tonymaro commented Jun 5, 2023

Note: The use of "Ultimarc Ultimarc" is specifically a bug according to the manufacturer. They initially released a patch to fix that but a particular arcade manufacturer had hard-coded it into their software (according to Andy). Ultimarc sent me a corrected firmware for the guns (9.21) that causes the guns to be uniquely identified as "Ultimarc ATAK Device #1" ... "Device #2", etc. This pretty much eliminates any weird workarounds or use of the XInput device ID # which is notoriously unstable.

I know this has already been merged but they won't let me post in Reddit in the MAME group and wanted to leave this for posterity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants