uhid.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #ifndef __UHID_H_
  2. #define __UHID_H_
  3. /*
  4. * User-space I/O driver support for HID subsystem
  5. * Copyright (c) 2012 David Herrmann
  6. */
  7. /*
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the Free
  10. * Software Foundation; either version 2 of the License, or (at your option)
  11. * any later version.
  12. */
  13. /*
  14. * Public header for user-space communication. We try to keep every structure
  15. * aligned but to be safe we also use __attribute__((__packed__)). Therefore,
  16. * the communication should be ABI compatible even between architectures.
  17. */
  18. #include <linux/input.h>
  19. #include <linux/types.h>
  20. #include <linux/hid.h>
  21. enum uhid_event_type {
  22. UHID_CREATE,
  23. UHID_DESTROY,
  24. UHID_START,
  25. UHID_STOP,
  26. UHID_OPEN,
  27. UHID_CLOSE,
  28. UHID_OUTPUT,
  29. UHID_OUTPUT_EV, /* obsolete! */
  30. UHID_INPUT,
  31. UHID_FEATURE,
  32. UHID_FEATURE_ANSWER,
  33. UHID_CREATE2,
  34. UHID_INPUT2,
  35. };
  36. struct uhid_create_req {
  37. __u8 name[128];
  38. __u8 phys[64];
  39. __u8 uniq[64];
  40. __u8 __user *rd_data;
  41. __u16 rd_size;
  42. __u16 bus;
  43. __u32 vendor;
  44. __u32 product;
  45. __u32 version;
  46. __u32 country;
  47. } __attribute__((__packed__));
  48. struct uhid_create2_req {
  49. __u8 name[128];
  50. __u8 phys[64];
  51. __u8 uniq[64];
  52. __u16 rd_size;
  53. __u16 bus;
  54. __u32 vendor;
  55. __u32 product;
  56. __u32 version;
  57. __u32 country;
  58. __u8 rd_data[HID_MAX_DESCRIPTOR_SIZE];
  59. } __attribute__((__packed__));
  60. #define UHID_DATA_MAX 4096
  61. enum uhid_report_type {
  62. UHID_FEATURE_REPORT,
  63. UHID_OUTPUT_REPORT,
  64. UHID_INPUT_REPORT,
  65. };
  66. struct uhid_input_req {
  67. __u8 data[UHID_DATA_MAX];
  68. __u16 size;
  69. } __attribute__((__packed__));
  70. struct uhid_input2_req {
  71. __u16 size;
  72. __u8 data[UHID_DATA_MAX];
  73. } __attribute__((__packed__));
  74. struct uhid_output_req {
  75. __u8 data[UHID_DATA_MAX];
  76. __u16 size;
  77. __u8 rtype;
  78. } __attribute__((__packed__));
  79. /* Obsolete! Newer kernels will no longer send these events but instead convert
  80. * it into raw output reports via UHID_OUTPUT. */
  81. struct uhid_output_ev_req {
  82. __u16 type;
  83. __u16 code;
  84. __s32 value;
  85. } __attribute__((__packed__));
  86. struct uhid_feature_req {
  87. __u32 id;
  88. __u8 rnum;
  89. __u8 rtype;
  90. } __attribute__((__packed__));
  91. struct uhid_feature_answer_req {
  92. __u32 id;
  93. __u16 err;
  94. __u16 size;
  95. __u8 data[UHID_DATA_MAX];
  96. } __attribute__((__packed__));
  97. struct uhid_event {
  98. __u32 type;
  99. union {
  100. struct uhid_create_req create;
  101. struct uhid_input_req input;
  102. struct uhid_output_req output;
  103. struct uhid_output_ev_req output_ev;
  104. struct uhid_feature_req feature;
  105. struct uhid_feature_answer_req feature_answer;
  106. struct uhid_create2_req create2;
  107. struct uhid_input2_req input2;
  108. } u;
  109. } __attribute__((__packed__));
  110. #endif /* __UHID_H_ */