Comments (1)
Something like this
import hidapi
def my_callback(device, data, length):
print(f"Received {length} bytes of data: {data}")
# Open a HID device
handle = hidapi.hid_open_path(vendor_id=0x1234, product_id=0x5678, path="/dev/hidraw0")
if handle is None:
print("Failed to open HID device")
else:
# Register the callback function
hidapi.hid_set_callback(handle, my_callback)
# Write data to the device
data = [0x01, 0x02, 0x03]
num_bytes_written = hidapi.hid_write(handle, data, len(data))
print(f"Wrote {num_bytes_written} bytes of data")
# Read data from the device
data = hidapi.hid_read(handle, 64)
if data is None:
print("Failed to read data from HID device")
else:
print(f"Read {len(data)} bytes of data: {data}")
# Close the HID device
hidapi.hid_close(handle)
from pyspacemouse.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyspacemouse.