-
Notifications
You must be signed in to change notification settings - Fork 1
/
EvdevControl.py
56 lines (45 loc) · 1.4 KB
/
EvdevControl.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
47
48
49
50
51
52
53
54
55
56
from fuchikoma2 import *
from evdev import InputDevice, list_devices, ecodes
#//////////////////joystick Check
found = False;
devices = [InputDevice(fn) for fn in list_devices()]
for dev in devices:
#print(dev) #to list available input devices
if dev.name == 'Bluetooth 3.0 Macro Keyboard Keyboard':#replace with your keyboard name
found = True;
time.sleep(.75)
F.move(0,77)
time.sleep(.75)
F.move(0,0)
print("control system Green")
break
if not(found):
print('Bluetooth 3.0 Macro Keyboard not found')
sys.exit()
##############CONTROL SYSTEM--CHANGE KEYS AND FUNCTIONS TO YOUR NEEDS
def handle(code):
if code == ecodes.KEY_1:
F.bite()
if code==ecodes.KEY_H:
F.lok()
if code==ecodes.KEY_D:
F.lopen()
if code == ecodes.KEY_UP:
F.shoot()
#//////////////////total relax sets all servos to 0
if code == ecodes.KEY_L:
F.servo_lax()
#////////////////////exit program
if code == ecodes.KEY_ESC:
sys.exit()
def Manual():
try:
for event in dev.read_loop():
if event.type == ecodes.EV_KEY:
if event.value == 1: # key down(pressed)
handle(event.code)
'''if event.value == 0: # key up(released)
handle(event.code)'''
except KeyboardInterrupt:
sys.exit()
Manual()