USBJoystick 0.12

USB Joystick driver for RISC OS 5
richw
Posts: 137
Joined: Sat Sep 14, 2013 9:05 pm

Re: USB Joystick driver

Post by richw » Mon Oct 01, 2018 5:16 pm

I'll stick a bit of extra debug code in the next version, and then I might learn a bit if you can run Reporter whilst you start the module.

I am just going to look at my USB stuff in general, as I am sometimes getting 'bad request' messages. If I use *USBReset, or start plugging/unplugging devices, then they go away. I suspect it's less to do with my code, and more to do with the Pi and/or RISC OS itself, but I want to try and be sure! When I'm happier with that, and my recent reportID fixes, I'll release 0.09. Would be nice if someone could try that on a wired 360 controller.

Edit: I spied some USB funnies on your Debug output, Jon. The product name and manufacturer name should be shown, but they are not. I suspect the request to get this data is failing (Reporter probably shows 'bad request'). I want to try and understand why - there is probably a bug in my USB code.

The more I read on the wireless 360 controller, the more I conclude that it's going to be additional device detection and bespoke data processing. It would be nice if this could be slotted in to what I have.

JonAbbott
Posts: 2257
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: USB Joystick driver

Post by JonAbbott » Fri Oct 05, 2018 9:11 am

Here's what I could grab of the Reporter output for the XB360 controller if its of any use. Its missing the first few endpoints as there too much output. If I can figure out how to grab it all, I'll update the post:

Code: Select all

