usbhid.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  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. A mouse whose report descriptor has a wheel runs in report
  20. protocol and maps one wheel notch to 48 px; Logitech DJ reports use the
  21. same scale. */
  22. int usbhid_poll(unsigned int *buttons, int *dx, int *dy, int *scroll);
  23. int usbhid_mouse_attached(void);
  24. int usbhid_keyboard_attached(void);
  25. /* For `mouseinfo`: controller instance, device address, endpoint number,
  26. endpoint max packet size, the low-speed flag, the report-protocol mode and
  27. whether that layout has a wheel. */
  28. void usbhid_get_info(unsigned int *ctrl, unsigned int *addr,
  29. unsigned int *ep, unsigned int *mps, int *low,
  30. int *report_mode, int *wheel);
  31. #endif