mirror of
https://github.com/wahyd4/raspberry-pi.git
synced 2026-08-09 04:46:15 +10:00
init repo
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import usb.core
|
||||
import usb.util
|
||||
import time
|
||||
|
||||
USB_IF = 0 # Interface
|
||||
USB_TIMEOUT = 5 # Timeout in MS
|
||||
|
||||
USB_VENDOR = 0x045e # Rii
|
||||
USB_PRODUCT = 0x028e # Mini Wireless Keyboard
|
||||
|
||||
dev = usb.core.find(idVendor=USB_VENDOR, idProduct=USB_PRODUCT)
|
||||
|
||||
endpoint = dev[0][(0,0)][0]
|
||||
|
||||
if dev.is_kernel_driver_active(USB_IF) is True:
|
||||
dev.detach_kernel_driver(USB_IF)
|
||||
|
||||
usb.util.claim_interface(dev, USB_IF)
|
||||
|
||||
while True:
|
||||
control = None
|
||||
|
||||
try:
|
||||
control = dev.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize, USB_TIMEOUT)
|
||||
print(control)
|
||||
print(control[2])
|
||||
except:
|
||||
pass
|
||||
|
||||
time.sleep(0.1) # Let CTRL+C actually exit
|
||||
Reference in New Issue
Block a user