HID parser:   got button
HID parser:   got button, setting up button 4
HID parser:   got button,
HID parser:   got button, setting up button 5
HID parser:   got button
HID parser:   got button, setting up button 10
HID parser:   ignoring item
HID parser:   got button
HID parser:   got button, setting up button 0
HID parser:   got button
HID parser:   got button, setting up button 1
HID parser:   got button
HID parser:   got button, setting up button 2
HID parser:   got button
HID parser:   got button, setting up button 3
HID parser:   got supported axis, usage is 0x32, type is 7
HID parser:   copying axis HID item to index 0
HID parser:   got supported axis, usage is 0x35, type is 10
HID parser:   copying axis HID item to index 1
HID parser:   got supported axis, usage is 0x30, type is 5
HID parser:   copying axis HID item to index 2
HID parser:   got supported axis, usage is 0x31, type is 6
HID parser:   copying axis HID item to index 3
HID parser:   got supported axis, usage is 0x33, type is 8
HID parser:   copying axis HID item to index 4
HID parser:   got supported axis, usage is 0x34, type is 9
HID parser:   copying axis HID item to index 5
HID parser:   ignoring item
Parse completed - freeing libusbhid report descriptor memory
Analysing parse output to build axes info
Axis 0, item_usage is 50, type is 7, name is Z
Axis 1, item_usage is 53, type is 10, name is RZ
Axis 2, item_usage is 48, type is 5, name is X
Axis 3, item_usage is 49, type is 6, name is Y
Axis 4, item_usage is 51, type is 8, name is RX
Axis 5, item_usage is 52, type is 9, name is RY
Stick has DPAD and we have two axes spare to use
Joystick/gamepad parsed and configured successfully (joy_index is 2)
Endpoint descriptor: EndpointAddress=131, (on TnterfaceNumber=2)
Endpoint descriptor: We think this is a joystick (got HID report descriptor and it looks good), so set up
Set up: Fill up joystick info
Set up: Manufacturer: 
Set up: Product: Xbox 360 Wireless Receiver for Windows
Set up: Serial: FD8EAC00
Set up: Constructed DeviceFS path for stick id 2, path is: devices#interface=2;endpoint=3;nopad;noblock:USB5
Set up: Open a connection to the joystick (id is 2)
Endpoint descriptor: EndpointAddress=3, (on TnterfaceNumber=2)
Endpoint descriptor: We think this isn't a joystick - ignore this endpoint
Interface descriptor: InterfaceNumber=3, InterfaceClass=255 (3 is HID), iInterface=0, csInterfaceClass=0xff5d82
Other descriptor: type is 34 - not Device/Config/Interface/Endpoint (csDeviceClass is 0xffffff, csInterfaceClass is 0xff5d82)
Will check interface class
Interface class looks like an XBOX360 controller, using baked-in HID report descriptor
usb_hid_set_output_report: reqtype 33, req 9, value 512, index 3, length 3
Unable to switch off XBOX360 LEDs: Bad request
Will use joystick number 3 (next available) for this HID parse
Shared report descriptor 'rd' (size=166) with libusbhid
Got hid report size/dlen 20 for reportid 0, offset is 0
Starting parse of HID report descriptor
HID parser:   got dpad up
HID parser:   got got dpad up, copying
HID parser:   got dpad down
HID parser:   got got dpad down, copying
HID parser:   got dpad left
HID parser:   got got dpad left, copying
HID parser:   got dpad right
HID parser:   got got dpad right, copying
HID parser:   got button
HID parser:   got button, setting up button 7
HID parser:   got button
HID parser:   got button, setting up button 6
HID parser:   got button
HID parser:   got button, setting up button 8
HID parser:   got button
HID parser:   got button, setting up button 9
HID parser:   got button
HID parser:   got button, setting up button 4
HID parser:   got button
HID parser:   got button, setting up button 5
HID parser:   got button
HID parser:   got button, setting up button 10
HID parser:   ignoring item
HID parser:   got button
HID parser:   got button, setting up button 0
HID parser:   got button
HID parser:   got button, setting up button 1
HID parser:   got button
HID parser:   got button, setting up button 2
HID parser:   got button
HID parser:   got button, setting up button 3
HID parser:   got supported axis, usage is 0x32, type is 7
HID parser:   copying axis HID item to index 0
HID parser:   got supported axis, usage is 0x35, type is 10
HID parser:   copying axis HID item to index 1
HID parser:   got supported axis, usage is 0x30, type is 5
HID parser:   copying axis HID item to index 2
HID parser:   got supported axis, usage is 0x31, type is 6
HID parser:   copying axis HID item to index 3
HID parser:   got supported axis, usage is 0x33, type is 8
HID parser:   copying axis HID item to index 4
HID parser:   got supported axis, usage is 0x34, type is 9
HID parser:   copying axis HID item to index 5
HID parser:   ignoring item
Parse completed - freeing libusbhid report descriptor memory
Analysing parse output to build axes info
Axis 0, item_usage is 50, type is 7, name is Z
Axis 1, item_usage is 53, type is 10, name is RZ
Axis 2, item_usage is 48, type is 5, name is X
Axis 3, item_usage is 49, type is 6, name is Y
Axis 4, item_usage is 51, type is 8, name is RX
Axis 5, item_usage is 52, type is 9, name is RY
Stick has DPAD and we have two axes spare to use
Joystick/gamepad parsed and configured successfully (joy_index is 3)
Endpoint descriptor: EndpointAddress=132, (on TnterfaceNumber=3)
Endpoint descriptor: We think this is a joystick (got HID report descriptor and it looks good), so set up
Set up: Fill up joystick info
Set up: Manufacturer: 
Set up: Product: Xbox 360 Wireless Receiver for Windows
Set up: Serial: FD8EAC00
Set up: Constructed DeviceFS path for stick id 3, path is: devices#interface=3;endpoint=4;nopad;noblock:USB5
Set up: Open a connection to the joystick (id is 3)
Endpoint descriptor: EndpointAddress=4, (on TnterfaceNumber=3)
Endpoint descriptor: We think this isn't a joystick - ignore this endpoint
Interface descriptor: InterfaceNumber=4, InterfaceClass=255 (3 is HID), iInterface=0, csInterfaceClass=0xff5d81
Other descriptor: type is 34 - not Device/Config/Interface/Endpoint (csDeviceClass is 0xffffff, csInterfaceClass is 0xff5d81)
Will check interface class
Interface class looks like an XBOX360 controller, using baked-in HID report descriptor
usb_hid_set_output_report: reqtype 33, req 9, value 512, index 4, length 3
Unable to switch off XBOX360 LEDs: Bad request
Will use joystick number 4 (next available) for this HID parse
Shared report descriptor 'rd' (size=166) with libusbhid
Got hid report size/dlen 20 for reportid 0, offset is 0
Starting parse of HID report descriptor
HID parser:   got dpad up
HID parser:   got got dpad up, copying
HID parser:   got dpad down
HID parser:   got got dpad down, copying
HID parser:   got dpad left
HID parser:   got got dpad left, copying
HID parser:   got dpad right
HID parser:   got got dpad right, copying
HID parser:   got button
HID parser:   got button, setting up button 7
HID parser:   got button
HID parser:   got button, setting up button 6
HID parser:   got button
HID parser:   got button, setting up button 8
HID parser:   got button
HID parser:   got button, setting up button 9
HID parser:   got button
HID parser:   got button, setting up button 4
HID parser:   got button
HID parser:   got button, setting up button 5
HID parser:   got button
HID parser:   got button, setting up button 10
HID parser:   ignoring item
HID parser:   got button
HID parser:   got button, setting up button 0
HID parser:   got button
HID parser:   got button, setting up button 1
HID parser:   got button
HID parser:   got button, setting up button 2
HID parser:   got button
HID parser:   got button, setting up button 3
HID parser:   got supported axis, usage is 0x32, type is 7
HID parser:   copying axis HID item to index 0
HID parser:   got supported axis, usage is 0x35, type is 10
HID parser:   copying axis HID item to index 1
HID parser:   got supported axis, usage is 0x30, type is 5
HID parser:   copying axis HID item to index 2
HID parser:   got supported axis, usage is 0x31, type is 6
HID parser:   copying axis HID item to index 3
HID parser:   got supported axis, usage is 0x33, type is 8
HID parser:   copying axis HID item to index 4
HID parser:   got supported axis, usage is 0x34, type is 9
HID parser:   copying axis HID item to index 5
HID parser:   ignoring item
Parse completed - freeing libusbhid report descriptor memory
Analysing parse output to build axes info
Axis 0, item_usage is 50, type is 7, name is Z
Axis 1, item_usage is 53, type is 10, name is RZ
Axis 2, item_usage is 48, type is 5, name is X
Axis 3, item_usage is 49, type is 6, name is Y
Axis 4, item_usage is 51, type is 8, name is RX
Axis 5, item_usage is 52, type is 9, name is RY
Stick has DPAD and we have two axes spare to use
Joystick/gamepad parsed and configured successfully (joy_index is 4)
Endpoint descriptor: EndpointAddress=133, (on TnterfaceNumber=4)
Endpoint descriptor: We think this is a joystick (got HID report descriptor and it looks good), so set up
Set up: Fill up joystick info
Set up: Manufacturer: 
Set up: Product: Xbox 360 Wireless Receiver for Windows
Set up: Serial: FD8EAC00
Set up: Constructed DeviceFS path for stick id 4, path is: devices#interface=4;endpoint=5;nopad;noblock:USB5
Set up: Open a connection to the joystick (id is 4)
Endpoint descriptor: EndpointAddress=5, (on TnterfaceNumber=4)
Endpoint descriptor: We think this isn't a joystick - ignore this endpoint
Interface descriptor: InterfaceNumber=5, InterfaceClass=255 (3 is HID), iInterface=0, csInterfaceClass=0xff5d82
Other descriptor: type is 34 - not Device/Config/Interface/Endpoint (csDeviceClass is 0xffffff, csInterfaceClass is 0xff5d82)
Will check interface class
Interface class looks like an XBOX360 controller, using baked-in HID report descriptor
usb_hid_set_output_report: reqtype 33, req 9, value 512, index 5, length 3
Unable to switch off XBOX360 LEDs: Bad request
Will use joystick number 5 (next available) for this HID parse
Shared report descriptor 'rd' (size=166) with libusbhid
Got hid report size/dlen 20 for reportid 0, offset is 0
Starting parse of HID report descriptor
HID parser:   got dpad up
HID parser:   got got dpad up, copying
HID parser:   got dpad down
HID parser:   got got dpad down, copying
HID parser:   got dpad left
HID parser:   got got dpad left, copying
HID parser:   got dpad right
HID parser:   got got dpad right, copying
HID parser:   got button
HID parser:   got button, setting up button 7
HID parser:   got button
HID parser:   got button, setting up button 6
HID parser:   got button
HID parser:   got button, setting up button 8
HID parser:   got button
HID parser:   got button, setting up button 9
HID parser:   got button
HID parser:   got button, setting up button 4
HID parser:   got button
HID parser:   got button, setting up button 5
HID parser:   got button
HID parser:   got button, setting up button 10
HID parser:   ignoring item
HID parser:   got button
HID parser:   got button, setting up button 0
HID parser:   got button
HID parser:   got button, setting up button 1
HID parser:   got button
HID parser:   got button, setting up button 2
HID parser:   got button
HID parser:   got button, setting up button 3
HID parser:   got supported axis, usage is 0x32, type is 7
HID parser:   copying axis HID item to index 0
HID parser:   got supported axis, usage is 0x35, type is 10
HID parser:   copying axis HID item to index 1
HID parser:   got supported axis, usage is 0x30, type is 5
HID parser:   copying axis HID item to index 2
HID parser:   got supported axis, usage is 0x31, type is 6
HID parser:   copying axis HID item to index 3
HID parser:   got supported axis, usage is 0x33, type is 8
HID parser:   copying axis HID item to index 4
HID parser:   got supported axis, usage is 0x34, type is 9
HID parser:   copying axis HID item to index 5
HID parser:   ignoring item
Parse completed - freeing libusbhid report descriptor memory
Analysing parse output to build axes info
Axis 0, item_usage is 50, type is 7, name is Z
Axis 1, item_usage is 53, type is 10, name is RZ
Axis 2, item_usage is 48, type is 5, name is X
Axis 3, item_usage is 49, type is 6, name is Y
Axis 4, item_usage is 51, type is 8, name is RX
Axis 5, item_usage is 52, type is 9, name is RY
Stick has DPAD and we have two axes spare to use
Joystick/gamepad parsed and configured successfully (joy_index is 5)
Endpoint descriptor: EndpointAddress=134, (on TnterfaceNumber=5)
Endpoint descriptor: We think this is a joystick (got HID report descriptor and it looks good), so set up
Set up: Fill up joystick info
error getting usb lang 1033 string: Bad request
Set up: Manufacturer: 
Set up: Product: Xbox 360 Wireless Receiver for Windows
Set up: Serial: FD8EAC00
Set up: Constructed DeviceFS path for stick id 5, path is: devices#interface=5;endpoint=6;nopad;noblock:USB5
Set up: Open a connection to the joystick (id is 5)
Endpoint descriptor: EndpointAddress=6, (on TnterfaceNumber=5)
Endpoint descriptor: We think this isn't a joystick - ignore this endpoint
Interface descriptor: InterfaceNumber=6, InterfaceClass=255 (3 is HID), iInterface=0, csInterfaceClass=0xff5d81
Other descriptor: type is 34 - not Device/Config/Interface/Endpoint (csDeviceClass is 0xffffff, csInterfaceClass is 0xff5d81)
Will check interface class
Interface class looks like an XBOX360 controller, using baked-in HID report descriptor
usb_hid_set_output_report: reqtype 33, req 9, value 512, index 6, length 3
Unable to switch off XBOX360 LEDs: Bad request
Will use joystick number 6 (next available) for this HID parse
Shared report descriptor 'rd' (size=166) with libusbhid
Got hid report size/dlen 20 for reportid 0, offset is 0
Starting parse of HID report descriptor
HID parser:   got dpad up
HID parser:   got got dpad up, copying
HID parser:   got dpad down
HID parser:   got got dpad down, copying
HID parser:   got dpad left
HID parser:   got got dpad left, copying
HID parser:   got dpad right
HID parser:   got got dpad right, copying
HID parser:   got button
HID parser:   got button, setting up button 7
HID parser:   got button
HID parser:   got button, setting up button 6
HID parser:   got button
HID parser:   got button, setting up button 8
HID parser:   got button
HID parser:   got button, setting up button 9
HID parser:   got button
HID parser:   got button, setting up button 4
HID parser:   got button
HID parser:   got button, setting up button 5
HID parser:   got button
HID parser:   got button, setting up button 10
HID parser:   ignoring item
HID parser:   got button
HID parser:   got button, setting up button 0
HID parser:   got button
HID parser:   got button, setting up button 1
HID parser:   got button
HID parser:   got button, setting up button 2
HID parser:   got button
HID parser:   got button, setting up button 3
HID parser:   got supported axis, usage is 0x32, type is 7
HID parser:   copying axis HID item to index 0
HID parser:   got supported axis, usage is 0x35, type is 10
HID parser:   copying axis HID item to index 1
HID parser:   got supported axis, usage is 0x30, type is 5
HID parser:   copying axis HID item to index 2
HID parser:   got supported axis, usage is 0x31, type is 6
HID parser:   copying axis HID item to index 3
HID parser:   got supported axis, usage is 0x33, type is 8
HID parser:   copying axis HID item to index 4
HID parser:   got supported axis, usage is 0x34, type is 9
HID parser:   copying axis HID item to index 5
HID parser:   ignoring item
Parse completed - freeing libusbhid report descriptor memory
Analysing parse output to build axes info
Axis 0, item_usage is 50, type is 7, name is Z
Axis 1, item_usage is 53, type is 10, name is RZ
Axis 2, item_usage is 48, type is 5, name is X
Axis 3, item_usage is 49, type is 6, name is Y
Axis 4, item_usage is 51, type is 8, name is RX
Axis 5, item_usage is 52, type is 9, name is RY
Stick has DPAD and we have two axes spare to use
Joystick/gamepad parsed and configured successfully (joy_index is 6)
Endpoint descriptor: EndpointAddress=135, (on TnterfaceNumber=6)
Endpoint descriptor: We think this is a joystick (got HID report descriptor and it looks good), so set up
Set up: Fill up joystick info
Set up: Manufacturer: 
Set up: Product: Xbox 360 Wireless Receiver for Windows
error getting usb string language: Bad request
Set up: Serial: 
Set up: Constructed DeviceFS path for stick id 6, path is: devices#interface=6;endpoint=7;nopad;noblock:USB5
Set up: Open a connection to the joystick (id is 6)
Endpoint descriptor: EndpointAddress=7, (on TnterfaceNumber=6)
Endpoint descriptor: We think this isn't a joystick - ignore this endpoint
Interface descriptor: InterfaceNumber=7, InterfaceClass=255 (3 is HID), iInterface=0, csInterfaceClass=0xff5d82
Other descriptor: type is 34 - not Device/Config/Interface/Endpoint (csDeviceClass is 0xffffff, csInterfaceClass is 0xff5d82)
Will check interface class
Interface class looks like an XBOX360 controller, using baked-in HID report descriptor
usb_hid_set_output_report: reqtype 33, req 9, value 512, index 7, length 3
Unable to switch off XBOX360 LEDs: Bad request
Will use joystick number 7 (next available) for this HID parse
Shared report descriptor 'rd' (size=166) with libusbhid
Got hid report size/dlen 20 for reportid 0, offset is 0
Starting parse of HID report descriptor
HID parser:   got dpad up
HID parser:   got got dpad up, copying
HID parser:   got dpad down
HID parser:   got got dpad down, copying
HID parser:   got dpad left
HID parser:   got got dpad left, copying
HID parser:   got dpad right
HID parser:   got got dpad right, copying
HID parser:   got button
HID parser:   got button, setting up button 7
HID parser:   got button
HID parser:   got button, setting up button 6
HID parser:   got button
HID parser:   got button, setting up button 8
HID parser:   got button
HID parser:   got button, setting up button 9
HID parser:   got button
HID parser:   got button, setting up button 4
HID parser:   got button
HID parser:   got button, setting up button 5
HID parser:   got button
HID parser:   got button, setting up button 10
HID parser:   ignoring item
HID parser:   got button
HID parser:   got button, setting up button 0
HID parser:   got button
HID parser:   got button, setting up button 1
HID parser:   got button
HID parser:   got button, setting up button 2
HID parser:   got button
HID parser:   got button, setting up button 3
HID parser:   got supported axis, usage is 0x32, type is 7
HID parser:   copying axis HID item to index 0
HID parser:   got supported axis, usage is 0x35, type is 10
HID parser:   copying axis HID item to index 1
HID parser:   got supported axis, usage is 0x30, type is 5
HID parser:   copying axis HID item to index 2
HID parser:   got supported axis, usage is 0x31, type is 6
HID parser:   copying axis HID item to index 3
HID parser:   got supported axis, usage is 0x33, type is 8
HID parser:   copying axis HID item to index 4
HID parser:   got supported axis, usage is 0x34, type is 9
HID parser:   copying axis HID item to index 5
HID parser:   ignoring item
Parse completed - freeing libusbhid report descriptor memory
Analysing parse output to build axes info
Axis 0, item_usage is 50, type is 7, name is Z
Axis 1, item_usage is 53, type is 10, name is RZ
Axis 2, item_usage is 48, type is 5, name is X
Axis 3, item_usage is 49, type is 6, name is Y
Axis 4, item_usage is 51, type is 8, name is RX
Axis 5, item_usage is 52, type is 9, name is RY
Stick has DPAD and we have two axes spare to use
Joystick/gamepad parsed and configured successfully (joy_index is 7)
Endpoint descriptor: EndpointAddress=136, (on TnterfaceNumber=7)
Endpoint descriptor: We think this is a joystick (got HID report descriptor and it looks good), so set up
Set up: Fill up joystick info
Set up: Manufacturer: 
Set up: Product: Xbox 360 Wireless Receiver for Windows
Set up: Serial: FD8EAC00
Set up: Constructed DeviceFS path for stick id 7, path is: devices#interface=7;endpoint=8;nopad;noblock:USB5
Set up: Open a connection to the joystick (id is 7)
Endpoint descriptor: EndpointAddress=8, (on TnterfaceNumber=7)
Endpoint descriptor: We think this isn't a joystick - ignore this endpoint
I've also retested checking Joysticks 0 thru 7 and its appearing on Joystick 1. Behaviour is as before, where the triggers are working, some buttons and thumb sticks aren't. Thumb stick buttons work correctly, as do Back and Start, pressing other buttons does result in a change, but its -128 on the X axis - not a button.
The Dpad is returning as the first four buttons.

