schedule_int_transfer 第 6 形参原为 toggle_ptr: uint8*,却直接转发给 _td_set_token 的值形参 toggle: uint8,命中指针隐式转整数禁令(uhci.vp:160 CastError)。改为 toggle: uint8 值传递,四个调用点去掉取地址,buf 仍以 & 传。同时纳入工作区既有的指针语法迁移:t.CPtr 改 X*、c.Addr 改 &、c.Set(c.Deref(...)) 改 *p = v。
38 lines
974 B
Plaintext
38 lines
974 B
Plaintext
import drivers.usb.usb as usb
|
|
|
|
|
|
define HID_BOOT_PROTOCOL = 0
|
|
define HID_REPORT_PROTOCOL = 1
|
|
|
|
define HID_KBD_REPORT_SIZE = 8
|
|
define HID_MOUSE_REPORT_SIZE = 4
|
|
|
|
class hid_kbd_report:
|
|
modifier: uint8
|
|
reserved: uint8
|
|
keycode: [6]uint8
|
|
|
|
class hid_mouse_report:
|
|
buttons: uint8
|
|
dx: int8
|
|
dy: int8
|
|
wheel: int8
|
|
|
|
def init_keyboard(dev: usb.usb_device*) -> int:
|
|
if dev.iface_class != 0x03: return -1
|
|
if dev.iface_protocol != 0x01: return -2
|
|
if dev.ep_in == 0: return -3
|
|
return 0
|
|
|
|
def init_mouse(dev: usb.usb_device*) -> int:
|
|
if dev.iface_class != 0x03: return -1
|
|
if dev.iface_protocol != 0x02: return -2
|
|
if dev.ep_in == 0: return -3
|
|
return 0
|
|
|
|
def read_keyboard(dev: usb.usb_device*, report: hid_kbd_report*) -> int:
|
|
return usb.read_interrupt(dev, &report) # 存疑
|
|
|
|
def read_mouse(dev: usb.usb_device*, report: hid_mouse_report*) -> int:
|
|
return usb.read_interrupt(dev, &report)
|