blob: 0a4487d3fb1ee43d436c37712f76403006c86dc4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * User level driver support for input subsystem
3 *
4 * Heavily based on evdev.c by Vojtech Pavlik
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
Dmitry Torokhov221979a2006-02-19 00:22:36 -050021 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 * Changes/Revisions:
Anssi Hannulaff462552006-07-19 01:41:09 -040023 * 0.3 24/05/2006 (Anssi Hannula <anssi.hannulagmail.com>)
24 * - update ff support for the changes in kernel interface
25 * - add UINPUT_VERSION
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 * 0.2 16/10/2004 (Micah Dowty <micah@navi.cx>)
27 * - added force feedback support
28 * - added UI_SET_PHYS
29 * 0.1 20/06/2002
30 * - first public version
31 */
David Howells607ca462012-10-13 10:46:48 +010032#ifndef __UINPUT_H_
33#define __UINPUT_H_
Anssi Hannulaff462552006-07-19 01:41:09 -040034
David Howells607ca462012-10-13 10:46:48 +010035#include <uapi/linux/uinput.h>
Mike Frysingera830df32007-05-03 00:55:34 -040036
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#define UINPUT_NAME "uinput"
38#define UINPUT_BUFFER_SIZE 16
39#define UINPUT_NUM_REQUESTS 16
40
Dmitry Torokhov29506412005-11-20 00:51:22 -050041enum uinput_state { UIST_NEW_DEVICE, UIST_SETUP_COMPLETE, UIST_CREATED };
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43struct uinput_request {
Dmitry Torokhovc5b35332012-07-29 22:48:32 -070044 unsigned int id;
45 unsigned int code; /* UI_FF_UPLOAD, UI_FF_ERASE */
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47 int retval;
Dmitry Torokhov0048e602005-06-30 00:48:14 -050048 struct completion done;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50 union {
Dmitry Torokhovc5b35332012-07-29 22:48:32 -070051 unsigned int effect_id;
Anssi Hannulaff462552006-07-19 01:41:09 -040052 struct {
53 struct ff_effect *effect;
54 struct ff_effect *old;
55 } upload;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 } u;
57};
58
59struct uinput_device {
60 struct input_dev *dev;
Dmitry Torokhov221979a2006-02-19 00:22:36 -050061 struct mutex mutex;
Dmitry Torokhov29506412005-11-20 00:51:22 -050062 enum uinput_state state;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 wait_queue_head_t waitq;
Dmitry Torokhov29506412005-11-20 00:51:22 -050064 unsigned char ready;
65 unsigned char head;
66 unsigned char tail;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 struct input_event buff[UINPUT_BUFFER_SIZE];
Dan Carpenter05be8b82011-10-12 21:05:53 -070068 unsigned int ff_effects_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70 struct uinput_request *requests[UINPUT_NUM_REQUESTS];
71 wait_queue_head_t requests_waitq;
Dmitry Torokhov0048e602005-06-30 00:48:14 -050072 spinlock_t requests_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073};
Linus Torvalds1da177e2005-04-16 15:20:36 -070074#endif /* __UINPUT_H_ */