So its mostly working, the non-working controls and appearing as Joystick 1 are probably just mapping issues.

EDIT: Had my parameters round the wrong way. It's appearing as Joystick 0, but only returns data if you request 16 bit data. The 8 bit Joystick interface doesn't appear to work.

JonAbbott
Posts: 2257
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: USB Joystick driver

Post by JonAbbott » Fri Oct 05, 2018 12:56 pm

Saloon Cars supports a steering wheel plugged into an Acorn I/O Podule, its very specific to the game and not used in any other game to my knowledge.

I'm tempted to add support for it, either via a shim Module (translating OS_Byte 16, 17, 128, 188, 189, 190) or with ADFFS by translation to the the memory range in the same way RTFM support is covered. I need to look at the game to see which method it's using.

Here's the circuit diagram:
Wiring diagram.png
Wiring diagram.png (16.17 KiB) Viewed 2825 times

richw
Posts: 137
Joined: Sat Sep 14, 2013 9:05 pm

Re: USB Joystick driver

Post by richw » Fri Oct 05, 2018 9:03 pm

How's that for bad timing? I've just uploaded 0.09 (some internal re-working, no sudden support for the 360 wireless!). I have tried to put some more useful stuff in the Reporter debug output, and less of the less useful stuff. Hopefully it should at least spot that your controller is a wireless one, and therefore unsupported.

I have had to change the stick HID data processing: a chunk is effectively on the received data interrupt now, rather than being done on-demand.

Your xbox controller sounds as though the buttons/axes are not mapped correctly. I wonder if your wireless variant uses a totally different data format to my wired one? Can you have another look at the output of Reporter with 0.09 and the USBJoystick_Debug command? It may shed some light. Things might have improved anyway, as I'm properly ignoring data which appears for a different report_id, so that might have been messing things up.

Saloon Cars... ahh... takes me back. I bought that when I was about ten, and all I wanted was to construct that controller setup, as described in the manual! I never had an I/O podule, though. I did have I/O podule emulation on my todo list (see post 1) so it should be possible. You could shim it as is, but you've only got the X and Y axis - I need to allow more to be mapped, since it looks like they are using four separate axes.

Maybe some new commands to map-up to the ADC channels, and perhaps some commands to play around with the range/sensitivity (just like changing those resistors on the pic above!).

JonAbbott
Posts: 2257
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: USB Joystick driver

Post by JonAbbott » Fri Oct 05, 2018 9:59 pm

I've done some more testing comparing Read_Joystick 0 and 1. It looks like the Module is mixing both. 8bit doesn't return anything, but 16bit is returning 8bit values.

So, I think the USB side is working okay, but there's an issue in the 8/16bit implementation of Joystick_Read.

Here's my test code:

Code: Select all

J%=0:read16%=1
Z%=0:Z2%=0
REPEAT
SYS "Joystick_Read",J%+(read16%<<8) TO A%,B%
IF A%<>Z% OR B%<>Z2% THEN
  IF read16%>0 THEN
    Y%=(A% AND &FFFF)-&8000
    X%=((A%>>16) AND &FFFF)-&8000
    PRINT "Joystick ";J%;": X=";X%, "Y=";Y%, "Buttons: ";
    FOR L%=7 TO 0 STEP -1:PRINT;(B%>>L%) AND 1;:NEXT
    PRINT:Z%=A%:Z2%=B%
  ELSE
    Y%=(((A% AND &80)*-1) + (A% AND &7F))
    X%=((((A%>>>8) AND &80)*-1) + ((A%>>>8) AND &7F))
    PRINT "Joystick ";J%;": X=";X%, "Y=";Y%, "Buttons: ";
    FOR L%=23 TO 16 STEP -1:PRINT;(A%>>L%) AND 1;:NEXT
    PRINT:Z%=A%
  ENDIF
ENDIF
UNTIL0


Reporter output with XB360 controller:

Code: Select all

