ucmd_mouseinfo.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* mouseinfo: ring-3 command. Mouse hardware/protocol info. */
  2. #include "ucmd_lib.h"
  3. static void put_hex8(unsigned int x)
  4. {
  5. static const char hex[] = "0123456789ABCDEF";
  6. u_putc(hex[(x >> 4) & 0xF]);
  7. u_putc(hex[x & 0xF]);
  8. }
  9. void _start(const char *arg)
  10. {
  11. struct sys_mouseinfo m;
  12. (void)arg;
  13. if (u_syscall1(SYS_MOUSEINFO, (int)&m) != 1) {
  14. u_puts("mouse present no\n");
  15. u_exit(0);
  16. }
  17. u_puts("mouse present yes\n");
  18. if (m.ps2) {
  19. u_puts("mouse ps/2 id 0x");
  20. put_hex8(m.ps2_id & 0xFFu);
  21. u_putc('\n');
  22. u_puts("mouse protocol ");
  23. if ((m.ps2_id & 0xFFu) == 0x03)
  24. u_puts("intellimouse (wheel)\n");
  25. else if ((m.ps2_id & 0xFFu) == 0x04)
  26. u_puts("intellimouse explorer (5-button)\n");
  27. else
  28. u_puts("standard ps/2\n");
  29. u_puts("mouse packet bytes ");
  30. u_putdec(m.ps2_packet_size);
  31. u_putc('\n');
  32. u_puts("mouse streaming ");
  33. u_puts(m.ps2_streaming ? "on\n" : "off\n");
  34. }
  35. if (m.usb) {
  36. u_puts("mouse usb ");
  37. u_puts(m.hcd);
  38. u_puts(" hid boot\n");
  39. u_puts("mouse usb ctrl ");
  40. u_putdec(m.usb_ctrl);
  41. u_puts(" addr ");
  42. u_putdec(m.usb_addr);
  43. u_puts(" ep 0x");
  44. put_hex8(0x80u | m.usb_ep);
  45. u_putc('\n');
  46. u_puts("mouse usb mps ");
  47. u_putdec(m.usb_mps);
  48. u_puts(m.usb_low ? " (low speed)\n" : " (full speed)\n");
  49. }
  50. if (m.touchpad) {
  51. u_puts("mouse touchpad elan ");
  52. u_put_hex2(m.tp_vendor >> 8);
  53. u_put_hex2(m.tp_vendor);
  54. u_putc(':');
  55. u_put_hex2(m.tp_product >> 8);
  56. u_put_hex2(m.tp_product);
  57. u_putc('\n');
  58. }
  59. u_puts("mouse usb keyboard ");
  60. u_puts(m.usb_keyboard ? "yes\n" : "no\n");
  61. u_puts("mouse cursor ");
  62. u_puts(m.cursor_visible ? "visible\n" : "hidden\n");
  63. u_puts("mouse cursor backend ");
  64. u_puts(m.backend);
  65. u_putc('\n');
  66. u_exit(0);
  67. }