lokxii / Mac-trackpad-mapper

A utility for Mac that maps finger position on trackpad to cursor location on Scnreen
MIT License
28 stars 3 forks source link

change in out-of-bounds handling #3

Closed Axilotl17 closed 1 year ago

Axilotl17 commented 1 year ago

A thought I had while tinkering with this would be to change how the cursor is mapped to the screen when it is out of bounds;

Let's assume we are using the config for the upper right corner from the readme (In #2, that is)

MTPoint map(double normx, double normy) {
    MTPoint point = {
            //the right half (.5 to 1) of the trackpad
            .x = rangeRatio(normx, .5, 1),
            //the top half (0 to 0.5) of the trackpad
            .y = rangeRatio(normy, 0, .5),
        };
    point.x *= screenSize.x;
    point.y *= screenSize.y;
    return point;
}

Currently, if you move your finger, say, to the left of the area, at about .25, .25 (coordinates on trackpad as the MTPoint) then your cursor still moves on the y axis, as it is in the range of y, while it is stuck all the way at the left of the screen because it is off the range of x.

This behavior causes issues; say, with the configuration above, you put your finger @ .25, .75; this is neither in the range of x OR y, causing non-absolute tracking to be commence... kind of.

It seems that the fingerPosition (or maybe some phantom cursor tracking!?!?) is actually being moved if you have your finger in this inaccessible region, however when your cursor is moved back into the region (however your finger is not) it gets teleported back down to the bottom left because it realizes it is out of bounds; It's really difficult to explain. Just try to apply the config I provided above and put your finger in the bottom left.

My suggested change is to disregard any finger position OUTSIDE of the range given in the map rule. This does have the downside of creating dead areas of your trackpad, which doesn't feel the best, but at least the inaccessable regions should be dead, if not anything out of either range.

TLDR: make it so finger position outside {x AND y} or outside {x OR y} is disregarded, and cursor position does not change.

lokxii commented 1 year ago

I have been experimenting with the mouse events and realized I can't filter mouse moved / mouse dragged events. A workaround is to emit mouse events to try to fix the cursor in position but I haven't got it working.

lokxii commented 1 year ago

Problem you described should have been fixed in eeb144bf7d7fa2271acdb551feefc037d6eaba72. Please check and close the issue.

Axilotl17 commented 1 year ago

looks better, although there's a new issue (as always)