usb_get_device_string descriptor: StringSize is 0, getting string: device='USB5' wValue=0x303, wIndex=4, wLength=0
error getting usb string: Bad request
Set up: Serial: 
Set up: Constructed DeviceFS path for stick id 3, path is: devices#interface=3;endpoint=4;nopad;noblock:USB5
Set up: Open a connection to the joystick (id is 3)
Endpoint descriptor: EndpointAddress=4, (on TnterfaceNumber=3)
Endpoint descriptor: We think this isn't a joystick - ignore this endpoint
Interface descriptor: InterfaceNumber=4, InterfaceClass=255 (3 is HID), iInterface=0, csInterfaceClass=0xff5d81
Other descriptor: type is 34 - not Device/Config/Interface/Endpoint (csDeviceClass is 0xffffff, csInterfaceClass is 0xff5d81)
Will check interface class+subclass (ignoring protocol)
Interface class looks like an XBOX360 controller, using baked-in HID report descriptor (interface protocol is 0x81)
Protocol suggests this is a wireless XBOX360 controller - not yet supported!
usb_hid_set_output_report: dev='USB5' wValue=512, wIndex=4, wLength=3
Unable to switch off XBOX360 LEDs: Bad request
Will use joystick number 4 (next available) for this HID parse
Shared report descriptor 'rd' (size=166) with libusbhid
Got hid report size/dlen 20 for reportid 0, offset is 0
Starting parse of HID report descriptor
HID parser:   reportid=0, got dpad up, copying
HID parser:   reportid=0, got dpad down, copying
HID parser:   reportid=0, got dpad left, copying
HID parser:   reportid=0, got dpad right, copying
HID parser:   reportid=0, got button, setting up button 7
HID parser:   reportid=0, got button, setting up button 6
HID parser:   reportid=0, got button, setting up button 8
HID parser:   reportid=0, got button, setting up button 9
HID parser:   reportid=0, got button, setting up button 4
HID parser:   reportid=0, got button, setting up button 5
HID parser:   reportid=0, got button, setting up button 10
HID parser:   reportid=0, ignoring item
HID parser:   reportid=0, got button, setting up button 0
HID parser:   reportid=0, got button, setting up button 1
HID parser:   reportid=0, got button, setting up button 2
HID parser:   reportid=0, got button, setting up button 3
HID parser:   reportid=0, got supported axis, usage is 0x32, type is 7
HID parser:   copying axis HID item to index 0
HID parser:   reportid=0, got supported axis, usage is 0x35, type is 10
HID parser:   copying axis HID item to index 1
HID parser:   reportid=0, got supported axis, usage is 0x30, type is 5
HID parser:   copying axis HID item to index 2
HID parser:   reportid=0, got supported axis, usage is 0x31, type is 6
HID parser:   copying axis HID item to index 3
HID parser:   reportid=0, got supported axis, usage is 0x33, type is 8
HID parser:   copying axis HID item to index 4
HID parser:   reportid=0, got supported axis, usage is 0x34, type is 9
HID parser:   copying axis HID item to index 5
HID parser:   reportid=0, ignoring item
Parse completed - freeing libusbhid report descriptor memory
Analysing parse output to build axes info
Axis 0, item_usage is 50, type is 7, name is Z
Axis 1, item_usage is 53, type is 10, name is RZ
Axis 2, item_usage is 48, type is 5, name is X
Axis 3, item_usage is 49, type is 6, name is Y
Axis 4, item_usage is 51, type is 8, name is RX
Axis 5, item_usage is 52, type is 9, name is RY
Stick has DPAD and we have two axes spare to use
Joystick/gamepad parsed and configured successfully (joy_index is 4)
Endpoint descriptor: EndpointAddress=133, (on TnterfaceNumber=4)
Endpoint descriptor: We think this is a joystick (got HID report descriptor and it looks good), so set up
Set up: Fill up joystick info
usb_get_device_string_descriptor: device='USB5', string index=1
usb_get_device_string descriptor: Getting language: device='USB5' wValue=0x300, wIndex=0, wLength=256
usb_get_device_string descriptor: Language is 4, getting size: device='USB5' wValue=0x301, wIndex=4, wLength=2
error getting usb string size: Bad request
usb_get_device_string descriptor: StringSize is 0, getting string: device='USB5' wValue=0x301, wIndex=4, wLength=0
error getting usb string: Bad request
Set up: Manufacturer: 
usb_get_device_string_descriptor: device='USB5', string index=2
usb_get_device_string descriptor: Getting language: device='USB5' wValue=0x300, wIndex=0, wLength=256
error getting usb string language: Bad request
usb_get_device_string descriptor: Language is 147, getting size: device='USB5' wValue=0x302, wIndex=147, wLength=2
error getting usb string size: Bad request
usb_get_device_string descriptor: StringSize is 0, getting string: device='USB5' wValue=0x302, wIndex=147, wLength=0
error getting usb string: Bad request
Set up: Product: 
usb_get_device_string_descriptor: device='USB5', string index=3
usb_get_device_string descriptor: Getting language: device='USB5' wValue=0x300, wIndex=0, wLength=256
usb_get_device_string descriptor: Language is 4, getting size: device='USB5' wValue=0x303, wIndex=4, wLength=2
error getting usb string size: Bad request
usb_get_device_string descriptor: StringSize is 0, getting string: device='USB5' wValue=0x303, wIndex=4, wLength=0
error getting usb string: Bad request
Set up: Serial: 
Set up: Constructed DeviceFS path for stick id 4, path is: devices#interface=4;endpoint=5;nopad;noblock:USB5
Set up: Open a connection to the joystick (id is 4)
Endpoint descriptor: EndpointAddress=5, (on TnterfaceNumber=4)
Endpoint descriptor: We think this isn't a joystick - ignore this endpoint
Interface descriptor: InterfaceNumber=5, InterfaceClass=255 (3 is HID), iInterface=0, csInterfaceClass=0xff5d82
Other descriptor: type is 34 - not Device/Config/Interface/Endpoint (csDeviceClass is 0xffffff, csInterfaceClass is 0xff5d82)
Will check interface class+subclass (ignoring protocol)
Interface class looks like an XBOX360 controller, using baked-in HID report descriptor (interface protocol is 0x82)
Protocol not supported - what is this?!
usb_hid_set_output_report: dev='USB5' wValue=512, wIndex=5, wLength=3
Unable to switch off XBOX360 LEDs: Bad request
Will use joystick number 5 (next available) for this HID parse
Shared report descriptor 'rd' (size=166) with libusbhid
Got hid report size/dlen 20 for reportid 0, offset is 0
Starting parse of HID report descriptor
HID parser:   reportid=0, got dpad up, copying
HID parser:   reportid=0, got dpad down, copying
HID parser:   reportid=0, got dpad left, copying
HID parser:   reportid=0, got dpad right, copying
HID parser:   reportid=0, got button, setting up button 7
HID parser:   reportid=0, got button, setting up button 6
HID parser:   reportid=0, got button, setting up button 8
HID parser:   reportid=0, got button, setting up button 9
HID parser:   reportid=0, got button, setting up button 4
HID parser:   reportid=0, got button, setting up button 5
HID parser:   reportid=0, got button, setting up button 10
HID parser:   reportid=0, ignoring item
HID parser:   reportid=0, got button, setting up button 0
HID parser:   reportid=0, got button, setting up button 1
HID parser:   reportid=0, got button, setting up button 2
HID parser:   reportid=0, got button, setting up button 3
HID parser:   reportid=0, got supported axis, usage is 0x32, type is 7
HID parser:   copying axis HID item to index 0
HID parser:   reportid=0, got supported axis, usage is 0x35, type is 10
HID parser:   copying axis HID item to index 1
HID parser:   reportid=0, got supported axis, usage is 0x30, type is 5
HID parser:   copying axis HID item to index 2
HID parser:   reportid=0, got supported axis, usage is 0x31, type is 6
HID parser:   copying axis HID item to index 3
HID parser:   reportid=0, got supported axis, usage is 0x33, type is 8
HID parser:   copying axis HID item to index 4
HID parser:   reportid=0, got supported axis, usage is 0x34, type is 9
HID parser:   copying axis HID item to index 5
HID parser:   reportid=0, ignoring item
Parse completed - freeing libusbhid report descriptor memory
Analysing parse output to build axes info
Axis 0, item_usage is 50, type is 7, name is Z
Axis 1, item_usage is 53, type is 10, name is RZ
Axis 2, item_usage is 48, type is 5, name is X
Axis 3, item_usage is 49, type is 6, name is Y
Axis 4, item_usage is 51, type is 8, name is RX
Axis 5, item_usage is 52, type is 9, name is RY
Stick has DPAD and we have two axes spare to use
Joystick/gamepad parsed and configured successfully (joy_index is 5)
Endpoint descriptor: EndpointAddress=134, (on TnterfaceNumber=5)
Endpoint descriptor: We think this is a joystick (got HID report descriptor and it looks good), so set up
Set up: Fill up joystick info
usb_get_device_string_descriptor: device='USB5', string index=1
usb_get_device_string descriptor: Getting language: device='USB5' wValue=0x300, wIndex=0, wLength=256
usb_get_device_string descriptor: Language is 4, getting size: device='USB5' wValue=0x301, wIndex=4, wLength=2
error getting usb string size: Bad request
usb_get_device_string descriptor: StringSize is 0, getting string: device='USB5' wValue=0x301, wIndex=4, wLength=0
error getting usb string: Bad request
Set up: Manufacturer: 
usb_get_device_string_descriptor: device='USB5', string index=2
usb_get_device_string descriptor: Getting language: device='USB5' wValue=0x300, wIndex=0, wLength=256
usb_get_device_string descriptor: Language is 4, getting size: device='USB5' wValue=0x302, wIndex=4, wLength=2
error getting usb string size: Bad request
usb_get_device_string descriptor: StringSize is 0, getting string: device='USB5' wValue=0x302, wIndex=4, wLength=0
error getting usb string: Bad request
Set up: Product: 
usb_get_device_string_descriptor: device='USB5', string index=3
usb_get_device_string descriptor: Getting language: device='USB5' wValue=0x300, wIndex=0, wLength=256
usb_get_device_string descriptor: Language is 4, getting size: device='USB5' wValue=0x303, wIndex=4, wLength=2
error getting usb string size: Bad request
usb_get_device_string descriptor: StringSize is 0, getting string: device='USB5' wValue=0x303, wIndex=4, wLength=0
error getting usb string: Bad request
Set up: Serial: 
Set up: Constructed DeviceFS path for stick id 5, path is: devices#interface=5;endpoint=6;nopad;noblock:USB5
Set up: Open a connection to the joystick (id is 5)
Endpoint descriptor: EndpointAddress=6, (on TnterfaceNumber=5)
Endpoint descriptor: We think this isn't a joystick - ignore this endpoint
Interface descriptor: InterfaceNumber=6, InterfaceClass=255 (3 is HID), iInterface=0, csInterfaceClass=0xff5d81
Other descriptor: type is 34 - not Device/Config/Interface/Endpoint (csDeviceClass is 0xffffff, csInterfaceClass is 0xff5d81)
Will check interface class+subclass (ignoring protocol)
Interface class looks like an XBOX360 controller, using baked-in HID report descriptor (interface protocol is 0x81)
Protocol suggests this is a wireless XBOX360 controller - not yet supported!
usb_hid_set_output_report: dev='USB5' wValue=512, wIndex=6, wLength=3
Unable to switch off XBOX360 LEDs: Bad request
Will use joystick number 6 (next available) for this HID parse
Shared report descriptor 'rd' (size=166) with libusbhid
Got hid report size/dlen 20 for reportid 0, offset is 0
Starting parse of HID report descriptor
HID parser:   reportid=0, got dpad up, copying
HID parser:   reportid=0, got dpad down, copying
HID parser:   reportid=0, got dpad left, copying
HID parser:   reportid=0, got dpad right, copying
HID parser:   reportid=0, got button, setting up button 7
HID parser:   reportid=0, got button, setting up button 6
HID parser:   reportid=0, got button, setting up button 8
HID parser:   reportid=0, got button, setting up button 9
HID parser:   reportid=0, got button, setting up button 4
HID parser:   reportid=0, got button, setting up button 5
HID parser:   reportid=0, got button, setting up button 10
HID parser:   reportid=0, ignoring item
HID parser:   reportid=0, got button, setting up button 0
HID parser:   reportid=0, got button, setting up button 1
HID parser:   reportid=0, got button, setting up button 2
HID parser:   reportid=0, got button, setting up button 3
HID parser:   reportid=0, got supported axis, usage is 0x32, type is 7
HID parser:   copying axis HID item to index 0
HID parser:   reportid=0, got supported axis, usage is 0x35, type is 10
HID parser:   copying axis HID item to index 1
HID parser:   reportid=0, got supported axis, usage is 0x30, type is 5
HID parser:   copying axis HID item to index 2
HID parser:   reportid=0, got supported axis, usage is 0x31, type is 6
HID parser:   copying axis HID item to index 3
HID parser:   reportid=0, got supported axis, usage is 0x33, type is 8
HID parser:   copying axis HID item to index 4
HID parser:   reportid=0, got supported axis, usage is 0x34, type is 9
HID parser:   copying axis HID item to index 5
HID parser:   reportid=0, ignoring item
Parse completed - freeing libusbhid report descriptor memory
Analysing parse output to build axes info
Axis 0, item_usage is 50, type is 7, name is Z
Axis 1, item_usage is 53, type is 10, name is RZ
Axis 2, item_usage is 48, type is 5, name is X
Axis 3, item_usage is 49, type is 6, name is Y
Axis 4, item_usage is 51, type is 8, name is RX
Axis 5, item_usage is 52, type is 9, name is RY
Stick has DPAD and we have two axes spare to use
Joystick/gamepad parsed and configured successfully (joy_index is 6)
Endpoint descriptor: EndpointAddress=135, (on TnterfaceNumber=6)
Endpoint descriptor: We think this is a joystick (got HID report descriptor and it looks good), so set up
Set up: Fill up joystick info
usb_get_device_string_descriptor: device='USB5', string index=1
usb_get_device_string descriptor: Getting language: device='USB5' wValue=0x300, wIndex=0, wLength=256
error getting usb string language: Bad request
usb_get_device_string descriptor: Language is 112, getting size: device='USB5' wValue=0x301, wIndex=112, wLength=2
error getting usb string size: Bad request
usb_get_device_string descriptor: StringSize is 0, getting string: device='USB5' wValue=0x301, wIndex=112, wLength=0
error getting usb string: Bad request
Set up: Manufacturer: 
usb_get_device_string_descriptor: device='USB5', string index=2
usb_get_device_string descriptor: Getting language: device='USB5' wValue=0x300, wIndex=0, wLength=256
usb_get_device_string descriptor: Language is 4, getting size: device='USB5' wValue=0x302, wIndex=4, wLength=2
error getting usb string size: Bad request
usb_get_device_string descriptor: StringSize is 0, getting string: device='USB5' wValue=0x302, wIndex=4, wLength=0
error getting usb string: Bad request
Set up: Product: 
usb_get_device_string_descriptor: device='USB5', string index=3
usb_get_device_string descriptor: Getting language: device='USB5' wValue=0x300, wIndex=0, wLength=256
usb_get_device_string descriptor: Language is 4, getting size: device='USB5' wValue=0x303, wIndex=4, wLength=2
error getting usb string size: Bad request
usb_get_device_string descriptor: StringSize is 0, getting string: device='USB5' wValue=0x303, wIndex=4, wLength=0
error getting usb string: Bad request
Set up: Serial: 
Set up: Constructed DeviceFS path for stick id 6, path is: devices#interface=6;endpoint=7;nopad;noblock:USB5
Set up: Open a connection to the joystick (id is 6)
Endpoint descriptor: EndpointAddress=7, (on TnterfaceNumber=6)
Endpoint descriptor: We think this isn't a joystick - ignore this endpoint
Interface descriptor: InterfaceNumber=7, InterfaceClass=255 (3 is HID), iInterface=0, csInterfaceClass=0xff5d82
Other descriptor: type is 34 - not Device/Config/Interface/Endpoint (csDeviceClass is 0xffffff, csInterfaceClass is 0xff5d82)
Will check interface class+subclass (ignoring protocol)
Interface class looks like an XBOX360 controller, using baked-in HID report descriptor (interface protocol is 0x82)
Protocol not supported - what is this?!
usb_hid_set_output_report: dev='USB5' wValue=512, wIndex=7, wLength=3
Unable to switch off XBOX360 LEDs: Bad request
Will use joystick number 7 (next available) for this HID parse
Shared report descriptor 'rd' (size=166) with libusbhid
Got hid report size/dlen 20 for reportid 0, offset is 0
Starting parse of HID report descriptor
HID parser:   reportid=0, got dpad up, copying
HID parser:   reportid=0, got dpad down, copying
HID parser:   reportid=0, got dpad left, copying
HID parser:   reportid=0, got dpad right, copying
HID parser:   reportid=0, got button, setting up button 7
HID parser:   reportid=0, got button, setting up button 6
HID parser:   reportid=0, got button, setting up button 8
HID parser:   reportid=0, got button, setting up button 9
HID parser:   reportid=0, got button, setting up button 4
HID parser:   reportid=0, got button, setting up button 5
HID parser:   reportid=0, got button, setting up button 10
HID parser:   reportid=0, ignoring item
HID parser:   reportid=0, got button, setting up button 0
HID parser:   reportid=0, got button, setting up button 1
HID parser:   reportid=0, got button, setting up button 2
HID parser:   reportid=0, got button, setting up button 3
HID parser:   reportid=0, got supported axis, usage is 0x32, type is 7
HID parser:   copying axis HID item to index 0
HID parser:   reportid=0, got supported axis, usage is 0x35, type is 10
HID parser:   copying axis HID item to index 1
HID parser:   reportid=0, got supported axis, usage is 0x30, type is 5
HID parser:   copying axis HID item to index 2
HID parser:   reportid=0, got supported axis, usage is 0x31, type is 6
HID parser:   copying axis HID item to index 3
HID parser:   reportid=0, got supported axis, usage is 0x33, type is 8
HID parser:   copying axis HID item to index 4
HID parser:   reportid=0, got supported axis, usage is 0x34, type is 9
HID parser:   copying axis HID item to index 5
HID parser:   reportid=0, ignoring item
Parse completed - freeing libusbhid report descriptor memory
Analysing parse output to build axes info
Axis 0, item_usage is 50, type is 7, name is Z
Axis 1, item_usage is 53, type is 10, name is RZ
Axis 2, item_usage is 48, type is 5, name is X
Axis 3, item_usage is 49, type is 6, name is Y
Axis 4, item_usage is 51, type is 8, name is RX
Axis 5, item_usage is 52, type is 9, name is RY
Stick has DPAD and we have two axes spare to use
Joystick/gamepad parsed and configured successfully (joy_index is 7)
Endpoint descriptor: EndpointAddress=136, (on TnterfaceNumber=7)
Endpoint descriptor: We think this is a joystick (got HID report descriptor and it looks good), so set up
Set up: Fill up joystick info
usb_get_device_string_descriptor: device='USB5', string index=1
usb_get_device_string descriptor: Getting language: device='USB5' wValue=0x300, wIndex=0, wLength=256
usb_get_device_string descriptor: Language is 4, getting size: device='USB5' wValue=0x301, wIndex=4, wLength=2
error getting usb string size: Bad request
usb_get_device_string descriptor: StringSize is 0, getting string: device='USB5' wValue=0x301, wIndex=4, wLength=0
error getting usb string: Bad request
Set up: Manufacturer: 
usb_get_device_string_descriptor: device='USB5', string index=2
usb_get_device_string descriptor: Getting language: device='USB5' wValue=0x300, wIndex=0, wLength=256
usb_get_device_string descriptor: Language is 4, getting size: device='USB5' wValue=0x302, wIndex=4, wLength=2
error getting usb string size: Bad request
usb_get_device_string descriptor: StringSize is 0, getting string: device='USB5' wValue=0x302, wIndex=4, wLength=0
error getting usb string: Bad request
Set up: Product: 
usb_get_device_string_descriptor: device='USB5', string index=3
usb_get_device_string descriptor: Getting language: device='USB5' wValue=0x300, wIndex=0, wLength=256
usb_get_device_string descriptor: Language is 4, getting size: device='USB5' wValue=0x303, wIndex=4, wLength=2
error getting usb string size: Bad request
usb_get_device_string descriptor: StringSize is 0, getting string: device='USB5' wValue=0x303, wIndex=4, wLength=0
error getting usb string: Bad request
Set up: Serial: 
Set up: Constructed DeviceFS path for stick id 7, path is: devices#interface=7;endpoint=8;nopad;noblock:USB5
Set up: Open a connection to the joystick (id is 7)
Endpoint descriptor: EndpointAddress=8, (on TnterfaceNumber=7)
Endpoint descriptor: We think this isn't a joystick - ignore this endpoint
Joystick_Debug output:

