uhid.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. enum uhid_event_type {
  21. UHID_CREATE,
  22. UHID_DESTROY,
  23. UHID_START,
  24. UHID_STOP,
  25. UHID_OPEN,
  26. UHID_CLOSE,
  27. UHID_OUTPUT,
  28. UHID_OUTPUT_EV,
  29. UHID_INPUT,
  30. UHID_FEATURE,
  31. UHID_FEATURE_ANSWER,
  32. };
  33. struct uhid_create_req {
  34. __u8 name[128];
  35. __u8 phys[64];
  36. __u8 uniq[64];
  37. __u8 __user *rd_data;
  38. __u16 rd_size;
  39. __u16 bus;
  40. __u32 vendor;
  41. __u32 product;
  42. __u32 version;
  43. __u32 country;
  44. } __attribute__((__packed__));
  45. #define UHID_DATA_MAX 4096
  46. enum uhid_report_type {
  47. UHID_FEATURE_REPORT,
  48. UHID_OUTPUT_REPORT,
  49. UHID_INPUT_REPORT,
  50. };
  51. struct uhid_input_req {
  52. __u8 data[UHID_DATA_MAX];
  53. __u16 size;
  54. } __attribute__((__packed__));
  55. struct uhid_output_req {
  56. __u8 data[UHID_DATA_MAX];
  57. __u16 size;
  58. __u8 rtype;
  59. } __attribute__((__packed__));
  60. struct uhid_output_ev_req {
  61. __u16 type;
  62. __u16 code;
  63. __s32 value;
  64. } __attribute__((__packed__));
  65. struct uhid_feature_req {
  66. __u32 id;
  67. __u8 rnum;
  68. __u8 rtype;
  69. } __attribute__((__packed__));
  70. struct uhid_feature_answer_req {
  71. __u32 id;
  72. __u16 err;
  73. __u16 size;
  74. __u8 data[UHID_DATA_MAX];
  75. };
  76. struct uhid_event {
  77. __u32 type;
  78. union {
  79. struct uhid_create_req create;
  80. struct uhid_input_req input;
  81. struct uhid_output_req output;
  82. struct uhid_output_ev_req output_ev;
  83. struct uhid_feature_req feature;
  84. struct uhid_feature_answer_req feature_answer;
  85. } u;
  86. } __attribute__((__packed__));
  87. #endif /* __UHID_H_ */