openleap / PyLeapMouse

A Leap Motion based mouse in Python
Other
172 stars 65 forks source link

Tracking stops when window out of focus #18

Closed skylogic004 closed 11 years ago

skylogic004 commented 11 years ago

On Windows 8, when the window goes out of focus the mouse stops moving.

I've narrowed it down that it has to do with the Leap not giving events when the window goes out of focus. At first I thought the mouse events were the problem however I tested out Sample.py in the Leap SDK and it stops printing messages as soon as the window loses focus - implying this is something to do the Leap Controller listener.

Any ideas why this might be? Or how to fix it?

skylogic004 commented 11 years ago

Turns out there's a policy which allows or disallows tracking in the background: https://developer.leapmotion.com/documentation/Languages/Python/API/pydoc/Leap.Controller.html#Leap.Controller.setpolicyflags

This is the fix: controller = Leap.Controller() controller.setpolicyflags(Leap.Controller.POLICYBACKGROUNDFRAMES)

(I asked the same question on Leap Dev Forum: https://developer.leapmotion.com/forums/forums/support/topics/python-tracking-stops-when-window-out-of-focus?page=1)

wyager commented 11 years ago

skylogic, would you mind submitting a pull request with the changes? I will merge them.