Code: Select all

Joystick id 0
  Path                    : devices#interface=0;endpoint=1;nopad;noblock:USB5
  File handle             : 252
  Data stream open        : Yes
  Local USB device name   : USB5
  Interface               : 0
  Endpoint                : 1
  Device manufacturer     : 
  Device product name     : 
  Device serial number    : 
  USB vendor id           : 0x045e
  USB product id          : 0x0719
  USB device id           : 0x0100
  Buffer handle           : 260
  Buffer internal id      : 308
  Buffer service routine  : 0xfc1d0770
  Buffer workspace        : 0x20003eb4
  DeviceFS handle         : 0x2024f474
  Data length             : 20
  Data offset             : 0
  Upcalls                 : 0 (delta: 0)
  Good reads              : 0 (delta: 0)
  Bad reads               : 0 (delta: 0)
  Raw data                : 20 00 00 00 ff ff ff ff 4c 39 e0 43 4c 39 e0 43 00 00 00 20
  Number of axes          : 8
  Number of buttons       : 11
  HAT switch              : No
  DPAD                    : Yes
  Axes:
  Axis 00 (    Z) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off 
  Axis 01 (   RZ) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off 
  Axis 02 (    X) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 03 (    Y) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = on
  Axis 04 (   RX) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 05 (   RY) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 06 (DPADX) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off
  Axis 07 (DPADY) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off 
  HID items:
  Axis 00   : ReportId=0
  Axis 01   : ReportId=0
  Axis 02   : ReportId=0
  Axis 03   : ReportId=0
  Axis 04   : ReportId=0
  Axis 05   : ReportId=0
  Axis 16   : ReportId=0
  Axis 17   : ReportId=0
  Axis 18   : ReportId=0
  Axis 19   : ReportId=0
  DPAD up   : ReportId=0
  DPAD down : ReportId=0
  DPAD left : ReportId=0
  DPAD right: ReportId=0
  Button 00 : ReportId=0
  Button 01 : ReportId=0
  Button 02 : ReportId=0
  Button 03 : ReportId=0
  Button 04 : ReportId=0
  Button 05 : ReportId=0
  Button 06 : ReportId=0
  Button 07 : ReportId=0
  Button 08 : ReportId=0
  Button 09 : ReportId=0
  Button 10 : ReportId=0
Joystick id 1
  Path                    : devices#interface=1;endpoint=2;nopad;noblock:USB5
  File handle             : 251
  Data stream open        : Yes
  Local USB device name   : USB5
  Interface               : 1
  Endpoint                : 2
  Device manufacturer     : 
  Device product name     : 
  Device serial number    : 
  USB vendor id           : 0x045e
  USB product id          : 0x0719
  USB device id           : 0x0100
  Buffer handle           : 261
  Buffer internal id      : 352
  Buffer service routine  : 0xfc1d0770
  Buffer workspace        : 0x20003eb4
  DeviceFS handle         : 0x20347db4
  Data length             : 20
  Data offset             : 0
  Upcalls                 : 0 (delta: 0)
  Good reads              : 0 (delta: 0)
  Bad reads               : 0 (delta: 0)
  Raw data                : 69 00 00 00 ad de ad de ad de ad de 00 00 00 00 ad de ad de 
  Number of axes          : 8
  Number of buttons       : 11
  HAT switch              : No
  DPAD                    : Yes
  Axes:
  Axis 00 (    Z) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off
  Axis 01 (   RZ) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off 
  Axis 02 (    X) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off
  Axis 03 (    Y) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = on 
  Axis 04 (   RX) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 05 (   RY) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off
  Axis 06 (DPADX) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off 
  Axis 07 (DPADY) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off 
  HID items:
  Axis 00   : ReportId=0
  Axis 01   : ReportId=0
  Axis 02   : ReportId=0
  Axis 03   : ReportId=0
  Axis 04   : ReportId=0
  Axis 05   : ReportId=0
  Axis 16   : ReportId=0
  Axis 17   : ReportId=0
  Axis 18   : ReportId=0
  Axis 19   : ReportId=0
  DPAD up   : ReportId=0
  DPAD down : ReportId=0
  DPAD left : ReportId=0
  DPAD right: ReportId=0
  Button 00 : ReportId=0
  Button 01 : ReportId=0
  Button 02 : ReportId=0
  Button 03 : ReportId=0
  Button 04 : ReportId=0
  Button 05 : ReportId=0
  Button 06 : ReportId=0
  Button 07 : ReportId=0
  Button 08 : ReportId=0
  Button 09 : ReportId=0
  Button 10 : ReportId=0
Joystick id 2
  Path                    : devices#interface=2;endpoint=3;nopad;noblock:USB5
  File handle             : 250
  Data stream open        : Yes
  Local USB device name   : USB5
  Interface               : 2
  Endpoint                : 3
  Device manufacturer     : 
  Device product name     :
  Device serial number    : 
  USB vendor id           : 0x045e
  USB product id          : 0x0719
  USB device id           : 0x0100
  Buffer handle           : 262
  Buffer internal id      : 396
  Buffer service routine  : 0xfc1d0770
  Buffer workspace        : 0x20003eb4
  DeviceFS handle         : 0x2034bad4
  Data length             : 20
  Data offset             : 0
  Upcalls                 : 0 (delta: 0)
  Good reads              : 0 (delta: 0)
  Bad reads               : 0 (delta: 0)
  Raw data                : 20 00 00 00 01 00 00 20 6c 5e 06 fc 9d 00 1d fc 00 00 00 00 
  Number of axes          : 8
  Number of buttons       : 11
  HAT switch              : No
  DPAD                    : Yes
  Axes:
  Axis 00 (    Z) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off 
  Axis 01 (   RZ) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off
  Axis 02 (    X) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 03 (    Y) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = on 
  Axis 04 (   RX) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off
  Axis 05 (   RY) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 06 (DPADX) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off 
  Axis 07 (DPADY) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off
  HID items:
  Axis 00   : ReportId=0
  Axis 01   : ReportId=0
  Axis 02   : ReportId=0
  Axis 03   : ReportId=0
  Axis 04   : ReportId=0
  Axis 05   : ReportId=0
  Axis 16   : ReportId=0
  Axis 17   : ReportId=0
  Axis 18   : ReportId=0
  Axis 19   : ReportId=0
  DPAD up   : ReportId=0
  DPAD down : ReportId=0
  DPAD left : ReportId=0
  DPAD right: ReportId=0
  Button 00 : ReportId=0
  Button 01 : ReportId=0
  Button 02 : ReportId=0
  Button 03 : ReportId=0
  Button 04 : ReportId=0
  Button 05 : ReportId=0
  Button 06 : ReportId=0
  Button 07 : ReportId=0
  Button 08 : ReportId=0
  Button 09 : ReportId=0
  Button 10 : ReportId=0
Joystick id 3
  Path                    : devices#interface=3;endpoint=4;nopad;noblock:USB5
  File handle             : 249
  Data stream open        : Yes
  Local USB device name   : USB5
  Interface               : 3
  Endpoint                : 4
  Device manufacturer     : 
  Device product name     : 
  Device serial number    : 
  USB vendor id           : 0x045e
  USB product id          : 0x0719
  USB device id           : 0x0100
  Buffer handle           : 263
  Buffer internal id      : 440
  Buffer service routine  : 0xfc1d0770
  Buffer workspace        : 0x20003eb4
  DeviceFS handle         : 0x20367234
  Data length             : 20
  Data offset             : 0
  Upcalls                 : 0 (delta: 0)
  Good reads              : 0 (delta: 0)
  Bad reads               : 0 (delta: 0)
  Raw data                : 20 00 00 00 72 66 61 de ad de ad de 00 00 00 00 ad de ad de
  Number of axes          : 8
  Number of buttons       : 11
  HAT switch              : No
  DPAD                    : Yes
  Axes:
  Axis 00 (    Z) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off
  Axis 01 (   RZ) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off 
  Axis 02 (    X) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 03 (    Y) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = on
  Axis 04 (   RX) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 05 (   RY) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 06 (DPADX) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off
  Axis 07 (DPADY) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off 
  HID items:
  Axis 00   : ReportId=0
  Axis 01   : ReportId=0
  Axis 02   : ReportId=0
  Axis 03   : ReportId=0
  Axis 04   : ReportId=0
  Axis 05   : ReportId=0
  Axis 16   : ReportId=0
  Axis 17   : ReportId=0
  Axis 18   : ReportId=0
  Axis 19   : ReportId=0
  DPAD up   : ReportId=0
  DPAD down : ReportId=0
  DPAD left : ReportId=0
  DPAD right: ReportId=0
  Button 00 : ReportId=0
  Button 01 : ReportId=0
  Button 02 : ReportId=0
  Button 03 : ReportId=0
  Button 04 : ReportId=0
  Button 05 : ReportId=0
  Button 06 : ReportId=0
  Button 07 : ReportId=0
  Button 08 : ReportId=0
  Button 09 : ReportId=0
  Button 10 : ReportId=0
Joystick id 4
  Path                    : devices#interface=4;endpoint=5;nopad;noblock:USB5
  File handle             : 248
  Data stream open        : Yes
  Local USB device name   : USB5
  Interface               : 4
  Endpoint                : 5
  Device manufacturer     : 
  Device product name     : 
  Device serial number    : 
  USB vendor id           : 0x045e
  USB product id          : 0x0719
  USB device id           : 0x0100
  Buffer handle           : 264
  Buffer internal id      : 484
  Buffer service routine  : 0xfc1d0770
  Buffer workspace        : 0x20003eb4
  DeviceFS handle         : 0x20365ef4
  Data length             : 20
  Data offset             : 0
  Upcalls                 : 0 (delta: 0)
  Good reads              : 0 (delta: 0)
  Bad reads               : 0 (delta: 0)
  Raw data                : 20 00 00 00 88 00 20 00 55 53 42 34 00 00 00 00 00 00 00 00 
  Number of axes          : 8
  Number of buttons       : 11
  HAT switch              : No
  DPAD                    : Yes
  Axes:
  Axis 00 (    Z) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off 
  Axis 01 (   RZ) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off 
  Axis 02 (    X) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off
  Axis 03 (    Y) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = on 
  Axis 04 (   RX) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 05 (   RY) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off
  Axis 06 (DPADX) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off 
  Axis 07 (DPADY) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off 
  HID items:
  Axis 00   : ReportId=0
  Axis 01   : ReportId=0
  Axis 02   : ReportId=0
  Axis 03   : ReportId=0
  Axis 04   : ReportId=0
  Axis 05   : ReportId=0
  Axis 16   : ReportId=0
  Axis 17   : ReportId=0
  Axis 18   : ReportId=0
  Axis 19   : ReportId=0
  DPAD up   : ReportId=0
  DPAD down : ReportId=0
  DPAD left : ReportId=0
  DPAD right: ReportId=0
  Button 00 : ReportId=0
  Button 01 : ReportId=0
  Button 02 : ReportId=0
  Button 03 : ReportId=0
  Button 04 : ReportId=0
  Button 05 : ReportId=0
  Button 06 : ReportId=0
  Button 07 : ReportId=0
  Button 08 : ReportId=0
  Button 09 : ReportId=0
  Button 10 : ReportId=0
