diff options
author | Anssi Hannula <anssi.hannula@gmail.com> | 2006-07-19 01:41:09 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2006-07-19 01:41:09 -0400 |
commit | ff462551235d8d7d843a005950bc90924fcedede (patch) | |
tree | 638ca70b8d1572b6f3738cfcb87355e34d006317 /include/linux/uinput.h | |
parent | dc76c912145febae8b62746d6f93e5edae342c9d (diff) |
Input: uinput - switch to the new FF interface
The userspace interface of the force feedback part is changed and
documentation in uinput.h is updated accordingly. MODULE_VERSION
is also incremented to reflect the revision.
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'include/linux/uinput.h')
-rw-r--r-- | include/linux/uinput.h | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/include/linux/uinput.h b/include/linux/uinput.h index 7168302f9844..1fd61eeed664 100644 --- a/include/linux/uinput.h +++ b/include/linux/uinput.h | |||
@@ -22,12 +22,18 @@ | |||
22 | * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org> | 22 | * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org> |
23 | * | 23 | * |
24 | * Changes/Revisions: | 24 | * Changes/Revisions: |
25 | * 0.3 24/05/2006 (Anssi Hannula <anssi.hannulagmail.com>) | ||
26 | * - update ff support for the changes in kernel interface | ||
27 | * - add UINPUT_VERSION | ||
25 | * 0.2 16/10/2004 (Micah Dowty <micah@navi.cx>) | 28 | * 0.2 16/10/2004 (Micah Dowty <micah@navi.cx>) |
26 | * - added force feedback support | 29 | * - added force feedback support |
27 | * - added UI_SET_PHYS | 30 | * - added UI_SET_PHYS |
28 | * 0.1 20/06/2002 | 31 | * 0.1 20/06/2002 |
29 | * - first public version | 32 | * - first public version |
30 | */ | 33 | */ |
34 | |||
35 | #define UINPUT_VERSION 3 | ||
36 | |||
31 | #ifdef __KERNEL__ | 37 | #ifdef __KERNEL__ |
32 | #define UINPUT_MINOR 223 | 38 | #define UINPUT_MINOR 223 |
33 | #define UINPUT_NAME "uinput" | 39 | #define UINPUT_NAME "uinput" |
@@ -45,7 +51,10 @@ struct uinput_request { | |||
45 | 51 | ||
46 | union { | 52 | union { |
47 | int effect_id; | 53 | int effect_id; |
48 | struct ff_effect* effect; | 54 | struct { |
55 | struct ff_effect *effect; | ||
56 | struct ff_effect *old; | ||
57 | } upload; | ||
49 | } u; | 58 | } u; |
50 | }; | 59 | }; |
51 | 60 | ||
@@ -58,6 +67,7 @@ struct uinput_device { | |||
58 | unsigned char head; | 67 | unsigned char head; |
59 | unsigned char tail; | 68 | unsigned char tail; |
60 | struct input_event buff[UINPUT_BUFFER_SIZE]; | 69 | struct input_event buff[UINPUT_BUFFER_SIZE]; |
70 | int ff_effects_max; | ||
61 | 71 | ||
62 | struct uinput_request *requests[UINPUT_NUM_REQUESTS]; | 72 | struct uinput_request *requests[UINPUT_NUM_REQUESTS]; |
63 | wait_queue_head_t requests_waitq; | 73 | wait_queue_head_t requests_waitq; |
@@ -69,6 +79,7 @@ struct uinput_ff_upload { | |||
69 | int request_id; | 79 | int request_id; |
70 | int retval; | 80 | int retval; |
71 | struct ff_effect effect; | 81 | struct ff_effect effect; |
82 | struct ff_effect old; | ||
72 | }; | 83 | }; |
73 | 84 | ||
74 | struct uinput_ff_erase { | 85 | struct uinput_ff_erase { |
@@ -98,33 +109,33 @@ struct uinput_ff_erase { | |||
98 | #define UI_BEGIN_FF_ERASE _IOWR(UINPUT_IOCTL_BASE, 202, struct uinput_ff_erase) | 109 | #define UI_BEGIN_FF_ERASE _IOWR(UINPUT_IOCTL_BASE, 202, struct uinput_ff_erase) |
99 | #define UI_END_FF_ERASE _IOW(UINPUT_IOCTL_BASE, 203, struct uinput_ff_erase) | 110 | #define UI_END_FF_ERASE _IOW(UINPUT_IOCTL_BASE, 203, struct uinput_ff_erase) |
100 | 111 | ||
101 | /* To write a force-feedback-capable driver, the upload_effect | 112 | /* |
113 | * To write a force-feedback-capable driver, the upload_effect | ||
102 | * and erase_effect callbacks in input_dev must be implemented. | 114 | * and erase_effect callbacks in input_dev must be implemented. |
103 | * The uinput driver will generate a fake input event when one of | 115 | * The uinput driver will generate a fake input event when one of |
104 | * these callbacks are invoked. The userspace code then uses | 116 | * these callbacks are invoked. The userspace code then uses |
105 | * ioctls to retrieve additional parameters and send the return code. | 117 | * ioctls to retrieve additional parameters and send the return code. |
106 | * The callback blocks until this return code is sent. | 118 | * The callback blocks until this return code is sent. |
107 | * | 119 | * |
108 | * The described callback mechanism is only used if EV_FF is set. | 120 | * The described callback mechanism is only used if ff_effects_max |
109 | * Otherwise, default implementations of upload_effect and erase_effect | 121 | * is set. |
110 | * are used. | ||
111 | * | 122 | * |
112 | * To implement upload_effect(): | 123 | * To implement upload_effect(): |
113 | * 1. Wait for an event with type==EV_UINPUT and code==UI_FF_UPLOAD. | 124 | * 1. Wait for an event with type == EV_UINPUT and code == UI_FF_UPLOAD. |
114 | * A request ID will be given in 'value'. | 125 | * A request ID will be given in 'value'. |
115 | * 2. Allocate a uinput_ff_upload struct, fill in request_id with | 126 | * 2. Allocate a uinput_ff_upload struct, fill in request_id with |
116 | * the 'value' from the EV_UINPUT event. | 127 | * the 'value' from the EV_UINPUT event. |
117 | * 3. Issue a UI_BEGIN_FF_UPLOAD ioctl, giving it the | 128 | * 3. Issue a UI_BEGIN_FF_UPLOAD ioctl, giving it the |
118 | * uinput_ff_upload struct. It will be filled in with the | 129 | * uinput_ff_upload struct. It will be filled in with the |
119 | * ff_effect passed to upload_effect(). | 130 | * ff_effects passed to upload_effect(). |
120 | * 4. Perform the effect upload, and place the modified ff_effect | 131 | * 4. Perform the effect upload, and place a return code back into |
121 | * and a return code back into the uinput_ff_upload struct. | 132 | the uinput_ff_upload struct. |
122 | * 5. Issue a UI_END_FF_UPLOAD ioctl, also giving it the | 133 | * 5. Issue a UI_END_FF_UPLOAD ioctl, also giving it the |
123 | * uinput_ff_upload_effect struct. This will complete execution | 134 | * uinput_ff_upload_effect struct. This will complete execution |
124 | * of our upload_effect() handler. | 135 | * of our upload_effect() handler. |
125 | * | 136 | * |
126 | * To implement erase_effect(): | 137 | * To implement erase_effect(): |
127 | * 1. Wait for an event with type==EV_UINPUT and code==UI_FF_ERASE. | 138 | * 1. Wait for an event with type == EV_UINPUT and code == UI_FF_ERASE. |
128 | * A request ID will be given in 'value'. | 139 | * A request ID will be given in 'value'. |
129 | * 2. Allocate a uinput_ff_erase struct, fill in request_id with | 140 | * 2. Allocate a uinput_ff_erase struct, fill in request_id with |
130 | * the 'value' from the EV_UINPUT event. | 141 | * the 'value' from the EV_UINPUT event. |
@@ -133,13 +144,13 @@ struct uinput_ff_erase { | |||
133 | * effect ID passed to erase_effect(). | 144 | * effect ID passed to erase_effect(). |
134 | * 4. Perform the effect erasure, and place a return code back | 145 | * 4. Perform the effect erasure, and place a return code back |
135 | * into the uinput_ff_erase struct. | 146 | * into the uinput_ff_erase struct. |
136 | * and a return code back into the uinput_ff_erase struct. | ||
137 | * 5. Issue a UI_END_FF_ERASE ioctl, also giving it the | 147 | * 5. Issue a UI_END_FF_ERASE ioctl, also giving it the |
138 | * uinput_ff_erase_effect struct. This will complete execution | 148 | * uinput_ff_erase_effect struct. This will complete execution |
139 | * of our erase_effect() handler. | 149 | * of our erase_effect() handler. |
140 | */ | 150 | */ |
141 | 151 | ||
142 | /* This is the new event type, used only by uinput. | 152 | /* |
153 | * This is the new event type, used only by uinput. | ||
143 | * 'code' is UI_FF_UPLOAD or UI_FF_ERASE, and 'value' | 154 | * 'code' is UI_FF_UPLOAD or UI_FF_ERASE, and 'value' |
144 | * is the unique request ID. This number was picked | 155 | * is the unique request ID. This number was picked |
145 | * arbitrarily, above EV_MAX (since the input system | 156 | * arbitrarily, above EV_MAX (since the input system |