usbhid.h 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. /* USB HID boot devices: mouse + keyboard.
  2. *
  3. * A single manager owns the scan/hotplug state for both interrupt-IN
  4. * endpoints (slot 0 = mouse, slot 1 = keyboard): find, configure, put into
  5. * boot protocol and keep each endpoint armed. The mouse reports are handed
  6. * back to mouse.c; keyboard reports are decoded into PS/2 set-1 scancodes
  7. * and injected into the regular input queue (io_inject_scancode), so the
  8. * terminal/WM see them exactly like a PS/2 keyboard. */
  9. #ifndef USBHID_H
  10. #define USBHID_H
  11. /* Bring up the USB subsystem and look for a boot mouse/keyboard. Safe to
  12. call when no controller or device exists; the hotplug watcher keeps
  13. running then. */
  14. void usbhid_init(void);
  15. /* Service both endpoints (called once per WM loop iteration from
  16. mouse_poll_update()). Returns 1 when a mouse report is available and
  17. fills buttons/dx/dy (PS/2 sign convention: dy > 0 = up) plus scroll in
  18. pixels (currently always 0: boot-protocol mice have no wheel field). */
  19. int usbhid_poll(unsigned int *buttons, int *dx, int *dy, int *scroll);
  20. int usbhid_mouse_attached(void);
  21. int usbhid_keyboard_attached(void);
  22. /* For `mouseinfo`: controller instance, device address, endpoint number,
  23. endpoint max packet size and the low-speed flag. */
  24. void usbhid_get_info(unsigned int *ctrl, unsigned int *addr,
  25. unsigned int *ep, unsigned int *mps, int *low);
  26. #endif