uhid.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_EV,
  28. UHID_INPUT,
  29. };
  30. struct uhid_create_req {
  31. __u8 name[128];
  32. __u8 phys[64];
  33. __u8 uniq[64];
  34. __u8 __user *rd_data;
  35. __u16 rd_size;
  36. __u16 bus;
  37. __u32 vendor;
  38. __u32 product;
  39. __u32 version;
  40. __u32 country;
  41. } __attribute__((__packed__));
  42. #define UHID_DATA_MAX 4096
  43. struct uhid_input_req {
  44. __u8 data[UHID_DATA_MAX];
  45. __u16 size;
  46. } __attribute__((__packed__));
  47. struct uhid_output_ev_req {
  48. __u16 type;
  49. __u16 code;
  50. __s32 value;
  51. } __attribute__((__packed__));
  52. struct uhid_event {
  53. __u32 type;
  54. union {
  55. struct uhid_create_req create;
  56. struct uhid_input_req input;
  57. struct uhid_output_ev_req output_ev;
  58. } u;
  59. } __attribute__((__packed__));
  60. #endif /* __UHID_H_ */