Joystick API

wago

New Member


Messages: 1

joystick works for me on FreeBSD 12.1 using SDL. I was getting "no joystick found" although attached on /dev/input/event7 and /dev/input/js0, however I noticed the device was owned by webcamd user/group with 660 permissions. I think you can set up a devd rule but I added myself to the "webcamd" group and the joystick works. It's a USB M$ Xbox controller. I've been able to use it in SDL like this:

C:
...
SDL_Joystick* joy = NULL;

SDL_InitSubSystem(SDL_INIT_JOYSTICK);

if ( SDL_NumJoysticks() > 0 )
    joy = SDL_JoystickOpen( 0 );
    
SDL_Event e;
handleEvent(e)

if( e.type == SDL_JOYAXISMOTION )
{
    if( e.jaxis.which == 0 )
    {                       
        if( e.jaxis.axis == 3 ) //x
...
ref: https://wiki.libsdl.org/SDL_JoystickOpen
 
OP
A

A. D. Sharpe Sr.

Active Member

Reaction score: 27
Messages: 109

Just a short update. I've started working on this project, but I've hit a few road blocks. As part of my process, I'm developing a tool to allow me to enumerate usb devices & get notifications of connections/disconnections. This tool is written in C++ & uses libusb. The problem is that I can't access usb information without running the tool as root/su. I see this as being unreasonable, because users should be able to get this information in a GUI tool on their own machine. Currently, I'm researching a way to get around this road block. The fact that I'm in the wheel group doesn't seem to matter, in regards to accessing usb information. I'm looking at devd. I'm hoping that it has an API to allow me to directly query it for the information that I'm looking for. If anyone else has any ideas to help me get past this blockage, please let me know.
 

PaddyMac

Member

Reaction score: 12
Messages: 46

Just a short update. I've started working on this project, but I've hit a few road blocks. As part of my process, I'm developing a tool to allow me to enumerate usb devices & get notifications of connections/disconnections. This tool is written in C++ & uses libusb. The problem is that I can't access usb information without running the tool as root/su. I see this as being unreasonable, because users should be able to get this information in a GUI tool on their own machine. Currently, I'm researching a way to get around this road block. The fact that I'm in the wheel group doesn't seem to matter, in regards to accessing usb information. I'm looking at devd. I'm hoping that it has an API to allow me to directly query it for the information that I'm looking for. If anyone else has any ideas to help me get past this blockage, please let me know.
Have you been in contact with the developers of iichid? They've done a lot of work toward getting USB gamepads working in FreeBSD. I'll bet you could collaborate with them and make some good progress. As far as accessing devices as a regular user instead of root, I've had the same complaint. My suggestion is that the FreeBSD base system needs to add additional users and groups to give finer-grained control of who can access various devices in the system. In the meantime, adding devfs.rules entries may be a workaround.
 
OP
A

A. D. Sharpe Sr.

Active Member

Reaction score: 27
Messages: 109

Have you been in contact with the developers of iichid? They've done a lot of work toward getting USB gamepads working in FreeBSD. I'll bet you could collaborate with them and make some good progress. As far as accessing devices as a regular user instead of root, I've had the same complaint. My suggestion is that the FreeBSD base system needs to add additional users and groups to give finer-grained control of who can access various devices in the system. In the meantime, adding devfs.rules entries may be a workaround.
Honestly, I've never heard of that project. As for the hardware access problem, I'm thinking that there might have to be either a hardware daemon or some type of modification to devd to facilitate better access.
 
OP
A

A. D. Sharpe Sr.

Active Member

Reaction score: 27
Messages: 109

In FreeBSD 13.0, iichid is in base. I'm uncertain if this an underlying part of usbhid(3), which can be enabled in place of the traditional uhid(4).
It does look like it's going to be the replacement for the previous hid subsystem. It seems that there's no longer a reason for my project to even exist. In time, I'll upgrade my system to 13. Afterwards, I'll check to see if my usb joysticks work. If so, then I'm going to sit back & enjoy.
 
OP
A

A. D. Sharpe Sr.

Active Member

Reaction score: 27
Messages: 109

Your project or a variant of it can still exist.
I'm currently checking it out now. I just upgraded from FBSD 12.2 to 13. If it works the way I think it works, then all that's necessary is to make sure that iichid works nicely with SDL's input. If that all works out fine, then I can move forward to my real interest -native gaming on FBSD.
 
Top