I'm trying to use PyUSB to capture data, change it and then send it to the PC as if it had come straight from the device in question. The device I am trying to connect to is a Wacom One tablet.
So far I have been able to pull the data from the tablet using the code below:
import usb.core
import usb.util
import usb.backend.libusb1
# find our device
dev = usb.core.find(idVendor=0x056A, idProduct=0x037A)
# was it found?
if dev is None:
raise ValueError('Device not found')
print(dev)
# set the active configuration. With no arguments, the first
# configuration will be the active one
dev.set_configuration()
# get an endpoint instance
cfg = dev.get_active_configuration()
intf = cfg[(0,0)]
# first endpoint
endpoint = dev[0][(0,0)][0]
# read a data packet
data = None
while True:
try:
data = dev.read(endpoint.bEndpointAddress,
endpoint.wMaxPacketSize)
print(data)
except usb.core.USBError as e:
data = None
if e.args == ('Operation timed out',):
continue
But currently as the tablet is detached from the kernel there is no movement of the cursor. This is fine as it should be but I can only find ways of sending data back to the Wacom tablet, I need to sift through , edit the data of the tablet (that I have done in a separate program) and finally send it through to the PC so it can be read by the Wacom driver. The reason I want the data to be sent as if it had not been edited is because I don't want to have to rewrite the entire driver for the tablet as Wacom's driver is good it was just missing some features that will be added by the manipulation of the data.