diff options
author | Devaev Maxim <[email protected]> | 2020-11-03 10:15:19 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-11-08 02:11:16 +0300 |
commit | 52a6eb3d98e22826881c75714d10e47204b55d41 (patch) | |
tree | 4a6f3781c8f3db12076cbb300cdc3f942d06f87f /kvmd/apps/otg | |
parent | 5f407fd4a0833c91e9bc683d058321bf409b650e (diff) |
bt hid
Diffstat (limited to 'kvmd/apps/otg')
-rw-r--r-- | kvmd/apps/otg/hid/keyboard.py | 7 | ||||
-rw-r--r-- | kvmd/apps/otg/hid/mouse.py | 16 |
2 files changed, 18 insertions, 5 deletions
diff --git a/kvmd/apps/otg/hid/keyboard.py b/kvmd/apps/otg/hid/keyboard.py index c38a2bfb..a098c6de 100644 --- a/kvmd/apps/otg/hid/keyboard.py +++ b/kvmd/apps/otg/hid/keyboard.py @@ -20,11 +20,13 @@ # ========================================================================== # +from typing import Optional + from . import Hid # ===== -def make_keyboard_hid() -> Hid: +def make_keyboard_hid(report_id: Optional[int]=None) -> Hid: return Hid( protocol=1, # Keyboard protocol subclass=1, # Boot interface subclass @@ -40,6 +42,9 @@ def make_keyboard_hid() -> Hid: 0x09, 0x06, # USAGE (Keyboard) 0xA1, 0x01, # COLLECTION (Application) + # Report ID + *([0x85, report_id] if report_id is not None else []), + # Modifiers 0x05, 0x07, # USAGE_PAGE (Keyboard) 0x19, 0xE0, # USAGE_MINIMUM (Keyboard LeftControl) diff --git a/kvmd/apps/otg/hid/mouse.py b/kvmd/apps/otg/hid/mouse.py index 9dcc0e5d..b1d235a2 100644 --- a/kvmd/apps/otg/hid/mouse.py +++ b/kvmd/apps/otg/hid/mouse.py @@ -20,13 +20,15 @@ # ========================================================================== # +from typing import Optional + from . import Hid # ===== -def make_mouse_hid(absolute: bool, horizontal_wheel: bool) -> Hid: +def make_mouse_hid(absolute: bool, horizontal_wheel: bool, report_id: Optional[int]=None) -> Hid: maker = (_make_absolute_hid if absolute else _make_relative_hid) - return maker(horizontal_wheel) + return maker(horizontal_wheel, report_id) _HORIZONTAL_WHEEL = [ @@ -40,7 +42,7 @@ _HORIZONTAL_WHEEL = [ ] -def _make_absolute_hid(horizontal_wheel: bool) -> Hid: +def _make_absolute_hid(horizontal_wheel: bool, report_id: Optional[int]) -> Hid: return Hid( protocol=0, # None protocol subclass=0, # No subclass @@ -60,6 +62,9 @@ def _make_absolute_hid(horizontal_wheel: bool) -> Hid: 0x09, 0x02, # USAGE (Mouse) 0xA1, 0x01, # COLLECTION (Application) + # Report ID + *([0x85, report_id] if report_id is not None else []), + # 8 Buttons 0x05, 0x09, # USAGE_PAGE (Button) 0x19, 0x01, # USAGE_MINIMUM (Button 1) @@ -96,7 +101,7 @@ def _make_absolute_hid(horizontal_wheel: bool) -> Hid: ) -def _make_relative_hid(horizontal_wheel: bool) -> Hid: +def _make_relative_hid(horizontal_wheel: bool, report_id: Optional[int]) -> Hid: return Hid( protocol=2, # Mouse protocol subclass=1, # Boot interface subclass @@ -111,6 +116,9 @@ def _make_relative_hid(horizontal_wheel: bool) -> Hid: 0x09, 0x02, # USAGE (Mouse) 0xA1, 0x01, # COLLECTION (Application) + # Report ID + *([0x85, report_id] if report_id is not None else []), + # 8 Buttons 0x05, 0x09, # USAGE_PAGE (Button) 0x19, 0x01, # USAGE_MINIMUM (Button 1) |