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