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 | 5e87a36 | 2012-06-10 15:16:19 +0200 | [diff] [blame] | 30 | UHID_INPUT, |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 31 | }; |
| 32 | |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 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 | |
| 40 | __u16 bus; |
| 41 | __u32 vendor; |
| 42 | __u32 product; |
| 43 | __u32 version; |
| 44 | __u32 country; |
| 45 | } __attribute__((__packed__)); |
| 46 | |
David Herrmann | 5e87a36 | 2012-06-10 15:16:19 +0200 | [diff] [blame] | 47 | #define UHID_DATA_MAX 4096 |
| 48 | |
| 49 | struct uhid_input_req { |
| 50 | __u8 data[UHID_DATA_MAX]; |
| 51 | __u16 size; |
| 52 | } __attribute__((__packed__)); |
| 53 | |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 54 | struct uhid_event { |
| 55 | __u32 type; |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 56 | |
| 57 | union { |
| 58 | struct uhid_create_req create; |
David Herrmann | 5e87a36 | 2012-06-10 15:16:19 +0200 | [diff] [blame] | 59 | struct uhid_input_req input; |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 60 | } u; |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 61 | } __attribute__((__packed__)); |
| 62 | |
| 63 | #endif /* __UHID_H_ */ |