Skip to content

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

Open
@Ciantic

Description

@Ciantic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions