Skip to content

Commit

Permalink
feat: absolute positions
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Dec 3, 2023
1 parent 8c77778 commit 8795e7a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
11 changes: 11 additions & 0 deletions usb_gadget/init_usb_gadget
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ echo -ne \\x25\\x7F # LOGICAL_MAXIMUM (127)
echo -ne \\x75\\x08 # REPORT_SIZE (8)
echo -ne \\x95\\x01 # REPORT_COUNT (1)
echo -ne \\x81\\x06 # INPUT (Data,Var,Rel)

# x,y absolute coordinates
echo -ne \\x05\\x01 # USAGE_PAGE (Generic Desktop)
echo -ne \\x09\\x30 # USAGE (X)
echo -ne \\x09\\x31 # USAGE (Y)
echo -ne \\x16\\x01\\xFF # LOGICAL_MINIMUM (-255)
echo -ne \\x26\\xFF\\x00 # LOGICAL_MAXIMUM (255)
echo -ne \\x75\\x10 # REPORT_SIZE (16)
echo -ne \\x95\\x02 # REPORT_COUNT (2)
echo -ne \\x81\\x02 # INPUT (Data,Var,Abs)

echo -ne \\xC0 # END_COLLECTION
} >> "$D"
cp "$D" "${MOUSE_FUNCTIONS_DIR}/report_desc"
Expand Down
15 changes: 12 additions & 3 deletions zero_hid/hid/mouse.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
from . import write as hid_write

def send_mouse_event(dev, buttons, relative_x, relative_y,
vertical_wheel_delta, horizontal_wheel_delta):
vertical_wheel_delta, horizontal_wheel_delta,
absolute_x=None, absolute_y=None):
buf = [
buttons,
relative_x & 0xff,
relative_y & 0xff,
vertical_wheel_delta & 0xff,
horizontal_wheel_delta & 0xff
]
hid_write.write_to_hid_interface(dev, buf)


if absolute_x is not None and absolute_y is not None:
buf.extend([
absolute_x & 0xff,
(absolute_x >> 8) & 0xff,
absolute_y & 0xff,
(absolute_y >> 8) & 0xff
])

hid_write.write_to_hid_interface(dev, buf)

0 comments on commit 8795e7a

Please sign in to comment.