Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

usb-device-hid: Fix boot protocol config in descriptor, default protocol mode, and protocol mode recover.#1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
hyx0329 wants to merge2 commits intomicropython:master
base:master
Choose a base branch
Loading
fromhyx0329:usb-hid-boot-protocol
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletionsmicropython/usb/usb-device-hid/usb/device/hid.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,6 +34,8 @@
_INTERFACE_SUBCLASS_NONE = const(0x00)
_INTERFACE_SUBCLASS_BOOT = const(0x01)

# These values will only make sense when interface subclass
# is 0x01, which indicates boot protocol support.
_INTERFACE_PROTOCOL_NONE = const(0x00)
_INTERFACE_PROTOCOL_KEYBOARD = const(0x01)
_INTERFACE_PROTOCOL_MOUSE = const(0x02)
Expand DownExpand Up@@ -130,7 +132,9 @@ def desc_cfg(self, desc, itf_num, ep_num, strs):
itf_num,
1,
_INTERFACE_CLASS,
_INTERFACE_SUBCLASS_NONE,
_INTERFACE_SUBCLASS_NONE
if self.protocol == _INTERFACE_PROTOCOL_NONE
else _INTERFACE_SUBCLASS_BOOT,
self.protocol,
len(strs) if self.interface_str else 0,
)
Expand All@@ -148,7 +152,12 @@ def desc_cfg(self, desc, itf_num, ep_num, strs):
desc.endpoint(self._int_ep, "interrupt", 8, 8)

self.idle_rate = 0
self.protocol = 0

# This variable is reused to track boot protocol status.
# 0 for boot protocol, 1 for report protocol
# According to Device Class Definition for Human Interface Devices (HID) v1.11
# Appendix F.5, the device comes up in non-boot mode by default.
self.protocol = 1

def num_eps(self):
return 1
Expand DownExpand Up@@ -197,6 +206,8 @@ def on_interface_control_xfer(self, stage, request):
if desc_type == _DESC_HID_TYPE:
return self.get_hid_descriptor()
if desc_type == _DESC_REPORT_TYPE:
# Reset to report protocol when report descriptor is requested
self.protocol = 1
return self.report_descriptor
elif req_type == _REQ_TYPE_CLASS:
# HID Spec p50: 7.2 Class-Specific Requests
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp