Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up --- Bug Reports --- Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Aimtrak light gun and Ubuntu  (Read 9456 times)

0 Members and 1 Guest are viewing this topic.

DOX1842

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 1
  • Last login:May 19, 2018, 12:43:42 pm
  • I want to build my own arcade controls!
Aimtrak light gun and Ubuntu
« on: April 05, 2018, 07:45:05 pm »
Hey everyone! So I have a retropie x86 setup running ubuntu and I was hoping to get my aimtrak working with it. When I connect the gun it works like a mouse except the cursur is super sensitive. I loaded up the 3rd party calibration program and it doesnt even detect my gun! I tried it on my windows laptop just to make sure it wasnt a hardware issue and it works ok. I played some time crisis for a while and to be honest, the accuracy was kind of off but it  did alright. I was wondering if anyone has any tips with getting this to work with linux as I do not use my windows pc to run emulators.

MacGyver

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 316
  • Last login:May 16, 2022, 08:42:14 am
    • Project Build
Re: Aimtrak light gun and Ubuntu
« Reply #1 on: April 20, 2018, 07:58:19 am »
Might try adjusting the acceleration (sensitivity and digital speed) for the analog control in MAME, however, if it works like all the other Linux SDL versions, adjusting "Mouse1 X&Y" for the gun might screw up any spinners and trackballs that are also "Mouse1 X&Y".

SDL has been promising for nearly a decade that they would be adding multiple mouse support to "the next release" so don't hold your breathe at them fixing it if adjusting one screws up the others.

[edit]
That's not really very fair of me, SDL is free software worked on by volunteers, it's just frustrating to those of us that have been waiting a long time to free our cabinets from Windows.
« Last Edit: April 22, 2018, 03:29:09 pm by MacGyver »

kiall

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 1
  • Last login:March 08, 2019, 11:47:56 am
Re: Aimtrak light gun and Ubuntu
« Reply #2 on: March 08, 2019, 08:52:19 am »
Reviving an old thread, but .. I got these working flawlessly.

Details here: https://github.com/mamedev/mame/pull/4698

The PR was merged AFTER 0.206 was released, so will be part of MAME from 0.207 on.

TLDR: Multiple guns working, perfect accuracy (within what the guns themselves allow for), etc.

MacGyver

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 316
  • Last login:May 16, 2022, 08:42:14 am
    • Project Build
Re: Aimtrak light gun and Ubuntu
« Reply #3 on: May 10, 2020, 10:00:16 pm »
Can confirm.  I just compiled a .220 version following the instructions on the Git page and both guns work perfectly under Linux.
I've copied kiall's instructions from there to here in case those go away.

Reviving an old thread, but .. I got these working flawlessly.

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 -
Code: [Select]
make -j4 NO_USE_XINPUT=0

in mame.ini:
Code: [Select]
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

sudo nano /etc/udev/rules.d/65-aimtrak.rules
Code: [Select]
# 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"


sudo nano /etc/X11/xorg.conf.d/60-aimtrak.conf
or (since Ubuntu 10.10)
sudo nano /usr/share/X11/xorg.conf.d/60-aimtrak.conf
Code: [Select]
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


Original details here: https://github.com/mamedev/mame/pull/4698

The PR was merged AFTER 0.206 was released, so will be part of MAME from 0.207 on.

TLDR: Multiple guns working, perfect accuracy (within what the guns themselves allow for), etc.



Thanks for the fix kiall.  :cheers:
« Last Edit: May 11, 2020, 11:18:55 am by MacGyver »

MacGyver

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 316
  • Last login:May 16, 2022, 08:42:14 am
    • Project Build
Re: Aimtrak light gun and Ubuntu
« Reply #4 on: May 18, 2020, 12:50:19 am »
Correction, mine work until I reboot, then something about the udev rules are wrong and the guns completely disappear. If you exclude the udev rules then both guns work, only their IDs are random following a reboot and you will have to fix mame.ini before playing.

I'm guessing that this method and the official version that is similar to this must have worked at some point, just trying to figure out why it doesn't work anymore.

I can see a way of scripting this to build a correct mame.ini every time, but it has to be simpler than that.

« Last Edit: May 19, 2020, 06:31:14 pm by MacGyver »

MacGyver

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 316
  • Last login:May 16, 2022, 08:42:14 am
    • Project Build
Re: Aimtrak light gun and Ubuntu
« Reply #5 on: May 18, 2020, 03:33:28 pm »
So it looks like they would work just fine if I had the ability to set an attribute "ATTR{product}" on the devices to something custom, but the only things I can set are variables "ENV{ID_VENDOR_ENC}" and xinput (and the xinput subsystem in MAME) doesn't use those.

So when MAME tries to assign the guns they are presented with:
Code: [Select]
$xinput list
~Ultimarc Ultimarc                        id= 9 [floating slave]
~Ultimarc Ultimarc                        id=20 [floating slave]
because the both fields are the same (despite there being a ATTR{configuration} available that is unique on both devices).

Here is what MAME -v spits out using the mame.ini recommendations from the official docs at https://docs.mamedev.org/advanced/linux-lightguns.html:
Code: [Select]
Lightgun: Begin initialization
Lightgun mapping: Logical id 1: UltimarcATRAKDevice#1
Lightgun mapping: Logical id 2: UltimarcATRAKDevice#2
Input: Adding lightgun #0: UltimarcATRAKDevice#1 (device id: UltimarcATRAKDevice#1)
0: UltimarcATRAKDevice#1
Evaluating device with name: Virtual core pointer
Evaluating device with name: Virtual core keyboard
Evaluating device with name: Virtual core XTEST pointer
Evaluating device with name: Virtual core XTEST keyboard
Evaluating device with name: Power Button
Evaluating device with name: Video Bus
Evaluating device with name: Power Button
Evaluating device with name: Eee PC WMI hotkeys
Evaluating device with name: Logitech K400 Plus
Evaluating device with name: Logitech K400 Plus
Evaluating device with name: Ultimarc IPAC 2 Ultimarc IPAC 2
Evaluating device with name: Ultimarc IPAC 2 Ultimarc IPAC 2
Evaluating device with name: Ultimarc Ultimarc
Evaluating device with name: Ultimarc IPAC 2 Ultimarc IPAC 2
Evaluating device with name: GGG TurboTwist 2 Spinner
Evaluating device with name: Universal Human Interface Device Universal Human Interface Device
Evaluating device with name: Universal Human Interface Device Universal Human Interface Device
Evaluating device with name: Ultimarc Ultimarc
Evaluating device with name: Universal Human Interface Device Universal Human Interface Device
Evaluating device with name: Trackball/Spinner Interface Trackball/Spinner Interface
Can't find device UltimarcATRAKDevice#1!
Input: Adding lightgun #1: UltimarcATRAKDevice#2 (device id: UltimarcATRAKDevice#2)
1: UltimarcATRAKDevice#2
Evaluating device with name: Virtual core pointer
Evaluating device with name: Virtual core keyboard
Evaluating device with name: Virtual core XTEST pointer
Evaluating device with name: Virtual core XTEST keyboard
Evaluating device with name: Power Button
Evaluating device with name: Video Bus
Evaluating device with name: Power Button
Evaluating device with name: Eee PC WMI hotkeys
Evaluating device with name: Logitech K400 Plus
Evaluating device with name: Logitech K400 Plus
Evaluating device with name: Ultimarc IPAC 2 Ultimarc IPAC 2
Evaluating device with name: Ultimarc IPAC 2 Ultimarc IPAC 2
Evaluating device with name: Ultimarc Ultimarc
Evaluating device with name: Ultimarc IPAC 2 Ultimarc IPAC 2
Evaluating device with name: GGG TurboTwist 2 Spinner
Evaluating device with name: Universal Human Interface Device Universal Human Interface Device
Evaluating device with name: Universal Human Interface Device Universal Human Interface Device
Evaluating device with name: Ultimarc Ultimarc
Evaluating device with name: Universal Human Interface Device Universal Human Interface Device
Evaluating device with name: Trackball/Spinner Interface Trackball/Spinner Interface
Can't find device UltimarcATRAKDevice#2!
Lightgun: End initialization


The official docs say to use this in mame.ini:
Code: [Select]
lightgun_index1 "Ultimarc ATRAK Device #1"
lightgun_index2 "Ultimarc ATRAK Device #2"
lightgun_index3 "Ultimarc ATRAK Device #3"
lightgun_index4 "Ultimarc ATRAK Device #4"

but because xinput only splits out "Ultimarc Ultimarc" for both guns that won't work.

And if you set them to "Ultimarc Ultimarc", it will complain because of this piece of code in mame's input_x11.cpp:
Code: [Select]
for(loop = 0; loop < num_devices; loop++)
{
osd_printf_verbose("Evaluating device with name: %s\n", devices[loop].name);

// if only extended devices and our device isn't extended, skip
if (only_extended && devices[loop].use < IsXExtensionDevice)
continue;

// Adjust name to remove spaces for accurate comparison
std::string name_no_space = remove_spaces(devices[loop].name);
if ((!is_id && strcmp(name_no_space.c_str(), name) == 0)
|| (is_id && devices[loop].id == id))
{
if (found)
{
osd_printf_verbose(
"Warning: There are multiple devices named \"%s\".\n"
"To ensure the correct one is selected, please use "
"the device ID instead.\n\n", name);
}
else
{
found = &devices[loop];
}
}
}
return found;


What am I missing here?  Why can't I get it to work?
Can someone explain to me how to set the attribute "ATTR{product}" on each to the "ATRAK Device #1" that mame is expecting back.

I have tried making a rule:
Code: [Select]
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="1601", ATTR{product}="ATRAKDevice#1"
It works in that it matches and should work but doesn't.
This works:
Code: [Select]
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="1601", ENV{ID_VENDOR_ENC}="ATRAKDevice#1"
But is worthless.

Any ideas? I'm thinking that new Aimtraks likely don't have this problem, but mine are old and on firmware 1.15, and I can find no other firmware other than 9.19 and that won't run on my Aimtraks)

(EDIT: I removed a lot of the troubleshooting from this post)
« Last Edit: May 19, 2020, 06:30:28 pm by MacGyver »

MacGyver

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 316
  • Last login:May 16, 2022, 08:42:14 am
    • Project Build
Re: Aimtrak light gun and Ubuntu
« Reply #6 on: May 19, 2020, 04:43:52 pm »
Just in case anyone finds this thread with the same problem, the issue was the age of my guns and the firmware they had.
They were on 1.15 from around 8 years ago, and it was like I thought, they made some changes and improvements to the firmware since then (who would have thought :) ) , I emailed Andy and even though he no longer even had that old hardware on hand to test he was able to compile a new version that output a distinctive model when polled, and it worked perfectly.
Now xinput outputs like this:
Code: [Select]
Ultimarc ATRAK Device #1                id=9 [floating slave]
Ultimarc ATRAK Device #2                id=20 [floating slave]


The official MAME instructions (https://docs.mamedev.org/advanced/linux-lightguns.html) now work as they should but the portion "Configure Xorg inputs" will break them in Daphne/Singe because it makes them floating and no longer part of the main mouse, both guns will work just fine under an X11 compiled version of MAME (non SDL and after version 0.206) with that part sipped.
Skip this part to keep Daphne Singe working:
Code: [Select]
In /etc/X11/xorg.conf.d/60-aimtrak.conf we will need:

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

Thank you Andy at Ultimarc for always being there for us.  :cheers:
« Last Edit: June 06, 2020, 01:49:20 pm by MacGyver »

meduza

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 56
  • Last login:August 30, 2021, 10:38:29 am
  • I want to build my own arcade controls!
    • LEDSpicer wiki
Re: Aimtrak light gun and Ubuntu
« Reply #7 on: October 20, 2020, 11:15:17 am »
I Confirm this is working on Ubuntu 20.04 with mame 220


alxld

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 1
  • Last login:April 16, 2021, 12:24:42 am
  • I want to build my own arcade controls!
Re: Aimtrak light gun and Ubuntu
« Reply #8 on: February 08, 2021, 08:21:51 pm »
Can you provide a link to the updated firmware?  My guns are still both showing up as "~Ultimarc Ultimarc", and given their age, I think I need the same update you did.

Also, do you have any details on getting MAME compiled for X11?  I've looked around and can't find any information.

MacGyver

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 316
  • Last login:May 16, 2022, 08:42:14 am
    • Project Build
Re: Aimtrak light gun and Ubuntu
« Reply #9 on: September 17, 2021, 02:55:27 am »
Holy late reply Batman.

make -j4 NO_USE_XINPUT=0

Nitro0602

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 119
  • Last login:Yesterday at 02:24:28 am
  • I want to build my own arcade controls!
Re: Aimtrak light gun and Ubuntu
« Reply #10 on: December 26, 2021, 03:37:36 am »
Hey guys! Could someone help me.. both my aimtrak guns are reading as mouse1. How can I change their IDís to 1 and 2?