WinUAE icon indicating copy to clipboard operation
WinUAE copied to clipboard

Invalid Joystick Axis handling for speedlink joystick

Open marcinkulus opened this issue 6 years ago • 1 comments

I've bought a speedlink Rocketeer Joystick recently and tried using it with WinUAE. Unfortunately, no matter how i tried reconfiguring it, it only allowed me to move left and up - right and down movement was impossible. At first I thought, that the joystick was damaged during the delivery, but then I tested it both with Windows USB Game Controllers Setup and also a few PC games native to Windows - it worked normally.

I took a peek at the code (inputdevice.cpp) and realized, that it assumes the following:

The joystick axis input (variable name: state) will either be a negative or a positive number. Negative numbers go left or up, positive numbers go down or right.

This assumption may not be true for all devices. As I tested the joystick in USB Game Controllers, it would show a value around 0 when the joystick was tilted left , 75 when it was centered and 150 when it was tilted fully right.

Proposed fix: Adding an axis bias (or two, for X and Y separately) to input configuration added to the state variable would enable the user to calibrate such devices, greatly increasing the spectrum of supported joysticks.

inputdevice.cpp else { /* "normal" joystick axis */ state += BIAS;

marcinkulus avatar Apr 01 '18 19:04 marcinkulus

inputdevice.cpp always gets adjusted "balanced" range. USB HID support code queries the device for range and automatically adds offset if needed.

Lots of game pads use 0 to 255 or 0 to 1023 or 0 to 65535 range. -127 to 127 or similar is less common. Some (broken) USB game controller returns different max range than actual range, these are not supported in USB HID mode.

Attach winuaebootlog.txt, it will include device's reported max range values. You can also use "-inputlog 4 -log" command line parameters to see real time output of game controller's unprocessed raw axis values to confirm if values match with reported max values.

tonioni avatar Apr 01 '18 20:04 tonioni