Skip to content

I made an USB plug & play mode with zero-hid #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Ciantic opened this issue Mar 17, 2025 · 0 comments
Open

I made an USB plug & play mode with zero-hid #1

Ciantic opened this issue Mar 17, 2025 · 0 comments

Comments

@Ciantic
Copy link

Ciantic commented Mar 17, 2025

First of all, great work!

If you are interested here is my "plug & play" USB mode:

https://github.com/ciantic/pycamera-mouse

It was relatively easy to make, only gotcha was that using the zero-hid package was not straightforward, if I tried to use the "official" Python package it cratered the framerate from 70 -> 40fps, but I found out I can just write to the HID device like this:

mouse_hid_device = open("/dev/hidg1", "wb")

def set_relative_mouse(x, y):
    mouse_hid_device.seek(0)
    buttons = 0x0
    vertical_wheel_delta = 0
    horizontal_wheel_delta = 0
    buf = [
            buttons,
            int(x) & 0xFF,
            int(y) & 0xFF,
            vertical_wheel_delta & 0xFF,
            horizontal_wheel_delta & 0xFF,
        ]

    mouse_hid_device.write(bytes(buf))
    mouse_hid_device.flush()

And it was trivial after that. This didn't affect the framerate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant