usbhid.h 1.4 KB

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