forked from openleap/PyLeapMouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PyLeapMouse.py
executable file
·46 lines (37 loc) · 1.62 KB
/
PyLeapMouse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#William Yager
#Leap Python mouse controller POC
import sys
if sys.platform == "darwin":
import OSX.Leap as Leap
import OSX.Mouse as Mouse
else:
import Windows.Leap as Leap
import Windows.Mouse as Mouse
from PalmControl import Palm_Control_Listener #For palm-tilt based control
from FingerControl import Finger_Control_Listener #For finger-pointing control
def main():
print "Use --finger (or no options) for pointer finger control,\nand --palm for palm control.\nRead README.md for more info."
cursor = Mouse.absolute_cursor() #Create a cursor object, which controls the cursor position, clicking, etc
listener = None; #I'm tired and can't think of a way to organize this segment nicely
#Create a custom listener object which controls the cursor
if len(sys.argv) == 1: #Finger pointer mode
listener = Finger_Control_Listener(cursor)
print "Using finger mode..."
elif sys.argv[1].lower() == "--finger": #Also finger control mode
listener = Finger_Control_Listener(cursor)
print "Using finger mode..."
elif sys.argv[1].lower() == "--palm": #Palm control mode
listener = Palm_Control_Listener(cursor)
print "Using palm mode..."
else:
print "Error parsing input options"
exit(1)
controller = Leap.Controller() #Get a Leap controller
print "Adding Listener."
controller.add_listener(listener) #Attach the listener
#Keep this process running until Enter is pressed
print "Press Enter to quit..."
sys.stdin.readline()
#Remove the sample listener when done
controller.remove_listener(listener)
main()