cython-hidapi icon indicating copy to clipboard operation
cython-hidapi copied to clipboard

Touchpad data read error in windows while success in linux

Open realysy opened this issue 1 year ago • 0 comments

Hello,

I want to use this lib to read raw data of touchpad, and it works fine in linux (ubuntu 20.04) with sudo: sudo python main.py, but in windows (11) (I have installed a dual system with Windows and Linux so I can switch between the two), same code throw an exception as read error.

  • I've tried run python main.py in admin console, but still read error
  • I've tried open device by path instead of by vendor_id and product_id, still read error

Bellow is my env:

  • laptop computer: Thinkpad Tp1 Gen6, the touchpad is SYNA801D:00 vendorID:productID Touchpad
  • Python 3.10
  • hidapi installed by pip install hidapi: 0.14.0.post2

main.py:

import hid

VENDOR_ID, PRODUCT_ID = 0x05DB, 0xECE9

try:
    h = hid.device()
    h.open(VENDOR_ID, PRODUCT_ID)  # success

    h.set_nonblocking(1)

    while True:
        data = h.read(64)          # throw exception: `read error` in windows
        if data:
            print(f"Raw data: {data}")

except Exception as e:
    print(f"An error occurred: {e}")
finally:
    h.close()

realysy avatar Oct 10 '24 05:10 realysy