Bug#922662: xboxdrv: some systemd unit
cacatoes at tuxfamily.org
cacatoes at tuxfamily.org
Sat Aug 12 15:32:26 BST 2023
Hello,
I myself tried to put some glue, it works but I realized it could have
been better to do it another way.
Method 1 : several instances of xboxdrv started with udev+systemd
(that's what I did)
Method 2 : xboxdrv as a daemon managed by systemd (maybe a better
option)
Method 1:
At first I got inspired by this:
https://github.com/phantom-voltage/xboxdrv-udev-rules
But prefered not to use a shell script and directly manage xboxdrv
through systemd.
Attached are the files doing the job for me.
Steps to use:
1) Write udev rules with identifiers for your devices
2) Write a .xboxdrv file for each unique controller
3) Copy all files (a template systemd unit, a udev rules file, xboxdrv
configs) in their dirs.
4) # systemctl daemon-reload
# systemctl reload udev
5) It's ready.
Pros/cons:
+ simple to implement
- write udev rules manually (xboxdrv could manage this itself)
- not so generic, and have to edit files in various parts for each new
controller
Method 2:
Check arch package, I hadn't the opportunity to dig into it, but maybe
running xboxdrv as a daemon makes it easier to handle more usecases.
https://aur.archlinux.org/packages/xboxdrv
-------------- next part --------------
# Microsoft Xbox Series USB
[xboxdrv]
evdev=/dev/input/by-id/usb-Microsoft_Controller_#########-event-joystick
mimic-xpad=true
#detach-kernel-driver=true
#evdev-grab=true
#dpad-as-button=true
#silent=true
#evdev-debug=true
[evdev-absmap]
ABS_X = x1
ABS_Y = y1
ABS_RX = y2
ABS_RY = x2
ABS_Z = lt
ABS_RZ = rt
ABS_HAT0X = dpad_x
ABS_HAT0Y = dpad_y
[axismap]
-Y1=Y1
[evdev-keymap]
BTN_A=a
BTN_B=b
BTN_X=x
BTN_Y=y
BTN_TL=lb
BTN_TR=rb
BTN_SELECT=Back
BTN_START=Start
# EOF #
-------------- next part --------------
### Udev rules for gamepads ###
# Add the two rules (plugged/unplugged) for each gametype model you own.
# You don't need to add new rules if you own several gamepads of the same model.
#
# Each unique gamepad is handled by its own instance of the xboxdrv systemd unit.
#
# We try to identify each unique gamepad with this combination of attributes:
# $attr{idVendor}-$attr{idProduct}-$attr{serial}
#
# For this to work, you need to provide a xboxdrv config for each unique gamepad you own.
## Gamepads ##
# Microsoft Xbox Series Controller S|X
KERNEL=="event*", SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0b12", SYMLINK+="input/$attr{idVendor}-$attr{idProduct}-$attr{serial}", ACTION=="add", RUN+="/usr/bin/systemctl start xboxdrv@$attr{idVendor}-$attr{idProduct}-$attr{serial}"
KERNEL=="event*", SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0b12", ACTION=="remove", RUN+="/usr/bin/systemctl stop xboxdrv@$attr{idVendor}-$attr{idProduct}-$attr{serial}"
# Logitec Rumblepad 2
KERNEL=="event*", SUBSYSTEM=="input", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c218", SYMLINK+="input/$attr{idVendor}-$attr{idProduct}-$attr{serial}", ACTION=="add", RUN+="/usr/bin/systemctl start xboxdrv@$attr{idVendor}-$attr{idProduct}-$attr{serial}"
KERNEL=="event*", SUBSYSTEM=="input", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c218", ACTION=="remove", RUN+="/usr/bin/systemctl stop xboxdrv@$attr{idVendor}-$attr{idProduct}-$attr{serial}"
-------------- next part --------------
[Unit]
Description=A Xbox/Xbox360 userspace gamepad driver
[Service]
Type=simple
User=root
ExecStart=/usr/bin/xboxdrv -c /etc/xboxdrv/%i.xboxdrv
# Or use a PID?
ExecStop=pkill --signal 1 -f "/usr/bin/xboxdrv -c /etc/xboxdrv/%i.xboxdrv"
[Install]
WantedBy=multi-user.target
More information about the Pkg-games-devel
mailing list