USB Joystick driver
Richard Walker (2090) 416 posts |
Hi folks, I have released an alpha version of my USBJoystick driver module. Plug in a USB HID-compliant joystick, and you can configure the joystick to respond to the Acorn (Joystick_Read) and Serial Port (Joystick_Status) SWIs. This allows old classics such as James Pond, SWIV, Zool or Quest For Gold to work with a joystick. Obviously, you will need software such as ADFFS to get the games to run in the first place. Also, more up-to-date titles such as StarFighter 3000, which work out-of-the-box, also work with joysticks. The full details are here on the JASPP forum: https://forums.jaspp.org.uk/forum/viewtopic.php?f=8&t=396 It is worth looking at ADFFS itself, as you can collect some games whilst you’re there. :) All feedback welcome here, or on the JASPP forum. Cheers, |
Anthony Vaughan Bartram (2454) 455 posts |
Awesome Richard. Would it be ok to include with my games in the future? Once I’ve coded Joystick support…. Thanks and Regards, Tony Bartram |
Chris Mahoney (1684) 2100 posts |
Neat; I’ll have to try this when I have a bit of time :)
Wait, what? I was actually useful for something? What is this madness?! |
Jon Abbott (1421) 2599 posts |
Richard. The file you’ve uploaded appears to only contain the source, with no compiled Module. I’ve just modified ADFFS to handle RTFM conversion and then released I couldn’t test as there’s no Module!! |
SeñorNueces (1438) 160 posts |
Wow! I have been waiting for YEARS for this to happen! |
David Pitt (3386) 1248 posts |
It builds easily with DDE28 and OSLib. For the impatient my build was, temporarily, available from here. A build is now on the JASPP forum |
Jon Abbott (1421) 2599 posts |
I’ve just spent the best past of an hour to get it to compile under DDE24, I really shows up how non-backward compatible DDE is these days. Path aliases are different, missing commands, additional commands etc, I must have added about a dozen aliases to get it to build. Thanks for the build David, I’ve added it to the JASPP forum post. |
David Pitt (3386) 1248 posts |
That’s good, I have removed my copy. It’s better all in one place. Thanks. |
Chris Mahoney (1684) 2100 posts |
Time for the inevitable newbie questions :) *USBJoystick_Read 0 gives “Joystick not active”. *USBDevices shows that the joystick is number 11, but *USBJoystick_Read 11 gives “Bad parameters”. *USBJoystick_List returns “No active joysticks”. Does this mean that my joystick (Sony CUH-ZCT1E, from a Playstation 4) isn’t compatible, or am I just doing something wrong? I know that it uses a standard(ish?) protocol because it works under Windows and MacOS without any special drivers. |
Holger Palmroth (487) 115 posts |
If it work at all, *USBJoystick_Read 0 is the command of choice. 0 is the internal joystick number, the USB device number (11) means nothing to the module. Maybe you could try another cable, you are maybe trying to connect with a pure USB power cable without signal lines. EDIT: It seems that older PS4 controller used Bluetooth regardless if plugged in or not. I guess the same advice is true for joypads as it was for keyboards: BE BORING. The simplest, most generic €5 device will have better chances to work than the fancy stuff. EDIT2: In the current form the Joystick Module doesn’t do hot plug. Connect a joypad before switching on the Pi. Alternatively, reset. |
Chris Mahoney (1684) 2100 posts |
My Windows machine doesn’t have Bluetooth and the controller works with the same cable. That would indicate that the cable works, and that the controller uses it.
That could be part of it; I loaded the module before plugging in the controller. I’ll do some more testing when I can. |
Richard Walker (2090) 416 posts |
OK, so first thing… sorry about missing the binary off the updated release. I have this convoluted procedure: I was trying to figure out InfoZip, and I had to copy it to my NAS (because NetSurf is a bit chewy on the JASPP forum, my MacBook doesn’t like the NAS, but my Tablet can see the NAS and upload to the JASPP forum!!!). So I end up using three different devices to upload it. I’ve also never released the source code to anything before. I don’t know if I have missed anything, and I don’t know what would happen on different build environments (I have RISC OS 5 on a Pi with DDE 27). Come to think of it, I have only used the binary module on that same Pi, along with a single USB joystick. I cannot do ay more testing, which is why I’ve thrown it out to the world. (Anthony) I have no issue with anyone else distributing the module, but I really do need to take a closer look at the whole licensing/distribution side of things – not for my code, which I don’t maintain a claim to, but for the other bits I have borrowed from elsewhere. I think it’s OK, but it would be nice to check further. The PRM has a section on the Joystick_Read SWI, so covering it in your games should be simple. If you look at the addendum in PRM 5a, there is also 16-bit analogue stick support: I have not yet implemented this, as there are approximately zero games using it. Now, onto the issues: 1. Hotplug should work. I have not tested that feature for a while, however, so I’ll try and have a look tomorrow evening. If in doubt, just RMKill the module, and load it after the joystick is plugged in. 2. I have had a report of the !HID utility conflicting with USBJoystick: I suspect they are both trying to talk to the stick. If you have !HID, please try killing it completely. 3. Holger is spot-on with the numbering. The number is indeed an ‘internal joystick id’. I’m open to ideas on how to make this more friendly! Best way to start is to plug in your device, then do *USBDevices. You should see your stick mentioned, with a USB device name, e.g. USB5. Then run the USBJoystick module. If you do *USBJoystick_List, you should see that same joystick listed as ‘stick 0’, with the product manufacturer, product name, and USB device name (USB5) matching the *USBDevices output. The list info should also indicate that the driver is talking to the stick. If it is, USBJoystick_Read is the next step. If you have any bother, please try ‘*USBJoystick_Debug 0’ (or whatever the stick number is). And/or run Reporter before you start. |
Colin (478) 2433 posts |
I tried it with ps3 and ps4 game controllers and they weren’t recognised. Recompiling with a report_id of 1 made the module recognise the ps4 controller. The ps3 controller needs more work. Contact me at the address on my ftpc website if you’d like me to send the descriptors for these devices. |
Jon Abbott (1421) 2599 posts |
I’ve just posted on JASPP saying I believe there’s an issue with the Report Id. |
Richard Walker (2090) 416 posts |
Colin/Jon: there is indeed an issue with report_id. I have a PS1 controller (with a dodgy USB adaptor) which was suffering from the same problem. I figured out how to get report_id correct (based on iInterface) and that is looking better. If it’s OK, I’ll fix a couple more bugs, and try and get out 0.04 which should ‘just work’. If not, then I might have to start collecting descriptors. :) |
Anthony Vaughan Bartram (2454) 455 posts |
Hi Richard, I hope that you’re well. The fix that you’ve made in version 0.19 addresses the same error reported “Internal error, abort on instruction fetch at &00000000” that I’m seeing on the Pi 4 and Pi 400. Is it okay if I update the version that I’m using in the AMCOG Game Kit, Scuba Hunter and Star Mine to v0.19 and is it okay if I include the source code for it? All the best, |
Richard Walker (2090) 416 posts |
Hi Tony, Apologies for the rather slap-dash state of it! No issue at all including 0.19. It seems to be the most useful, especially if it isn’t crashing for you! I will try and upload 0.20 which is basically 0.19 with basic mouse functions. I will do a full archive with the source code. The source on github is probably quite old. I just plonked that there for convenience at one time I really must get around to thinking about a more formalised Joystick API so games can display joystick and axes names, and have much more exotic configuration. |
Anthony Vaughan Bartram (2454) 455 posts |
Hi Richard. Thanks for your reply and also for developing the USB joystick driver. This is the first problem I’ve had with it. The code has been pretty reliable. I’ll watch out for 0.20, but in the meantime I will update to 0.19. |
Richard Walker (2090) 416 posts |
I have put 0.20 on the JASPP site. For anyone who has not tried it, or only tried the earlier versions, you might find it worth a bash. In simple cases, you just double click the module and you’re away. Games like StarFighter 3000 which support joysticks should work. And if you install ADFFS, you can potentially run loads more. |
Willard Goosey (5119) 257 posts |
Works good with my cheap cheap chinese usb joypad! Hey Zool supports joystick! C001!!! (armv7 Pi2, riscos 5.28) |
Richard Walker (2090) 416 posts |
Woo, pleased to hear it, thanks! |