Implement confined mouse mode for OS X.

Note: it seems that using #set_pointer() will result in
a long delay before an absolute mouse position is updated,
even though deltas are reported.

Thus, in CocoaPandaView, the mouse deltas are sent for both
relative and confined modes, so client code (e.g. the "mouse
modes" demo) will be able to recenter the mouse without
choppy movement.
This commit is contained in:
Ed Swartz
2015-04-23 11:20:24 -05:00
committed by Ed Swartz
parent 5f20afd5ea
commit fc5a2e5e33
4 changed files with 76 additions and 8 deletions
+6 -4
View File
@@ -34,7 +34,8 @@ class App(ShowBase):
# Disable the camera trackball controls.
self.disableMouse()
self.mouseMagnitude = 144
# control mapping of mouse movement to box movement
self.mouseMagnitude = 1
self.rotateX, self.rotateY = 0, 0
@@ -146,7 +147,8 @@ class App(ShowBase):
if self.manualRecenterMouse:
# move mouse back to center
self.recenterMouse()
self.lastMouseX, self.lastMouseY = 0, 0
# scale position and delta to pixels for user
w, h = self.win.getSize()
@@ -158,8 +160,8 @@ class App(ShowBase):
int(dx*w), int(dy*h)))
# rotate box by delta
self.rotateX += dx * 10
self.rotateY += dy * 10
self.rotateX += dx * 10 * self.mouseMagnitude
self.rotateY += dy * 10 * self.mouseMagnitude
self.positionText.setText("Model rotation: {0}, {1}".format(
int(self.rotateX*1000)/1000., int(self.rotateY*1000)/1000.))