Linux driver for the GunCon 2 light gun.
- A joystick device:
- Reports absolute
ABS_XandABS_Ypositions from the GunCon 2 sensor. - Reports trigger and other buttons as standard gamepad buttons (e.g. trigger as
BTN_LEFTby default).
- Reports absolute
- A mouse device:
- Provides relative motion and a standard mouse left-click, mapped from the same GunCon 2 trigger.
Emulators and frontends can use either:
- The joystick device (absolute aiming + buttons), or
- The mouse device (relative pointer + left click), depending on what works best.
The GunCon 2 must be calibrated for your display.
The joystick device’s ABS_X and ABS_Y ranges can be adjusted using evdev-joystick. This allows you to map the raw GunCon 2 coordinates to the visible area of your screen.
Example (adjust the values to your setup):
# X axis (joystick device)
evdev-joystick --e /dev/input/by-id/usb-0b9a_016a-event-joystick -m 175 -M 720 -a 0
# Y axis (joystick device)
evdev-joystick --e /dev/input/by-id/usb-0b9a_016a-event-joystick -m 20 -M 240 -a 1It is also included a simple script for calibrating the GunCon 2, however the calibration must be performed each time the GunCon 2 is connected. This can be done with a set of udev rules.
For example;
SUBSYSTEM=="input", ATTRS{idVendor}=="0b9a", ATTRS{idProduct}=="016a", ACTION=="add", RUN+="/bin/bash -c 'evdev-joystick --e %E{DEVNAME} -m 175 -M 720 -a 0; evdev-joystick --e %E{DEVNAME} -m 20 -M 240 -a 1'"The build requires a C compiler, GNU Make, and headers matching the target kernel.
Build and install the module for the running kernel:
make -j"$(nproc)"
sudo make install
sudo modprobe guncon2The module is installed under /lib/modules/$(uname -r)/extra/ by default.
The modules_install target remains available as an alias for install.
Build the module without installing it, then load it temporarily:
make modules
sudo insmod ./guncon2.koRun make help for the complete target and override list. For example:
make KERNEL_RELEASE=6.12.0-rpi-2712 modules
make KDIR=/path/to/kernel/build modules
make DESTDIR=/tmp/guncon2-package installKERNEL_RELEASE defaults to the running kernel, and KDIR defaults to its
build directory under /lib/modules/.
Unload the driver before uninstalling it if it is currently in use:
sudo modprobe -r guncon2
sudo make uninstallTo reload the driver after rebuilding it, unload it with
sudo modprobe -r guncon2 before loading it again.