Skip to content

Commit

Permalink
Emit delta only when it makes sense
Browse files Browse the repository at this point in the history
  • Loading branch information
X9VoiD authored and gonX committed Nov 27, 2023
1 parent 5d3d8e2 commit 55d24f6
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace OpenTabletDriver.Desktop.Interop.Input.Absolute
public class MacOSAbsolutePointer : MacOSVirtualMouse, IAbsolutePointer
{
private Vector2 offset;
private Vector2 lastPos;
private Vector2 delta;
private Vector2? lastPos;
private Vector2? delta;

public MacOSAbsolutePointer()
{
Expand All @@ -33,12 +33,17 @@ public void SetPosition(Vector2 pos)
protected override void SetPendingPosition(IntPtr mouseEvent, float x, float y)
{
CGEventSetLocation(mouseEvent, new CGPoint(x, y));
CGEventSetDoubleValueField(mouseEvent, CGEventField.mouseEventDeltaX, delta.X);
CGEventSetDoubleValueField(mouseEvent, CGEventField.mouseEventDeltaY, delta.Y);
if (delta is not null)
{
CGEventSetDoubleValueField(mouseEvent, CGEventField.mouseEventDeltaX, delta.Value.X);
CGEventSetDoubleValueField(mouseEvent, CGEventField.mouseEventDeltaY, delta.Value.Y);
}
}

protected override void ResetPendingPosition(IntPtr mouseEvent)
{
lastPos = null;
delta = null;
}
}
}

0 comments on commit 55d24f6

Please sign in to comment.