Relative (#18)

* refactoring

* basic relative mouse mode
This commit is contained in:
Maxim Devaev
2020-11-03 04:50:08 +03:00
committed by GitHub
parent 6ec82dde5d
commit 544f4b3fec
9 changed files with 246 additions and 85 deletions

View File

@@ -24,7 +24,7 @@ from . import Hid
# =====
MOUSE_HID = Hid(
MOUSE_ABSOLUTE_HID = Hid(
protocol=0, # None protocol
subclass=0, # No subclass
@@ -84,3 +84,54 @@ MOUSE_HID = Hid(
0xC0, # END_COLLECTION
]),
)
MOUSE_RELATIVE_HID = Hid(
protocol=2, # Mouse protocol
subclass=1, # Boot interface subclass
report_length=5,
report_descriptor=bytes([
# https://github.com/NicoHood/HID/blob/0835e6a/src/SingleReport/BootMouse.cpp
# Relative mouse
0x05, 0x01, # USAGE_PAGE (Generic Desktop)
0x09, 0x02, # USAGE (Mouse)
0xA1, 0x01, # COLLECTION (Application)
# 8 Buttons
0x05, 0x09, # USAGE_PAGE (Button)
0x19, 0x01, # USAGE_MINIMUM (Button 1)
0x29, 0x08, # USAGE_MAXIMUM (Button 8)
0x15, 0x00, # LOGICAL_MINIMUM (0)
0x25, 0x01, # LOGICAL_MAXIMUM (1)
0x95, 0x08, # REPORT_COUNT (8)
0x75, 0x01, # REPORT_SIZE (1)
0x81, 0x02, # INPUT (Data,Var,Abs)
# X, Y
0x05, 0x01, # USAGE_PAGE (Generic Desktop)
0x09, 0x30, # USAGE (X)
0x09, 0x31, # USAGE (Y)
# Wheel
0x09, 0x38, # USAGE (Wheel)
0x15, 0x81, # LOGICAL_MINIMUM (-127)
0x25, 0x7F, # LOGICAL_MAXIMUM (127)
0x75, 0x08, # REPORT_SIZE (8)
0x95, 0x03, # REPORT_COUNT (3)
0x81, 0x06, # INPUT (Data,Var,Rel)
# Horizontal wheel
0x05, 0x0C, # USAGE PAGE (Consumer Devices)
0x0A, 0x38, 0x02, # USAGE (AC Pan)
0x15, 0x81, # LOGICAL_MINIMUM (-127)
0x25, 0x7F, # LOGICAL_MAXIMUM (127)
0x75, 0x08, # REPORT_SIZE (8)
0x95, 0x01, # REPORT_COUNT (1)
0x81, 0x06, # INPUT (Data,Var,Rel)
# End
0xC0, # END_COLLECTION
]),
)