Joystick id 5
  Path                    : devices#interface=5;endpoint=6;nopad;noblock:USB5
  File handle             : 245
  Data stream open        : Yes
  Local USB device name   : USB5
  Interface               : 5
  Endpoint                : 6
  Device manufacturer     :
  Device product name     : 
  Device serial number    : 
  USB vendor id           : 0x045e
  USB product id          : 0x0719
  USB device id           : 0x0100
  Buffer handle           : 265
  Buffer internal id      : 528
  Buffer service routine  : 0xfc1d0770
  Buffer workspace        : 0x20003eb4
  DeviceFS handle         : 0x20364b34
  Data length             : 20
  Data offset             : 0
  Upcalls                 : 0 (delta: 0)
  Good reads              : 0 (delta: 0)
  Bad reads               : 0 (delta: 0)
  Raw data                : 03 00 00 00 ad de ad de ad de ad de 00 00 00 00 ad de ad de 
  Number of axes          : 8
  Number of buttons       : 11
  HAT switch              : No
  DPAD                    : Yes
  Axes:
  Axis 00 (    Z) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off 
  Axis 01 (   RZ) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off
  Axis 02 (    X) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 03 (    Y) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = on 
  Axis 04 (   RX) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off
  Axis 05 (   RY) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 06 (DPADX) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off 
  Axis 07 (DPADY) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off
  HID items:
  Axis 00   : ReportId=0
  Axis 01   : ReportId=0
  Axis 02   : ReportId=0
  Axis 03   : ReportId=0
  Axis 04   : ReportId=0
  Axis 05   : ReportId=0
  Axis 16   : ReportId=0
  Axis 17   : ReportId=0
  Axis 18   : ReportId=0
  Axis 19   : ReportId=0
  DPAD up   : ReportId=0
  DPAD down : ReportId=0
  DPAD left : ReportId=0
  DPAD right: ReportId=0
  Button 00 : ReportId=0
  Button 01 : ReportId=0
  Button 02 : ReportId=0
  Button 03 : ReportId=0
  Button 04 : ReportId=0
  Button 05 : ReportId=0
  Button 06 : ReportId=0
  Button 07 : ReportId=0
  Button 08 : ReportId=0
  Button 09 : ReportId=0
  Button 10 : ReportId=0
Joystick id 6
  Path                    : devices#interface=6;endpoint=7;nopad;noblock:USB5
  File handle             : 244
  Data stream open        : Yes
  Local USB device name   : USB5
  Interface               : 6
  Endpoint                : 7
  Device manufacturer     : 
  Device product name     : 
  Device serial number    : 
  USB vendor id           : 0x045e
  USB product id          : 0x0719
  USB device id           : 0x0100
  Buffer handle           : 266
  Buffer internal id      : 572
  Buffer service routine  : 0xfc1d0770
  Buffer workspace        : 0x20003eb4
  DeviceFS handle         : 0x203644f4
  Data length             : 20
  Data offset             : 0
  Upcalls                 : 0 (delta: 0)
  Good reads              : 0 (delta: 0)
  Bad reads               : 0 (delta: 0)
  Raw data                : 20 00 00 00 01 00 00 20 6c 5e 06 fc 9d 00 1d fc 00 00 00 00
  Number of axes          : 8
  Number of buttons       : 11
  HAT switch              : No
  DPAD                    : Yes
  Axes:
  Axis 00 (    Z) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off
  Axis 01 (   RZ) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off 
  Axis 02 (    X) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 03 (    Y) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = on
  Axis 04 (   RX) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 05 (   RY) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 06 (DPADX) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off
  Axis 07 (DPADY) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off 
  HID items:
  Axis 00   : ReportId=0
  Axis 01   : ReportId=0
  Axis 02   : ReportId=0
  Axis 03   : ReportId=0
  Axis 04   : ReportId=0
  Axis 05   : ReportId=0
  Axis 16   : ReportId=0
  Axis 17   : ReportId=0
  Axis 18   : ReportId=0
  Axis 19   : ReportId=0
  DPAD up   : ReportId=0
  DPAD down : ReportId=0
  DPAD left : ReportId=0
  DPAD right: ReportId=0
  Button 00 : ReportId=0
  Button 01 : ReportId=0
  Button 02 : ReportId=0
  Button 03 : ReportId=0
  Button 04 : ReportId=0
  Button 05 : ReportId=0
  Button 06 : ReportId=0
  Button 07 : ReportId=0
  Button 08 : ReportId=0
  Button 09 : ReportId=0
  Button 10 : ReportId=0
Joystick id 7
  Path                    : devices#interface=7;endpoint=8;nopad;noblock:USB5
  File handle             : 243
  Data stream open        : Yes
  Local USB device name   : USB5
  Interface               : 7
  Endpoint                : 8
  Device manufacturer     : 
  Device product name     : 
  Device serial number    : 
  USB vendor id           : 0x045e
  USB product id          : 0x0719
  USB device id           : 0x0100
  Buffer handle           : 267
  Buffer internal id      : 616
  Buffer service routine  : 0xfc1d0770
  Buffer workspace        : 0x20003eb4
  DeviceFS handle         : 0x20365914
  Data length             : 20
  Data offset             : 0
  Upcalls                 : 0 (delta: 0)
  Good reads              : 0 (delta: 0)
  Bad reads               : 0 (delta: 0)
  Raw data                : d3 04 00 00 00 00 00 00 c4 00 04 00 00 00 0a 00 00 00 0a 00 
  Number of axes          : 8
  Number of buttons       : 11
  HAT switch              : No
  DPAD                    : Yes
  Axes:
  Axis 00 (    Z) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off 
  Axis 01 (   RZ) : Slope 8 = 0.9961, Slope 16 = 257.0000, SP = 97:159 Flip = off 
  Axis 02 (    X) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off
  Axis 03 (    Y) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = on 
  Axis 04 (   RX) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off 
  Axis 05 (   RY) : Slope 8 = 0.0039, Slope 16 = 1.0000, SP = -8191:8191 Flip = off
  Axis 06 (DPADX) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off 
  Axis 07 (DPADY) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off 
  HID items:
  Axis 00   : ReportId=0
  Axis 01   : ReportId=0
  Axis 02   : ReportId=0
  Axis 03   : ReportId=0
  Axis 04   : ReportId=0
  Axis 05   : ReportId=0
  Axis 16   : ReportId=0
  Axis 17   : ReportId=0
  Axis 18   : ReportId=0
  Axis 19   : ReportId=0
  DPAD up   : ReportId=0
  DPAD down : ReportId=0
  DPAD left : ReportId=0
  DPAD right: ReportId=0
  Button 00 : ReportId=0
  Button 01 : ReportId=0
  Button 02 : ReportId=0
  Button 03 : ReportId=0
  Button 04 : ReportId=0
  Button 05 : ReportId=0
  Button 06 : ReportId=0
  Button 07 : ReportId=0
  Button 08 : ReportId=0
  Button 09 : ReportId=0
  Button 10 : ReportId=0
richw wrote:
Fri Oct 05, 2018 9:03 pm
Saloon Cars... ahh... takes me back. I bought that when I was about ten, and all I wanted was to construct that controller setup, as described in the manual! I never had an I/O podule, though. I did have I/O podule emulation on my todo list (see post 1) so it should be possible. You could shim it as is, but you've only got the X and Y axis - I need to allow more to be mapped, since it looks like they are using four separate axes.

Maybe some new commands to map-up to the ADC channels, and perhaps some commands to play around with the range/sensitivity (just like changing those resistors on the pic above!).
Good point, in which case it will have to go into USBJoystick...it will work provided the game is using OS_Byte - which I suspect it is.

I have a Thrustmaster Force Feedback Steering Wheel (VID_06F8 PID_0004) I was going to try with it, but I need to be able to inject the HID descriptor as it doesn't have one.

richw
Posts: 137
Joined: Sat Sep 14, 2013 9:05 pm

Re: USB Joystick driver

Post by richw » Sat Oct 06, 2018 8:32 pm

That 8/16 stuff sounds odd. You can compare with my test code in the SRC.utils directory (it is a bit naff, sorry). I shall investigate too.

I have been pondering the ADC emulation, and think it would be reasonably straightforward to map an axis to one (or two, consider acc+brake on the same axis) channels. Not sure how to handle taking over osbyte but I am sure the PRM will enlighten me. Maybe it's just another UKSWIV trip? I will also need to hack up a quick BASIC test app.

Putting in a custom hid for your device is easy. If you have the vendor/product codes and the HID report descriptor...

JonAbbott
Posts: 2257
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: USB Joystick driver

Post by JonAbbott » Sun Oct 07, 2018 8:23 am

