CurryKitten / CurryKitten-Sim

FPV quad simulator
70 stars 7 forks source link

Revamp the controller calibration and control remapping (again) #33

Closed CurryKitten closed 4 years ago

CurryKitten commented 4 years ago

Despite spending an eternity on this already, it seems that some people can't get their radios setup... and sometimes it's not the weird and wonderful USB dongles, it's known good radios like the Q7 or X9D. These should work out of the box with zero setup, but there's not much debug I can gather aside from sending over the code to view the raw axis... but it's still difficult to debug remotely.

Slightly inspired by a user who sent me over his non-working USB dongle, as well as arguing with the Rewired developer about my approach here - I've decided on a 3-pronged attack.

The USB dongle in question didn't remap because only at the full extent of the stick, only 0.3 of the axis was being detected and the InputMapper needs 0.7. The Rewired developer is going to make a change to make this alterable (although he didn't agree with the philosophy)

The InputMapper would work if the axis was calibrated before hand, but as we have no idea of which axis the input is going to come from, it's difficult to calibrate. Rewired Dev suggests calibrating them all at once. This is probably a good idea - and would certainly fix the dongle issue.

However, will it fix all... probably not, so as far as debugging goes I need to be able to visualise all the axis/buttons available on the radio and what they are assigned to... with perhaps a manual way of allocating them. There are far too many virtual axis and buttons available on a controller, so I will take 8 of each and see how we go.

Depending on what fixes what, one or more of these may be removed later. As generally I don't want the user to have to think about multiple weird axis controls and things. I just want them to be able to move a stick and make that stick "throttle" for example

CurryKitten commented 4 years ago

First part of this implemented. I rewrote the calibration function to calibrate the first 8 axis at once (or less if less that 8 axis are detected) It's a simple case of centering all the sticks for 5 seconds, and then moving them to all their extents for 5 seconds. With the calibrated axis the remapping doesn't have an issue. I tried it on a USB dongle that a user sent in and was found to only move around 30% of the axis length, meaning that yaw (which was on ch 6) was never seen to be able to remap. After the calibration, this remapped without a hitch.

CurryKitten commented 4 years ago

I managed to get a user to test this out on his previously non-working QX7 radio and he was able to calibrate, remap and get playing - so yay.

My testing on the QX7 showed that it was absolutely fine on my test machines without me having to do anything... which is weird. But several more people reported similar issues on also good known-working radios like the X9d so hopefully, this will fix it for them as well. I'll release this code in 0.43a

I also worked on the axis visualisations to help in debugging (although the revamped calibration means that with any luck it won't be needed) I've made this debug screen accessible from the Radio Calibration menu

Screenshot 2020-02-07 at 15 59 24

One in the Radio Debug screen, it will show the state of the first 8 axis and first 8 buttons (where a tick means the button is active) this axis will show Unity/Rewired view of them, rather than any raw values. in fact, I deliberately haven't included values at all as a float between -1 and 1 isn't very friendly anyway. I like to this the visuals speak for themselves.

Screenshot 2020-02-07 at 12 36 27

Any current allocations on the Axis are shown (although any changes/calibrations etc needs to be done form the Radio calibration screen)

I may expand this, or revamp it when I come to add switches as keyboard functions to the sim.