Close

[C] Made ButtonRing diagonals consistent with cardinal directions

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/19/2023 at 19:590 Comments

Something I noticed when using the ButtonRing is that it seemed that less force was needed to press. This ment that I often activated the Diagonal Edge button instead of the Outer Diagonal button and it would take 4 - 5 attempts to get it right. 

The reason is because diagonal magnitudes are able to be larger than cardinals.

When I first encountered the issue, I considered doing something inside the angle-checking if-blocks themselves, but I thought that would just result in a cliff-edge response between the main cardinal directions and the diagonal directions.

A few hours ago, I got the idea to have a magnitude multiplier that would scale back these larger values, and it didn't take long to find (via image search) a polar equation that did what I wanted to do (with a few tweaks):

I went into desmos to experiment. I plugged in real values so that I could work to a more general calculation.

This is the equation I want. The clover-like shape is the magnitude multiplier and the circle is the minimum of this multiplier which should be exactly on the diagonals. I tweaked the values so that the maximum for this function was 1.

I was able to discover a general equation to make sure that the function was less than or equal to 1, and then I rearanged the inner circle equation to make the minimum value of the function the subject.

I feel like the implementation is a bit crude since I have to remember to multiply currentMagnitude, prevMagnitude and SpacePoint.ButtonEvent, but if I try and do this multiplier filtering on the input values as they come in, I belive SpacePoint.ButtonRing would decay to 0. Remember, 3DxPoint just gets handed a new axis value and, at that point in time, doesn't know what angle the spacemouse is at.

Anyway, after once again being thrown under the bus temporarily because C++ divided 2 ints and probably injected a 0 into my double variable (see below for correction), I got the fix to work.

I've only tried it for a couple minutes but it already feels like the ButtonRing is more true to my intent. I'm now also considering if I need to use this for cursor translation too.

Discussions