[E1][C] Improved mouse smoothness

A project log for AirBerries and SpaceExplorer

I should start using my £80 split keyboard and £40 spacemouse more than my £32 keyboard and £16 mouse.

kelvinakelvinA 11/28/2023 at 00:060 Comments

This suprisingly took even more effort than the ButtonRing and I got a lot more help from BingChat this time around. Essentially, I wanted to replace the simple method with one that waited until it was sure both the real and imaginary components were accounted for. This is the plan I wrote just to have an idea on what to do:

I then asked BingChat many C++ questions, such as 

and also learned things that I didn't even know existed, such as

I then started deriving equations in Desmos:

This one is for velocity speed limits. There also needed to be a "slow movement zone".

To get that slow movement zone, I needed to store the fractional part of the number I sent to SendMouse so that it could be carried forward.

Eventually, I had to create a massive wall of logs to debug:

This is one of the BingChat functions, and there wasn't any checks for m == 0.

I still had the issue with overshooting, so I had the idea to implement a bell curve that would multiply the output by considering the %-changed of the magnitude. Didn't help:

I went in, fixed a bug with the %-change calculation, and tried many different curves, namely those that actually went negative when the %-change was close to -100% as it would actually cause the mouse to bounce back slightly, mirroring the actual feeling on the spacemouse.

Red = Bell, Green = Linear, Purple = Cos and Blue = Exponent.

I also tried a negative bell curve on positive %-change, but since I was often getting things like +1400% when starting off, it meant that the cursor started going backwards before going forwards. For medium-large moves, this was beneficial as it gave me just a bit more runway, but was counter-intuitive when I was moving inside the slow-zone.

The finishing touch I've just added now are some lines so that the bounceback feature actually bounces back in the same direction it came in:

Before this change, I'd often have situations like this:

This is because when the spacemouse closer to the centre, it's more likely to magnetise onto a cardinal direction. Here's a gif that tries to show what it looks like now:
The slight ghosting of the GIF is probably a feature and not a bug in this case.

[9 Dec] I've mostly been using the below displacement multiplier curves (before admitting defeat and trying a Logitech G300s mouse):


For the multiplier when decelerating (-1 <= x <= 0), I just tried the 4 combinations of the 2 curves and got the most points in the accuracy test with the above configuration. 

For accelerating, my reasoning was that I'd either be coasting (so near 0) or wanting to accelerate (usually over 14), thus values in the middle should be supressed as I'm probably just transitioning from one to the other. In practice, looking at the logs, it seems that change-in-magnitude readings are something like 20 -> 8 -> 2 -> 1.5 -> 0.8 -> 0.2..., so don't seem to be many values around in the suppression region anyway.

If I could just get the ergonomics of the SpaceExplorer with the speed and precision of the G300s, that would be great. Like the opposite version of the Wing mouse: