Skip to content

Commit

Permalink
#3992 macOS: Dragging broken in Unity
Browse files Browse the repository at this point in the history
OSXScreen was not adding mouse movement deltas to mouse events while
dragging. Some 3D applications rely on these deltas to implement
dragging. Adding the mouse deltas to the mouse event fixes dragging in
these applications. Ex: Unity3d
  • Loading branch information
jpmcmu authored and Andrew Nelless committed Jan 25, 2017
1 parent a5140aa commit 2f29e43
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/lib/platform/OSXScreen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,23 @@
// Fix for sticky keys
CGEventFlags modifiers = m_keyState->getModifierStateAsOSXFlags();
CGEventSetFlags(event, modifiers);


// Set movement deltas to fix issues with certain 3D programs
SInt64 deltaX = pos.x;
deltaX -= m_xCursor;

SInt64 deltaY = pos.y;
deltaY -= m_yCursor;

CGEventSetIntegerValueField(event, kCGMouseEventDeltaX, deltaX);
CGEventSetIntegerValueField(event, kCGMouseEventDeltaY, deltaY);

double deltaFX = deltaX;
double deltaFY = deltaY;

CGEventSetDoubleValueField(event, kCGMouseEventDeltaX, deltaFX);
CGEventSetDoubleValueField(event, kCGMouseEventDeltaY, deltaFY);

CGEventPost(kCGHIDEventTap, event);

CFRelease(event);
Expand Down

0 comments on commit 2f29e43

Please sign in to comment.