CurryKitten / CurryKitten-Sim

FPV quad simulator
70 stars 7 forks source link

The big joystick mapping/calibration/axis redefinition feature #20

Closed CurryKitten closed 4 years ago

CurryKitten commented 4 years ago

Many issues are being raised or reported against using different joysticks or radios in the sim. The typical problems are:

Whilst it would seem that the easy way to fix all (or at least most) of these issues is to ask the user to move the stick for throttle (for example) and then calibrate the joystick at this point to detect the low/mid/high points.

Unfortunately, Unity constrains us as far as joysticks go. We can redefine axis easily enough, but actual calibration is completely missing. It's dependant (it says) on the calibration to the OS. But this doesn't seem to ring true, with several people showing me evidence of their radios being calibrated fine in Windows and then going completely wrong in the sim itself. I put a question into the Unity support form asking about this, but didn't get a response.

I started coding up the process of allowing axis detection and being able to swap things around here, as well as detecting the type of radio/joystick and making some templates, but it doesn't fix the calibration issue. I found a Unity asset store package called Rewired which is a native plugin which can handle calibration. I described the issue to the project owner who thinks this may be able to work, but has warned that it can't cover all instances. Rewired is a $45 package, so I will evaluate it using the trial version and potentially put out a standalone tester for people having issues to see if it can solve their problems.

In the meantime, I'm going to close off all other issues about controllers and point them to this one.

howels commented 4 years ago

Heard good things about rewired, apparently the best route around Unity's annoying input handling.

CurryKitten commented 4 years ago

Quick test of Rewired features so far are looking very promising as I'm able to hot swap between a Taranis and a PS4 controller with no extra code needed. I need to now look at the controller remapping and calibration before I can see whether this will fix the problems

DroneFletch commented 4 years ago

Xbox controller works except for throttle. (Left stick up and down) It also does this funny thing. https://imgur.com/a/M5dNRNd Throttle up and down is where it flips.

CurryKitten commented 4 years ago

Much weirdness, I still have to fix the clipping through the floor thing. Xbox controller will work in the next update. I've been using a PS4 pad in conjunction with a Taranis to test things as I've been going. I've sorted out the axis remapping stuff, I just need to finish the calibration now

CurryKitten commented 4 years ago

This is finally done with sticks able to remap any to any and gamepads supported. I made some other changes that went hand-in-hand with these.

All the modes are now supported (1-4) but in real terms, this is just a handy cosmetic touch to show your stick layout how it would look - it doesn't try and rearrange the inputs to suit, but is easily remapped to suit.

In a similar vein, I've ditched the control maps. Aside from the fact that we only supported 2, and the actual number of possible maps were enormous, now that it's very easy to remap axis to channels it's not necessary. The default stick layout is still for mode 2 and AETR - but again, this is easily changed.

With gamepads being supported, I've also added an option to change the stick type. This is to combat the fact that gamepads sticks have much less travel than proper radios and they are sprung to return to centre. This only affects the throttle stick, but if you select Gamepad as the stick type, it's take the zero to full throttle input form the centre stick to the top - this is to let the throttle drop to nothing by relaxing the stick rather than having to physcally pull it downwards.

Screenshot 2020-01-06 at 09 37 43

I'm not sure which way beginners would prefer this - I'll let them feedback and tell me. The sticks are very sensitive like this though, so a future idea would be to give some presets for rates (both for gamepad sticks and beginner rates on regular radio)

This will be released in 0.4a (once testing is finished)