This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

#3992 macOS: Dragging broken in Unity

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 nlyan committed Dec 3, 2014
1 parent ba55369 commit 0eff5a95bea3c0d21c6adfa468f7696853c10692
Showing with 17 additions and 1 deletion.
  1. +17 −1 src/lib/platform/OSXScreen.mm
@@ -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);

0 comments on commit 0eff5a9

Please sign in to comment.