-
Notifications
You must be signed in to change notification settings - Fork 0
/
Olympus Foot Pedal RS-26 USB device.py
63 lines (46 loc) · 1.58 KB
/
Olympus Foot Pedal RS-26 USB device.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
57
58
59
60
61
62
63
"""
PyUSB Python code to read buttons from Olympus Foot Pedal RS-26 USB device, on Windows. Tested on Windows 10 64
Author: tballas
Requirements:
1. Install libusbK: https://sourceforge.net/projects/libusbk/
Then:
2. You must setup a driver with: http://zadig.akeo.ie/
Make sure the device you are setting up has the "USB ID" 07B4 0202 and you select "libusbK" for the driver
3. PyUSB:
Download the zip from here: http://walac.github.io/pyusb/
Unzip to a folder then follow these installation instructions: https://github.com/walac/pyusb#installing-pyusb-on-windows
"""
from __future__ import print_function
import usb.core
import usb.util
import sys
deviceCode = "FootPedal"
# Modify these to do whatever you want
def leftButton (): print(deviceCode + '.' + "LeftButton" + '.' + str(keycode[2]))
def middleButton (): print(deviceCode + '.' + "MiddleButton" + '.' + str(keycode[2]))
def rightButton (): print(deviceCode + '.' + "RightButton" + '.' + str(keycode[2]))
def errhandler ():
pass
# Dictionary of actions
keyactions = {
8: leftButton,
2: middleButton,
4: rightButton
}
VID = 0x07B4 # Vendor ID for: OLYMPUS CORPORATION
PID = 0x0202 # Product ID for: Foot Pedal RS-26
Endpoint = 0x83 # Endpoint into Host, Interrupt Transfer Type
# Find device
dev = usb.core.find(idVendor=VID, idProduct=PID)
# Check results of find
if dev is None:
raise ValueError('Device not found')
print("We've found the device")
dev.set_configuration()
# Read the data
try:
while True:
keycode = dev.read(Endpoint,8)
keyactions.get(keycode[2],errhandler)()
except KeyboardInterrupt:
exit(0)