USBJoystick 0.12

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

USBJoystick 0.12

Post by richw » Sat Mar 24, 2018 11:01 pm

Hi all,

As previously mentioned, here is an alpha test version of my USB Joystick driver module (scroll to bottom of post for download link).

Edit: I have removed the overview/instructional content: see later posts.
Attachments
USBJoystick012.zip
(191.42 KiB) Downloaded 16 times
USBJoystick009.zip
(185.29 KiB) Downloaded 18 times
USBJoystick008.zip
(183.42 KiB) Downloaded 16 times
Last edited by richw on Thu Nov 08, 2018 10:14 pm, edited 19 times in total.

grannyg
Posts: 17
Joined: Fri Dec 13, 2013 3:47 pm

Re: USB Joystick driver

Post by grannyg » Sun Mar 25, 2018 10:40 am

Just tried it on a RPi 3B+ with SWIV. Works great with a Competition Pro and a cheapo Snes Clone.
Seems really responsive.
Initially couldn't get the usbjoystick_read to show any changes. Had to remove !USBHID from !Boot. It also caused aborts when booting.

Adding the USBJoystick module to PreDesk works OK too once !USBHID was removed from !Boot.

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

Re: USB Joystick driver

Post by richw » Sun Mar 25, 2018 10:16 pm

Ah, yes. I shall have to try that (I have the freeware version somewhere).

USBJoystick scans all connected devices, and anything that it decides looks like a joystick, it will try and talk to. Maybe HID is trying to do similar? I cannot recall the error-handling path when it cannot open the stream, so I shall investigate.

Thanks for the feedback.

Regarding your earlier question on the keyboard handling, yes, I am planning on adding more *commands so you can map a movement to a fake key press. So keyboard-only games could become controlled by joystick. Same idea for the mouse.

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

Re: USB Joystick driver

Post by richw » Tue Mar 27, 2018 9:49 pm

I have just upped the version to 0.03.

The second stick on the Joystick_Status SWI was corrupt, and I have tried to indicate if the endpoint could not be opened on *USBJoystick_List

The archive also includes the source code.

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

Re: USB Joystick driver

Post by JonAbbott » Tue Mar 27, 2018 10:31 pm

Emulate RTFM joystick API (based on Econet hardware peeks)
I can modify ADFFS to pass reads/writes to the Econet interface to your code if it's any use? At the time it handles them it's in Abort mode with IRQ disabled, so you won't be able to issue any SWI, but assuming it's just translating cached values it will work.

Is there any documentation on the RTFM interface? I'll need to know which addresses it's on.

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

Re: USB Joystick driver

Post by JonAbbott » Wed Mar 28, 2018 12:51 pm

JonAbbott wrote:
Tue Mar 27, 2018 10:31 pm
Is there any documentation on the RTFM interface? I'll need to know which addresses it's on.
I've found the RTFM drivers here, based on which I've modified ADFFS so the check for the RTFM Joystick Interface works.

It appears to use bits 4..0 across two ports @ 33A0004 and 33A0008. From what I can gather, each port is a separate Joystick with bits defined as follows:

Code: Select all

Bit / Value
0     Right
1     Left
2     Down
3     Up
4     Fire
If I read the joystick state via Joystick_Read at VSync and set the two registers accordingly, will that be sufficient to work with your Module?

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

Re: USB Joystick driver

Post by JonAbbott » Wed Mar 28, 2018 4:39 pm

After much faffing around I've finally manage to get the 0.03 source to compile under DDE24 - had to create aliases for some commands and duplicate path variables, not to mention hunt down FAppend!

Anyhow...assuming the resultant Module is ARMv7 compatible, I tested the two HID devices I have on a Pi3. Sadly neither show up under *USBJoystick_List.

The first I tried was a Microsoft Force Feedback Joystick, which identifies as:

Code: Select all

USB$Device_00_00_00_045E_001B_-1_-1_0A00_USB5 : 5
USB$Device_03_00_00_045E_001B_01_00_0A00_USB5 : 5 0 0
The second one was a Thrustmaster Force Feedback Steering Wheel, which identifies as:

