usb-device-hid: MouseInterface reports bInterfaceProtocol 1 (keyboard) instead of 2

Aperta Adatta ai principianti
#1,176 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@Duhan07 ci sta già lavorando.

Dal 19/11/2026.

  • #1177 di @Duhan07 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
embedded-iot

Direzione di ricerca

Leggi l’implementazione di HIDInterface di usb-device-hid, in particolare desc_cfg(), e segui come Device.config() la richiama per entrambi i passaggi del descrittore. La riproduzione nell’issue mostra il byte del descrittore di interfaccia che differisce; conferma la correzione eseguendo di nuovo lo snippet fornito e verificando che il byte del protocollo sia 02.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

MouseInterface is enumerated as a boot keyboard, its interface descriptor has bInterfaceSubClass 1 and bInterfaceProtocol 1, but it should be protocol 2 (mouse).

Cause

HIDInterface.protocol stores both the descriptor protocol and the runtime protocol mode. desc_cfg() ends with self.protocol = 1 (report mode), and Device.config() calls desc_cfg() twice (once to measure the length, once to write). So the second call writes 1 for every boot interface.

Reproduction
  • MicroPython v1.29.0, ESP32_GENERIC_S3 (ESP32-S3, 2 MB PSRAM)
  • usb-device-hid 0.2.0, usb-device-mouse, installed with mip
from usb.device.core import Descriptor
from usb.device.mouse import MouseInterface

m = MouseInterface()
d = Descriptor(None)        # pass 1, as in Device.config()
m.desc_cfg(d, 0, 0, [])
buf = bytearray(d.o)
d = Descriptor(buf)          # pass 2
m.desc_cfg(d, 3, 1, [])
print(" ".join("%02x" % b for b in buf[:9]))

Output: 09 04 03 00 01 03 01 01 00 (last-but-one byte should be 02). macOS ioreg shows the same for interface "MicroPython Mouse".

Suggested fix

Store the descriptor value in a separate attribute (e.g. interface_protocol) and keep protocol for the runtime mode. I have tested this on the board.

Lingua principale
Python
Stelle
2.9k
Fork
1.1k
Merge medio
3g 21h
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di micropython/micropython-lib

Tutte le issue di micropython/micropython-lib

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.