- devfs.vp: string.split 传 PATH_BUFFER_SIZE(配合 split 新增容量参数) - fat32_types.vp: lfn_extract 越界钳制(base+i > MAX_LFN 返回 -1) - sheet.vp: gfx.Renderer 实参修正为 (fb, zb, w, h)(原单参导致 w/h=0 渲染空操作) - 同批包含 VKernel 其余既有移植改动与 vpsdk/Apps/Libs 工作区内容
38 lines
1.1 KiB
Plaintext
38 lines
1.1 KiB
Plaintext
import t, c
|
|
import drivers.usb.usb as usb
|
|
|
|
HID_BOOT_PROTOCOL: t.CDefine = 0
|
|
HID_REPORT_PROTOCOL: t.CDefine = 1
|
|
|
|
HID_KBD_REPORT_SIZE: t.CDefine = 8
|
|
HID_MOUSE_REPORT_SIZE: t.CDefine = 4
|
|
|
|
class hid_kbd_report(t.CStruct):
|
|
modifier: uint8
|
|
reserved: uint8
|
|
keycode: t.CArray[uint8, 6]
|
|
|
|
class hid_mouse_report(t.CStruct):
|
|
buttons: uint8
|
|
dx: int8
|
|
dy: int8
|
|
wheel: int8
|
|
|
|
def init_keyboard(dev: usb.usb_device | t.CPtr) -> 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 | t.CPtr) -> 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 | t.CPtr, report: hid_kbd_report | t.CPtr) -> int:
|
|
return usb.read_interrupt(dev, c.Addr(report))
|
|
|
|
def read_mouse(dev: usb.usb_device | t.CPtr, report: hid_mouse_report | t.CPtr) -> int:
|
|
return usb.read_interrupt(dev, c.Addr(report))
|