I'll probably add Voltmace emulation to ADFFS, its only applicable to a few legacy games and will need explicitly turning on only whilst those games are running.Mouse movement is proportional so the farther the stick is from the centre, the faster the pointer moves. There are a couple of pots on the bottom that control the sensitivity in the x and y directions. The stick position controls the speed of movement so having the stick dead centre means the pointer doesn't move rather than the pointer being in the centre of the screen.
USBJoystick 0.12
Re: USB Joystick driver
Voltmace Mouse Eliminator details (courtesy of RobC on StarDot):
Re: USB Joystick driver
Thanks for the USBDescriptor info - looks the same as my knock-off.
I've been reading and fiddling about, and I've now got the axes to be detected according to their function. So instead of listing axes as 0, 1, 2 etc. it will show X, Y, Z, Rx, Ry and so on. I have not been able to find out how to do the same for their directions.
I am thinking that I could improve the mapping so that it automatically maps up the X and Y axes to the legacy Joystick APIs. We can also define new variations on Joystick_Read that allow additional axes to be reported.
However, on my 360 controller at least, I have a X and Y axes (the sticks) and I have an X and Y hat-switch. So for some/most games, you would want to map the HAT X and Y axis up to the legacy Joystick API (rather than analogue X and Y). I am still mulling this over in my head - not sure:
I have also put in some code to switch off the XBOX360 controller LEDs, but I don't know if it works, because my clone pad doesn't switch any LEDs on by default! I'll release a newer build at some point soon and you can give it a go on your real controller.
I've been reading and fiddling about, and I've now got the axes to be detected according to their function. So instead of listing axes as 0, 1, 2 etc. it will show X, Y, Z, Rx, Ry and so on. I have not been able to find out how to do the same for their directions.
I am thinking that I could improve the mapping so that it automatically maps up the X and Y axes to the legacy Joystick APIs. We can also define new variations on Joystick_Read that allow additional axes to be reported.
However, on my 360 controller at least, I have a X and Y axes (the sticks) and I have an X and Y hat-switch. So for some/most games, you would want to map the HAT X and Y axis up to the legacy Joystick API (rather than analogue X and Y). I am still mulling this over in my head - not sure:
- what I can do automatically
- what the default should be
- if each stick and/or axis should be specified manually, so it's very granular
I have also put in some code to switch off the XBOX360 controller LEDs, but I don't know if it works, because my clone pad doesn't switch any LEDs on by default! I'll release a newer build at some point soon and you can give it a go on your real controller.
Re: USB Joystick driver
I'm pretty sure the PID standard defines the direction in one of the ID's.richw wrote: ↑Tue Sep 18, 2018 12:48 pm I've been reading and fiddling about, and I've now got the axes to be detected according to their function. So instead of listing axes as 0, 1, 2 etc. it will show X, Y, Z, Rx, Ry and so on. I have not been able to find out how to do the same for their directions.
We should probably resurrect the Joystick thread on ROOL and propose any changes.
For the purposes of legacy games, having the HAT alter the analogue X, Y axis returned by Joystick_Read would probably suffice, so you can use either the thumb stick or the HAT. The current Joystick API has no understanding of a HAT, so it would need extending if it were to be presented as a seperate input.
My thinking here was to have all games accepting a standard set of inputs, so you don't have to configure each game individually. So for example ADFFS knows that game X uses Z X P L RETURN which are mapped to Left, Right, Up, Down, Fire. In the Joystick configuration you're then mapping X Axis, Y Axis and Fire and ADFFS handles translating those to what the game expects. In other words, Up on the Joystick is always Up in a game irrespective of the game using keyboard, Acorn, RTFM, Voltmace.richw wrote: ↑Tue Sep 18, 2018 12:48 pm I'm not convinced that different games will really need different axes mappings: all existing titles must just use X and Y, and it's up to the user which physical control they want for that, isn't it? I agree that the keyboard mapping needs doing for the keyboard-only games: as I understand it, you've done something in ADFFS for now, and I plan on adding 'action to key' mapping in USBJoystick at some point.
This will be internally handled by ADFFS, so not something the user needs access to configure. The only configuration the user is doing is in the Joystick Configuration app, which is a global setting.
You probably want to set the LED to Joystick 1, otherwise you won't know if it's on or off

Re: USB Joystick driver
OK, so I’ve attached version 0.08 to the first post.
I have improved the display of various *commands and tried to indicate the axes types. Now that USBJoystick understands them, I have made a semi-intelligent auto-map: it will do as you proposed, Jon. My knock-off XBOX360 controller will map the DPAD to the 8-bit APIs, and the analogue X/Y to the 16-bit APIs. In theory, it should stop the LED blinking - I’d appreciate any feedback on that.
I couldn’t figure out the direction detection: the PID standard didn’t help me - I must be missing something.
I’d appreciate anyone commenting on the usefulness of the automatic mapping. In theory, you can just double-click the module, and it should ‘just work’ (as they say!). Does that actually work for anyone?!
I have improved the display of various *commands and tried to indicate the axes types. Now that USBJoystick understands them, I have made a semi-intelligent auto-map: it will do as you proposed, Jon. My knock-off XBOX360 controller will map the DPAD to the 8-bit APIs, and the analogue X/Y to the 16-bit APIs. In theory, it should stop the LED blinking - I’d appreciate any feedback on that.
I couldn’t figure out the direction detection: the PID standard didn’t help me - I must be missing something.
I’d appreciate anyone commenting on the usefulness of the automatic mapping. In theory, you can just double-click the module, and it should ‘just work’ (as they say!). Does that actually work for anyone?!
Re: USB Joystick driver
I've done some quick testing with 0.08. I'm seeing a lot of Floating point exception and Abort on instruction fetch errors when using Joystick_Read from BASIC, so there's possibly some stack/register corruption occurring.
I've given it a try with my XB360 controller, it appears to map everything correctly going by USBJoystick_List, but Joystick_Read 0 isn't seeing any Joystick activity. None of the axis, DPad or buttons appeared to do anything. It also appears to list the same joystick mapped 8 times to id's 0 thru 7 so its possible one other ID's was reporting - which I probably should have checked at the time.
LED blinking hasn't changed, all four ID LED's are flashing. I wonder if there's a difference between your clone and official XB360 controllers?
Here's the automapping output:
The Nintendo SNES JoyPad clone appears to map correctly:
However its randomly reporting +-126/127 if left untouched, which may or may not be related to the random Abort/Floating point errors being reported (I had to ignore errors to get this meagre output without a fatal error):
I've given it a try with my XB360 controller, it appears to map everything correctly going by USBJoystick_List, but Joystick_Read 0 isn't seeing any Joystick activity. None of the axis, DPad or buttons appeared to do anything. It also appears to list the same joystick mapped 8 times to id's 0 thru 7 so its possible one other ID's was reporting - which I probably should have checked at the time.
LED blinking hasn't changed, all four ID LED's are flashing. I wonder if there's a difference between your clone and official XB360 controllers?
Here's the automapping output:
Code: Select all
Joystick id 0
Local USB device name : USB5
Interface : 0
Endpoint : 1
Device manufacturer :
Device product name : Xbox 360 Wireless Receiver for Windows
Device serial number : FD8EAC00
Number of axes : 8
Number of buttons : 11
HAT switch : No
DPAD : Yes
Mapped to Joystick number : 00
Mapped to Joystick 8-bit x-axis : 06 (DPADX)
Mapped to Joystick 8-bit y-axis : 07 (DPADY)
Mapped to Joystick 16-bit x-axis : 02 (X)
Mapped to Joystick 16-bit y-axis : 03 (Y)
Mapped to Joystick button 00 : 00
Mapped to Joystick button 01 : 01
Mapped to Joystick button 02 : 02
Mapped to Joystick button 03 : 03
Mapped to Joystick button 04 : 04
Mapped to Joystick button 05 : 05
Mapped to Joystick button 06 : 06
Mapped to Joystick button 07 : 07
Joystick id 1
Local USB device name : USB5
Interface : 1
Endpoint : 2
Device manufacturer :
Device product name : Xbox 360 Wireless Receiver for Windows
Device serial number : FD8EAC00
Number of axes : 8
Number of buttons : 11
HAT switch : No
DPAD : Yes
Mapped to Joystick number : 01
Mapped to Joystick 8-bit x-axis : 06 (DPADX)
Mapped to Joystick 8-bit y-axis : 07 (DPADY)
Mapped to Joystick 16-bit x-axis : 02 (X)
Mapped to Joystick 16-bit y-axis : 03 (Y)
Mapped to Joystick button 00 : 00
Mapped to Joystick button 01 : 01
Mapped to Joystick button 02 : 02
Mapped to Joystick button 03 : 03
Mapped to Joystick button 04 : 04
Mapped to Joystick button 05 : 05
Mapped to Joystick button 06 : 06
Mapped to Joystick button 07 : 07
Joystick id 2
Local USB device name : USB5
Interface : 2
Endpoint : 3
Device manufacturer :
Device product name : Xbox 360 Wireless Receiver for Windows
Device serial number : FD8EAC00
Number of axes : 8
Number of buttons : 11
HAT switch : No
DPAD : Yes
Mapped to Joystick number : 02
Mapped to Joystick 8-bit x-axis : 06 (DPADX)
Mapped to Joystick 8-bit y-axis : 07 (DPADY)
Mapped to Joystick 16-bit x-axis : 02 (X)
Mapped to Joystick 16-bit y-axis : 03 (Y)
Mapped to Joystick button 00 : 00
Mapped to Joystick button 01 : 01
Mapped to Joystick button 02 : 02
Mapped to Joystick button 03 : 03
Mapped to Joystick button 04 : 04
Mapped to Joystick button 05 : 05
Mapped to Joystick button 06 : 06
Mapped to Joystick button 07 : 07
Joystick id 3
Local USB device name : USB5
Interface : 3
Endpoint : 4
Device manufacturer :
Device product name : Xbox 360 Wireless Receiver for Windows
Device serial number : FD8EAC00
Number of axes : 8
Number of buttons : 11
HAT switch : No
DPAD : Yes
Mapped to Joystick number : 03
Mapped to Joystick 8-bit x-axis : 06 (DPADX)
Mapped to Joystick 8-bit y-axis : 07 (DPADY)
Mapped to Joystick 16-bit x-axis : 02 (X)
Mapped to Joystick 16-bit y-axis : 03 (Y)
Mapped to Joystick button 00 : 00
Mapped to Joystick button 01 : 01
Mapped to Joystick button 02 : 02
Mapped to Joystick button 03 : 03
Mapped to Joystick button 04 : 04
Mapped to Joystick button 05 : 05
Mapped to Joystick button 06 : 06
Mapped to Joystick button 07 : 07
Joystick id 4
Local USB device name : USB5
Interface : 4
Endpoint : 5
Device manufacturer :
Device product name : Xbox 360 Wireless Receiver for Windows
Device serial number : FD8EAC00
Number of axes : 8
Number of buttons : 11
HAT switch : No
DPAD : Yes
Mapped to Joystick number : 04
Mapped to Joystick 8-bit x-axis : 06 (DPADX)
Mapped to Joystick 8-bit y-axis : 07 (DPADY)
Mapped to Joystick 16-bit x-axis : 02 (X)
Mapped to Joystick 16-bit y-axis : 03 (Y)
Mapped to Joystick button 00 : 00
Mapped to Joystick button 01 : 01
Mapped to Joystick button 02 : 02
Mapped to Joystick button 03 : 03
Mapped to Joystick button 04 : 04
Mapped to Joystick button 05 : 05
Mapped to Joystick button 06 : 06
Mapped to Joystick button 07 : 07
Joystick id 5
Local USB device name : USB5
Interface : 5
Endpoint : 6
Device manufacturer :
Device product name : Xbox 360 Wireless Receiver for Windows
Device serial number : FD8EAC00
Number of axes : 8
Number of buttons : 11
HAT switch : No
DPAD : Yes
Mapped to Joystick number : 05
Mapped to Joystick 8-bit x-axis : 06 (DPADX)
Mapped to Joystick 8-bit y-axis : 07 (DPADY)
Mapped to Joystick 16-bit x-axis : 02 (X)
Mapped to Joystick 16-bit y-axis : 03 (Y)
Mapped to Joystick button 00 : 00
Mapped to Joystick button 01 : 01
Mapped to Joystick button 02 : 02
Mapped to Joystick button 03 : 03
Mapped to Joystick button 04 : 04
Mapped to Joystick button 05 : 05
Mapped to Joystick button 06 : 06
Mapped to Joystick button 07 : 07
Joystick id 6
Local USB device name : USB5
Interface : 6
Endpoint : 7
Device manufacturer :
Device product name : Xbox 360 Wireless Receiver for Windows
Device serial number : FD8EAC00
Number of axes : 8
Number of buttons : 11
HAT switch : No
DPAD : Yes
Mapped to Joystick number : 06
Mapped to Joystick 8-bit x-axis : 06 (DPADX)
Mapped to Joystick 8-bit y-axis : 07 (DPADY)
Mapped to Joystick 16-bit x-axis : 02 (X)
Mapped to Joystick 16-bit y-axis : 03 (Y)
Mapped to Joystick button 00 : 00
Mapped to Joystick button 01 : 01
Mapped to Joystick button 02 : 02
Mapped to Joystick button 03 : 03
Mapped to Joystick button 04 : 04
Mapped to Joystick button 05 : 05
Mapped to Joystick button 06 : 06
Mapped to Joystick button 07 : 07
Joystick id 7
Local USB device name : USB5
Interface : 7
Endpoint : 8
Device manufacturer :
Device product name : Xbox 360 Wireless Receiver for Windows
Device serial number : FD8EAC00
Number of axes : 8
Number of buttons : 11
HAT switch : No
DPAD : Yes
Mapped to Joystick number : 07
Mapped to Joystick 8-bit x-axis : 06 (DPADX)
Mapped to Joystick 8-bit y-axis : 07 (DPADY)
Mapped to Joystick 16-bit x-axis : 02 (X)
Mapped to Joystick 16-bit y-axis : 03 (Y)
Mapped to Joystick button 00 : 00
Mapped to Joystick button 01 : 01
Mapped to Joystick button 02 : 02
Mapped to Joystick button 03 : 03
Mapped to Joystick button 04 : 04
Mapped to Joystick button 05 : 05
Mapped to Joystick button 06 : 06
Mapped to Joystick button 07 : 07
Code: Select all
Joystick id 0
Local USB device name : USB6
Interface : 0
Endpoint : 1
Device manufacturer :
Device product name : usb gamepad
Device serial number :
Number of axes : 2
Number of buttons : 10
HAT switch : No
DPAD : No
Mapped to Joystick number : 00
Mapped to Joystick 8-bit x-axis : 00 (X)
Mapped to Joystick 8-bit y-axis : 01 (Y)
Mapped to Joystick 16-bit x-axis : 00 (X)
Mapped to Joystick 16-bit y-axis : 01 (Y)
Mapped to Joystick button 00 : 00
Mapped to Joystick button 01 : 01
Mapped to Joystick button 02 : 02
Mapped to Joystick button 03 : 03
Mapped to Joystick button 04 : 04
Mapped to Joystick button 05 : 05
Mapped to Joystick button 06 : 06
Mapped to Joystick button 07 : 07
Code: Select all
X=127 Y=0 Buttons: 00000000
X=0 Y=0 Buttons: 00000000
X=126 Y=-126 Buttons: 00000000
X=0 Y=0 Buttons: 00000000
X=0 Y=-126 Buttons: 00000000
X=0 Y=0 Buttons: 00000000
X=0 Y=-126 Buttons: 00000000
X=0 Y=0 Buttons: 00000000
X=0 Y=127 Buttons: 00000000
X=0 Y=0 Buttons: 00000000
X=0 Y=-126 Buttons: 00000000
X=0 Y=0 Buttons: 00000000
X=0 Y=127 Buttons: 00000000
X=0 Y=0 Buttons: 00000000
X=126 Y=-126 Buttons: 00000000
X=0 Y=0 Buttons: 00000000
X=0 Y=-126 Buttons: 00000000
X=0 Y=0 Buttons: 00000000
X=127 Y=-126 Buttons: 00000000
Re: USB Joystick driver
Hmm, interesting. I don't see any FP exceptions from BASIC. I use the test code in the src.utils directory in my archive. Can you share the output of USBJoystick_List and _Debug, so I can see what the min/max values for the axes are? (should be the same as mine, as it's my report descriptor!) Did you see the FP exceptions in 0.07?
It is strange how your controller appears as eight different endpoints. I wonder if that is because the single wireless dongle can support multiple (eight?) control pads?
My USB hid report descriptor is actually the XBOX360 one bakced into NetBSD/FreeBSD, so it should work with genuine controllers. I wonder if your wireless unit is a more modern thing, so actually needs a more sophisticated, or just different, configuration?
If you move an axis and/or button, can you see any changes in the 'raw data' shown in the USBJoystick_Debug command?
It is strange how your controller appears as eight different endpoints. I wonder if that is because the single wireless dongle can support multiple (eight?) control pads?
My USB hid report descriptor is actually the XBOX360 one bakced into NetBSD/FreeBSD, so it should work with genuine controllers. I wonder if your wireless unit is a more modern thing, so actually needs a more sophisticated, or just different, configuration?
If you move an axis and/or button, can you see any changes in the 'raw data' shown in the USBJoystick_Debug command?
Re: USB Joystick driver
I've tracked the issue down, the problem occurs when ADFFS is loaded as it calls Joystick_Read during the fake VSync to set the RTFM Econet registers and do key translation. My guess is Joystick_Read is failing due to reentracy, so I'll probably have to manage Joystick_Read in the SWI handler so it can't be called reentrantly. I'll code that up and see if solves the issue.
In the meantime, I'll test without ADFFS loaded.
I don't need to connect an XB360 controller to see eight endpoints, so its coming from the official wireless dongle. When a Joystick is connected the raw data value changes from:
Code: Select all
20 00 00 00 44 00 38 00 45 00 41 00 43 00 30 00 30 00 66 00
Code: Select all
00 F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Re: USB Joystick driver
Debug output of XB360 controller when moving the left thumbstick:
Debug example of XB360 controller when left idle:
Code: Select all
Joystick id 0
Path : devices#interface=0;endpoint=1;nopad;noblock:USB6
File handle : 252
Data stream open : Yes
Buffer handle : 260
Buffer internal id : 308
Buffer service routine : 0xfc1d0770
Buffer workspace : 0x20003eb4
USB vendor id : 0x045e
USB product id : 0x0719
USB device id : 0x0100
DeviceFS handle : 0x20347bd4
Data length : 20
Data offset : 0
Upcalls : 1747 (delta: 128)
Good reads : 1746 (delta: 128)
Bad reads : 1 (delta: 0)
Raw data : 00 01 00 f0 00 13 00 00 00 00 b9 eb 4b 0b 31 42 e7 03 00 00
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)
Code: Select all
Joystick id 0
Path : devices#interface=0;endpoint=1;nopad;noblock:USB6
File handle : 252
Data stream open : Yes
Buffer handle : 260
Buffer internal id : 308
Buffer service routine : 0xfc1d0770
Buffer workspace : 0x20003eb4
USB vendor id : 0x045e
USB product id : 0x0719
USB device id : 0x0100
DeviceFS handle : 0x20347bd4
Data length : 20
Data offset : 0
Upcalls : 1619 (delta: 72)
Good reads : 1618 (delta: 72)
Bad reads : 1 (delta: 0)
Raw data : 00 00 00 f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
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)
Re: USB Joystick driver
Interesting. I generally have ADFFS loaded, but I am a couple of versions out of date, so it may pre-date your RTFM 'hacks'. I would suspect the FP exception to be a divide by zero, but I can't see one in my C. Hopefully it works without ADFFS.
I have discovered some issues with certain devices where multiple report ids are used, so I am fixing that.
I suspect my clone wireless controller is working as per the spec of an official wired one. Yours is official wireless, which looks to have more steps in the comms protocol. I was browsing some other sources online and it is complex. I need to study it. I might need to try and acquire one, as I might need to make a lot of mods!
I have discovered some issues with certain devices where multiple report ids are used, so I am fixing that.
I suspect my clone wireless controller is working as per the spec of an official wired one. Yours is official wireless, which looks to have more steps in the comms protocol. I was browsing some other sources online and it is complex. I need to study it. I might need to try and acquire one, as I might need to make a lot of mods!
Re: USB Joystick driver
It will only be an problem with 2.68 when calling Joystick_Read from 32bit code. I implemented a workaround for 26bit code early in testing, as some games suffered the same issue.
I've now added Joystick_Read to the SWI handler and prevented reentrancy, which has resolved the issue.
I expect you're probably right, I don't have a wired controller here to confirm though.richw wrote: ↑Sun Sep 30, 2018 10:23 pm I suspect my clone wireless controller is working as per the spec of an official wired one. Yours is official wireless, which looks to have more steps in the comms protocol. I was browsing some other sources online and it is complex. I need to study it. I might need to try and acquire one, as I might need to make a lot of mods!