richw wrote:
Sat Oct 06, 2018 8:32 pm
I have been pondering the ADC emulation, and think it would be reasonably straightforward to map an axis to one (or two, consider acc+brake on the same axis) channels.
You'd probably have to play in Automatic if you don't have a clutch pedal.
richw wrote:
Sat Oct 06, 2018 8:32 pm
Not sure how to handle taking over osbyte but I am sure the PRM will enlighten me. Maybe it's just another UKSWIV trip?
You'd just sit on ByteV and claim it if it's one you're interested in.
richw wrote:
Sat Oct 06, 2018 8:32 pm
Putting in a custom hid for your device is easy. If you have the vendor/product codes and the HID report descriptor...
I need to create a HID descriptor, assuming one can be made of course. I plugged it into the Pi last week with the intention of dumping the endpoint to see if it does return suitable data, but DeviceFS refuses to connect to the endpoint reporting it doesn't exist. USBDescriptor describes two endpoints, 1 - OUT and 5 - IN, so I'm not sure why DeviceFS won't connect.

richw
Posts: 137
Joined: Sat Sep 14, 2013 9:05 pm

Re: USB Joystick driver

Post by richw » Sun Oct 07, 2018 9:59 pm

I’ve had a look at the OSBYTE interface. Looks OK. I think it will also wire-up ADVAL in BASIC, so I can knock-up a test utility too.

Your Joystick oddness in 8/16-bit is strange. I have tried your test app (in 8 and 16-bit mode) and it works fine with my controller. I can only think of two possibilities: 1) the data format on your device is different, so yours needs custom code or a different report descriptor 2) because you have multiple sticks active on the same device, something else in the code is confused. I don’t think it’s (2) because my atari-style adaptor presents as two endpoints, and that works fine. Admittedly, though, my atari interface is only a HAT device: no analogue axes.

Does your nintendo interface work OK?

Having looked at some other code for decoding XBOX controllers, I think the way forward might be to extend USBJoystick to support different ‘types’ of USB joystick: standard HID, XBOX360 wired, XBOX360 wireless, Thrustmaster FFW. The HID parsing might only be used for the first two, and totally bespoke decoders for the others. It would be cute if all the data formats could be described with HID report descriptors, but it might not be possible.

JonAbbott
Posts: 2257
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: USB Joystick driver

Post by JonAbbott » Mon Oct 08, 2018 6:48 am

Yes, the Nintendo clone worked okay, but I will retest with the latest build. I've yet to retest the Sidewinder FF Joystick, so I'll check that as well.

I'll see if I can dump some raw data from the XB360 controller so we can compare the format, that seems the most logical cause of the issue. I'll also add some additional debugging in the source to see if I can figure out how on earth 8/16 bit are returning different results, I could understand the axis might act differently, but the buttons working on 16bit, but not 8bit is just plain odd.

Adding support to inject an HID descriptor for specific VID/PID might cover all those non-HID compliant controllers, but as you say, that's assuming they don't need bespoke decoders.

JonAbbott
Posts: 2257
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: USB Joystick driver

Post by JonAbbott » Mon Oct 08, 2018 1:13 pm

I've restested the Joysticks and now grabbed USB data for the X360 controller. The NES clone works as expected. The Sidewinder suffers the same 8/16bit mixup issues as the XB360 controller with some of the buttons not working. Here's the debug info from it:

Code: Select all

Joystick id 0
  Path                    : devices#interface=0;endpoint=1;nopad;noblock:USB6
  File handle             : 249
  Data stream open        : Yes
  Local USB device name   : USB6
  Interface               : 0
  Endpoint                : 1
  Device manufacturer     : Microsoft
  Device product name     : SideWinder Force Feedback 2 Joystick
  Device serial number    : 
  USB vendor id           : 0x045e
  USB product id          : 0x001b
  USB device id           : 0x0a00
  Buffer handle           : 260
  Buffer internal id      : 308
  Buffer service routine  : 0xfc1d0770
  Buffer workspace        : 0x20003eb4
  DeviceFS handle         : 0x201d9c14
  Data length             : 12
  Data offset             : 1
  Upcalls                 : 5248 (delta: 20)
  Good reads              : 5245 (delta: 20)
  Bad reads               : 3 (delta: 0)
  Raw data                : 01 80 00 43 ff 00 00 08 00 a2 01 a4
  Number of axes          : 6
  Number of buttons       : 8
  HAT switch              : Yes
  DPAD                    : No
  Axes:
  Axis 00 (    X) : Slope 8 = 0.2483, Slope 16 = 64.0616, SP = -127:127 Flip = off
  Axis 01 (    Y) : Slope 8 = 0.2483, Slope 16 = 64.0616, SP = -127:127 Flip = off 
  Axis 02 (   RZ) : Slope 8 = 4.0317, Slope 16 = 1040.2380, SP = -7:7 Flip = off 
  Axis 03 (    S) : Slope 8 = 2.0000, Slope 16 = 516.0236, SP = 49:79 Flip = off
  Axis 04 ( HATX) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off 
  Axis 05 ( HATY) : Slope 8 = 1.0000, Slope 16 = 1.0000, SP = 0:0 Flip = off 
  HID items:
  Axis 00   : ReportId=1
  Axis 01   : ReportId=1
  Axis 02   : ReportId=1
  Axis 03   : ReportId=1
  Axis 16   : ReportId=1
  Axis 17   : ReportId=1
  Axis 18   : ReportId=1
  Axis 19   : ReportId=1
  HAT       : ReportId=1
  Button 00 : ReportId=1
  Button 01 : ReportId=1
  Button 02 : ReportId=1
  Button 03 : ReportId=1
  Button 04 : ReportId=1
  Button 05 : ReportId=1
  Button 06 : ReportId=1
  Button 07 : ReportId=1
And here's the raw USB data from the XB360 controller:

Code: Select all

Returns 29 bytes on Endpoint 1, which are as follows:

Buttons:

          A: 000100F000130010000008ED210CEAEAB7ED0000000000000000000000
          B: 000100F000130020000008ED210CEAEAB7ED0000000000000000000000
          X: 000100F000130040000008ED210CEAEAB7ED0000000000000000000000
          Y: 000100F000130080000008ED210CEAEAB7ED0000000000000000000000
         LB: 000100F000130001000008ED210CEAEAB7ED0000000000000000000000
         RB: 000100F000130002000008ED210CEAEAB7ED0000000000000000000000
XBox button: 000100F000130004000008ED210CEAEAB7ED0000000000000000000000
   D-Pad Up: 000100F000130100000008ED210CEAEAB7ED0000000000000000000000
 D-Pad Down: 000100F000130200000008ED210CEAEAB7ED0000000000000000000000
 D-Pad Left: 000100F000130400000008ED210CEAEAB7ED0000000000000000000000
D-Pad Right: 000100F000130800000008ED210CEAEAB7ED0000000000000000000000
      Start: 000100F000131000000008ED210CEAEAB7ED0000000000000000000000
       Back: 000100F000132000000008ED210CEAEAB7ED0000000000000000000000
 Left Thumb: 000100F000134000000008ED210CEAEAB7ED0000000000000000000000
Right Thumb: 000100F000138000000008ED210CEAEAB7ED0000000000000000000000
                         ^^^^
Right Thumb Y axis: 000100F000130000000008ED210CEAEAB7ED0000000000000000000000
                                                    ^^^^
Right Thumb X axis: 000100F000130000000008ED210CEAEAB7ED0000000000000000000000
                                                ^^^^
 Left Thumb Y axis: 000100F000130000000008ED210CEAEAB7ED0000000000000000000000
                                            ^^^^
 Left Thumb X axis: 000100F000130000000008ED210CEAEAB7ED0000000000000000000000
                                        ^^^^

RT:
000100F000130000000108ED210CEAEAB7ED0000000000000000000000
000100F000130000001508ED210CEAEAB7ED0000000000000000000000
000100F000130000002208ED210CEAEAB7ED0000000000000000000000
000100F000130000003808ED210CEAEAB7ED0000000000000000000000
000100F000130000004E08ED210CEAEAB7ED0000000000000000000000
000100F000130000005F08ED210CEAEAB7ED0000000000000000000000
000100F000130000007908ED210CEAEAB7ED0000000000000000000000
000100F000130000009108ED210CEAEAB7ED0000000000000000000000
000100F00013000000A808ED210CEAEAB7ED0000000000000000000000
000100F00013000000CA08ED210CEAEAB7ED0000000000000000000000
000100F00013000000E808ED210CEAEAB7ED0000000000000000000000
000100F00013000000FF08ED210CEAEAB7ED0000000000000000000000
                  ^^
LT:
000100F000130000030008ED210CEAEAB7ED0000000000000000000000
000100F000130000150008ED210CEAEAB7ED0000000000000000000000
000100F000130000260008ED210CEAEAB7ED0000000000000000000000
000100F000130000450008ED210CEAEAB7ED0000000000000000000000
000100F000130000650008ED210CEAEAB7ED0000000000000000000000
000100F000130000760008ED210CEAEAB7ED0000000000000000000000
000100F000130000910008ED210CEAEAB7ED0000000000000000000000
000100F000130000B80008ED210CEAEAB7ED0000000000000000000000
000100F000130000D80008ED210CEAEAB7ED0000000000000000000000
000100F000130000EA0008ED210CEAEAB7ED0000000000000000000000
000100F000130000FF0008ED210CEAEAB7ED0000000000000000000000
                ^^

In between data, there's sometimes a blank block of padding:
000000F000000000000000000000000000000000000000000000000000

So a button press looks like this:
000100F000130010000008ED210CEAEAB7ED0000000000000000000000 (A down)
000000F000000000000000000000000000000000000000000000000000 (padding)
000100F000130000000008ED210CEAEAB7ED0000000000000000000000 (A up)
000000F000000000000000000000000000000000000000000000000000 (padding)

Post Reply