Code: Select all

USB$Device_00_00_00_06F8_0004_-1_-1_0100_USB6 : 6
USB$Device_FF_FF_FF_06F8_0004_01_00_0100_USB6 : 6 0 0
I have however made the changes to ADFFS to translate the Acorn Joystick interface to RTFM...just need to test it, if I can find a Joystick that will show up.

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

Re: USB Joystick driver

Post by richw » Wed Mar 28, 2018 8:36 pm

JonAbbott wrote:
Wed Mar 28, 2018 12:51 pm
I've found the RTFM drivers here, based on which I've modified ADFFS so the check for the RTFM Joystick Interface works.
Ah yes, I knew I’d downloaded them before from somewhere! I vaguely recall looking at the ReadJoy BASIC program. Shame the archive contains the Extend virus.
It appears to use bits 4..0 across two ports @ 33A0004 and 33A0008. From what I can gather, each port is a separate Joystick with bits defined as follows:

Code: Select all

Bit / Value
0     Right
1     Left
2     Down
3     Up
4     Fire
If I read the joystick state via Joystick_Read at VSync and set the two registers accordingly, will that be sufficient to work with your Module?
That sounds reasonable from my glance over the ReadPorts code (ARM assembler isn’t really my thing, though!). It looks fairly similar to the Serial Port’s SWI interface, so I’m sure I can produce the correct data format. The bit which scared me was the hardware probing, where it’s doing all that funky Econet stuff. I guess it can be dumbed down slightly, so as you say, we just need to trap reads from BoardAddr (0x33A0004). Not sure how to do that in a C module, but I’ll ponder it.

I suspect it’s also worth looking at a game itself, as it’s a bit of an assumption that the official test application is representative of the games. :) Mind you, that’s the approach I took for the Acorn and Serial Port SWIs, and it seemed to work OK. I don’t suppose in your archive metadata, you note the joystick status for each game?

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

Re: USB Joystick driver

Post by richw » Wed Mar 28, 2018 8:44 pm

JonAbbott wrote:
Wed Mar 28, 2018 4:39 pm
After much faffing around I've finally manage to get the 0.03 source to compile under DDE24 - had to create aliases for some commands and duplicate path variables, not to mention hunt down Append!
Ah yes, I had some fun with FAppend being missing from my DDE (27), and I was going to raise that on the ROOL forums. You’ve reminded me! I was trying to follow the pattern of the shared makefiles etc., using some of the modules in the RISC OS source code as templates for how things should be set up.
Anyhow...assuming the resultant Module is ARMv7 compatible, I tested the two HID devices I have on a Pi3. Sadly neither show up under
*USBJoystick_List.
Shame. Any chance you can run Reporter and observe the output when you start the USBJoystick module? It will only list (and try and talk to) devices that it believes are USB HID compliant, and ‘look like’ gamepads/joysticks. The ‘look like’ algorithm came from XMAME, which apparently uses the same sort of approach Microsoft used in Windows. I am not totally surprised that a steering wheel might be too funky, but you’d think an FF joystick would work (are they quite old?).

I have an Ancient (2005-ish) Playstation 1 pad to USB adaptor, and that doesn’t work at all. It doesn’t provide a HID descriptor.

I have however made the changes to ADFFS to translate the Acorn Joystick interface to RTFM...just need to test it, if I can find a Joystick that will show up.
Ah, so you trap those memory reads, and just issue a Joystick_Read SWI? That should ‘just work’ as they say. I have a feeling converting to Joystick_Status might be even easier.

Vanfanel
Posts: 476
Joined: Mon Sep 16, 2013 12:01 am

Re: USB Joystick driver

Post by Vanfanel » Wed Mar 28, 2018 10:18 pm

My joystick is a PSX original joystick that uses a GreenAsia adapter, very popular around here.
It seems that, according to *usbjoystick_list, it's not recognized... :(
Any chances for it to work? Works on GNU/Linux with no problem on PC, Raspberry Pi, etc...

Post Reply