-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.JOYSTICKS.FREEBSD
96 lines (73 loc) · 3.27 KB
/
README.JOYSTICKS.FREEBSD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
FreeBSD joystick support
------------------------
FreeBSD supports two flavors of joysticks: analog and USB. By default,
non-root users do not have access to these devices on FreeBSD, and the
required devices may not even be created yet. Please browse the below
notes before writing to the plib mailing list.
Contents of this file:
-----------
Analog joysticks
USB joysticks
Testing the joysticks
Compiling and linking
Analog joysticks
----------------
Plib uses the joy(4) interface to analog joysticks. You will need to
make sure the device files exist:
ls -l /dev/joy*
If they do not yet exist, create them (logged in as root):
cd /dev
sh MAKEDEV joy
By default, they will have permissions that do not allow unprivileged
users access to them:
crw-r----- 1 root operator 51, 0 Aug 30 16:59 joy0
crw-r----- 1 root operator 51, 1 Aug 30 16:59 joy1
You may wish to consider making the devices world read/writable:
chmod a+rw /dev/joy*
Users of xdm(1) or any of its more modern successors may wish to look
into GiveConsole and TakeConsole or its equivalent.
If you do not have a joystick driver compiled into you kernel, you can
load one dynamically with the command
kldload joy
When in doubt, check the FreeBSD handbook about making sure this driver
is loaded every time you reboot.
USB joysticks
-------------
Plib uses the usbhid(3) interface to USB joysticks. Joysticks will show
up as generic USB Human Interface Devices (uhid). Because the USB design
allows an almost unlimited number of USB buses and USB devices, you should
make sure you have enough devices in /dev to deal with your devices.
When in doubt, create a few extra to make sure. If you have insufficient
USB or uhid devices, your joystick may not appear at all, or it may
disappear if you connect your USB devices in a different order.
Fortunately, device nodes are free. For example, you might see this:
ls -al /dev/usb* /dev/uhid*
crw-rw---- 1 root operator 108, 255 Apr 12 01:44 /dev/usb
crw-rw---- 1 root operator 108, 0 Apr 12 01:44 /dev/usb0
crw-rw---- 1 root operator 122, 0 Apr 12 01:44 /dev/uhid0
This shows you have one usb interface (/dev/usb itself doesn't count), and
one uhid device. Make a few extra with
cd /dev
sh MAKEDEV usb0 usb1 usb2 usb3 uhid0 uhid1 uhid2 uhid3
(you can leave out the devices that exist already).
Next, you'll have to think about permissions. Both the /dev/usb0..3
(but not /dev/usb) have to be world readable, as well as the uhid devices.
This command will take care of it:
chmod a+r /dev/usb?* /dev/uhid*
(yes, the "?*" after /dev/usb is intentional).
Obviously, any permission change you make is at your own risk! XDM users
may use the GiveConsole/TakeConsole mechanism as an alternative.
Plib will complain if /dev/uhid* or /dev/usb* exist but are
unreadable with your current privileges.
Testing the joysticks
---------------------
Users of FlightGear can quickly test their joysticks with the js_demo
program.
Compiling and linking
---------------------
Compile plib on FreeBSD with the same compiler options as used for the
other libraries you may use. In particular, if you use pthreads anywhere
in your application, you should compile Plib with
g++ -pthread
Applications linking to recent Plib's -ljs should add -lusbhid to the
link command line in the Makefile.