This tutorial will guide you through the process of setting up game controllers on a FreeBSD system.
Before you start, you will need to install the devel/sdl2
port with make config
and enable HIDAPI and UDEV.
Then, run make install
to install it system-wide.
You may also need to install the following packages, depending on your specific controller and needs:
x11-toolkits/qt5-gamepad
for use with QT applicationsmultimedia/webcamd
for certain controllers, such as the Xbox controllerx11-drivers/xf86-input-joystick x11-drivers/xf86-input-evdev
for extended X11 supportdevel/libgamepad devel/allegro
for everything else
Also, you may need to enable some specific drivers according to your gamepad model - I'm going to go through it soon:
- hgame(4) driver for generic HID game controllers
- ps4dshock(4) driver for Sony's DualShock 4 controllers
- x360gp(4) driver for Microsoft's Xbox 360 controllers
To enable a module, you need to add the following to your /boot/loader.conf
: <module>_load="YES"
. For example: hgame_load="YES"
.
To enable USB HID support, you will need to add the following lines to your /boot/loader.conf
file:
usbhid_load="YES"
hw.usb.usbhid.enable=1
And run this command: sysrc kld_list+=usbhid && kldload usbhid
To enable webcamd, you will need to add the following line to your /etc/rc.conf
file:
webcamd_enable="YES"
If you are using a DualShock or DualSense controller, you may need to follow a few extra steps.
First, add the following sections to your /usr/local/etc/devd/sony.conf
file:
# DualSense
notify 100 {
match "system" "USB";
match "subsystem" "INTERFACE";
match "type" "ATTACH";
match "vendor" "0x054c";
match "product" "0x0ce6";
action "chgrp games /dev/$cdev; chmod 660 /dev/$cdev";
};
# DualShock 4
notify 100 {
match "system" "USB";
match "subsystem" "INTERFACE";
match "type" "ATTACH";
match "vendor" "0x054c";
match "product" "0x05c4";
action "chgrp games /dev/$cdev; chmod 660 /dev/$cdev";
};
Then, add the following line to your /etc/devfs.rules
file:
[system=10]
add path 'input*' mode 0660 group games
add path 'input' mode 0775 group games
Finally, add the following line to your /etc/rc.conf
file:
devfs_system_ruleset="system"
To ensure that you can access the device, make sure you are a member of the games
group by running pw groupmod games -m <username>
.
To test your configuration, you can use the wine control joy.cpl
command or try running
a QT application that uses gamepad input.