Repository navigation
Conversation
a172122 to
6aefb35
Compare
a2eab0c to
72c4871
Compare
|
Only real thing i was unsure about is where to put SDL_SantrollerSubType and SDL_XInputSubType, if we want them to live somewhere else we can certainly move them |
| _this->syms.udev_device_unref(dev); | ||
|
|
||
| return found; | ||
| } |
There was a problem hiding this comment.
This seems like a very expensive function. Do you know how often it'll be called?
There was a problem hiding this comment.
It would only get called when MaybeAddDevice is called, since its only used by IsJoystick
The input scanning would bail out early before reaching IsJoystick as well so it should only really happen when a new joystick is plugged in, or at startup when scanning all plugged in joysticks for the first time
It only does the expensive descriptor trawl for new santroller devices via hid or new wired xinput devices via xpad, never other hid devices or wireless xinput devices
c6e94a5 to
95ff1e3
Compare
If udev is available, fetch the XInput subtypes and Santroller interfaces for SysJoystick devices. We do this by looking for specific vendor descriptors and then fetching the relevant device information.
…n't need to convert
…oards as a joystick type
ff6a315 to
a49c53c
Compare
Description
I created the Santroller firmware, which is used by the rhythm gaming community for emulating various rhythm game related peripherals.
I recently released Santroller 2, which was a complete rewrite and has the ability to emulate a sort of hub, where a user can plug multiple peripherals into it, and it presents itself as a composite USB device that either has multiple HID interfaces or multiple XInput interfaces, depending on what mode the user is using.
This adds support for either mode, via both hidapi and sysjoystick.
The older firmware only supported emulating a single device at a time, so its the simplest case - the joystick type is simply just placed in the usb devices revision so we simply pull that out and use it as is. Bluetooth works like this as well, as Santroller 1 and Santroller 2 only ever emulate a single device over bluetooth.
Since the newer firmware can emulate multiple devices, that wasn't going to work. As a result, I implemented a hid output / input reported based capabilities report that can be requested, which lets you retrieve things like what is device type is in use and what capabilities the device has.
For XInput and hid via sysjoystick, we needed another method to get the joystick type. I took a page from what i had implemented in
SDL_hidapi_xbox360.ca while ago, where i simply just parse the usb descriptor to find the vendor descriptor that tells us the subtype. Using udev we can get the sysfs path to the usb descriptor, and then parse that out to figure out the subtype.This worked so well that i just implemented a vendor descriptor for santroller 2 as well that contains the capabilities, so we can get the device type that way.
I didn't really like having a block hardcoded in multiple places for resolving subtypes / santroller types to their joystick type counterparts, so i pulled out some helper methods so we could handle it all in one place. I also pulled in my list of subtypes that i have built from looking at instruments over the years - there are a bunch of extra subtypes that microsoft has not documented that we can use for matching rhythm game peripherals.
Note that this XInput support extends to any wired XInput device handled via xpad, the subtype is directly pulled from the controller now instead of relying on the vids and pids being in the controller list.
Since i have all these extra types around now, i also added a musical keyboard and turntable joystick type.