root / hw / usb-wacom.c @ 0157644c
History | View | Annotate | Download (10 kB)
1 | f6d2a316 | balrog | /*
|
---|---|---|---|
2 | f6d2a316 | balrog | * Wacom PenPartner USB tablet emulation.
|
3 | f6d2a316 | balrog | *
|
4 | f6d2a316 | balrog | * Copyright (c) 2006 Openedhand Ltd.
|
5 | f6d2a316 | balrog | * Author: Andrzej Zaborowski <balrog@zabor.org>
|
6 | f6d2a316 | balrog | *
|
7 | f6d2a316 | balrog | * Based on hw/usb-hid.c:
|
8 | f6d2a316 | balrog | * Copyright (c) 2005 Fabrice Bellard
|
9 | f6d2a316 | balrog | *
|
10 | f6d2a316 | balrog | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
11 | f6d2a316 | balrog | * of this software and associated documentation files (the "Software"), to deal
|
12 | f6d2a316 | balrog | * in the Software without restriction, including without limitation the rights
|
13 | f6d2a316 | balrog | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14 | f6d2a316 | balrog | * copies of the Software, and to permit persons to whom the Software is
|
15 | f6d2a316 | balrog | * furnished to do so, subject to the following conditions:
|
16 | f6d2a316 | balrog | *
|
17 | f6d2a316 | balrog | * The above copyright notice and this permission notice shall be included in
|
18 | f6d2a316 | balrog | * all copies or substantial portions of the Software.
|
19 | f6d2a316 | balrog | *
|
20 | f6d2a316 | balrog | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
21 | f6d2a316 | balrog | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
22 | f6d2a316 | balrog | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
23 | f6d2a316 | balrog | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
24 | f6d2a316 | balrog | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
25 | f6d2a316 | balrog | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
26 | f6d2a316 | balrog | * THE SOFTWARE.
|
27 | f6d2a316 | balrog | */
|
28 | 87ecb68b | pbrook | #include "hw.h" |
29 | 87ecb68b | pbrook | #include "console.h" |
30 | 87ecb68b | pbrook | #include "usb.h" |
31 | 037a5203 | Gerd Hoffmann | #include "usb-desc.h" |
32 | f6d2a316 | balrog | |
33 | f6d2a316 | balrog | /* Interface requests */
|
34 | f6d2a316 | balrog | #define WACOM_GET_REPORT 0x2101 |
35 | f6d2a316 | balrog | #define WACOM_SET_REPORT 0x2109 |
36 | f6d2a316 | balrog | |
37 | f6d2a316 | balrog | /* HID interface requests */
|
38 | f6d2a316 | balrog | #define HID_GET_REPORT 0xa101 |
39 | f6d2a316 | balrog | #define HID_GET_IDLE 0xa102 |
40 | f6d2a316 | balrog | #define HID_GET_PROTOCOL 0xa103 |
41 | f6d2a316 | balrog | #define HID_SET_IDLE 0x210a |
42 | f6d2a316 | balrog | #define HID_SET_PROTOCOL 0x210b |
43 | f6d2a316 | balrog | |
44 | f6d2a316 | balrog | typedef struct USBWacomState { |
45 | f6d2a316 | balrog | USBDevice dev; |
46 | f6d2a316 | balrog | QEMUPutMouseEntry *eh_entry; |
47 | f6d2a316 | balrog | int dx, dy, dz, buttons_state;
|
48 | f6d2a316 | balrog | int x, y;
|
49 | f6d2a316 | balrog | int mouse_grabbed;
|
50 | f6d2a316 | balrog | enum {
|
51 | f6d2a316 | balrog | WACOM_MODE_HID = 1,
|
52 | f6d2a316 | balrog | WACOM_MODE_WACOM = 2,
|
53 | f6d2a316 | balrog | } mode; |
54 | 2ca2078e | François Revol | uint8_t idle; |
55 | 2ca2078e | François Revol | int changed;
|
56 | f6d2a316 | balrog | } USBWacomState; |
57 | f6d2a316 | balrog | |
58 | 037a5203 | Gerd Hoffmann | enum {
|
59 | 037a5203 | Gerd Hoffmann | STR_MANUFACTURER = 1,
|
60 | 037a5203 | Gerd Hoffmann | STR_PRODUCT, |
61 | 037a5203 | Gerd Hoffmann | STR_SERIALNUMBER, |
62 | 037a5203 | Gerd Hoffmann | }; |
63 | f6d2a316 | balrog | |
64 | 037a5203 | Gerd Hoffmann | static const USBDescStrings desc_strings = { |
65 | 037a5203 | Gerd Hoffmann | [STR_MANUFACTURER] = "QEMU " QEMU_VERSION,
|
66 | 037a5203 | Gerd Hoffmann | [STR_PRODUCT] = "Wacom PenPartner",
|
67 | 037a5203 | Gerd Hoffmann | [STR_SERIALNUMBER] = "1",
|
68 | 037a5203 | Gerd Hoffmann | }; |
69 | f6d2a316 | balrog | |
70 | 037a5203 | Gerd Hoffmann | static const USBDescIface desc_iface_wacom = { |
71 | 037a5203 | Gerd Hoffmann | .bInterfaceNumber = 0,
|
72 | 037a5203 | Gerd Hoffmann | .bNumEndpoints = 1,
|
73 | 037a5203 | Gerd Hoffmann | .bInterfaceClass = USB_CLASS_HID, |
74 | 037a5203 | Gerd Hoffmann | .bInterfaceSubClass = 0x01, /* boot */ |
75 | 037a5203 | Gerd Hoffmann | .bInterfaceProtocol = 0x02,
|
76 | 037a5203 | Gerd Hoffmann | .ndesc = 1,
|
77 | 037a5203 | Gerd Hoffmann | .descs = (USBDescOther[]) { |
78 | 037a5203 | Gerd Hoffmann | { |
79 | 037a5203 | Gerd Hoffmann | /* HID descriptor */
|
80 | 037a5203 | Gerd Hoffmann | .data = (uint8_t[]) { |
81 | 037a5203 | Gerd Hoffmann | 0x09, /* u8 bLength */ |
82 | 037a5203 | Gerd Hoffmann | 0x21, /* u8 bDescriptorType */ |
83 | 037a5203 | Gerd Hoffmann | 0x01, 0x10, /* u16 HID_class */ |
84 | 037a5203 | Gerd Hoffmann | 0x00, /* u8 country_code */ |
85 | 037a5203 | Gerd Hoffmann | 0x01, /* u8 num_descriptors */ |
86 | 037a5203 | Gerd Hoffmann | 0x22, /* u8 type: Report */ |
87 | 037a5203 | Gerd Hoffmann | 0x6e, 0, /* u16 len */ |
88 | 037a5203 | Gerd Hoffmann | }, |
89 | 037a5203 | Gerd Hoffmann | }, |
90 | 037a5203 | Gerd Hoffmann | }, |
91 | 037a5203 | Gerd Hoffmann | .eps = (USBDescEndpoint[]) { |
92 | 037a5203 | Gerd Hoffmann | { |
93 | 037a5203 | Gerd Hoffmann | .bEndpointAddress = USB_DIR_IN | 0x01,
|
94 | 037a5203 | Gerd Hoffmann | .bmAttributes = USB_ENDPOINT_XFER_INT, |
95 | 037a5203 | Gerd Hoffmann | .wMaxPacketSize = 8,
|
96 | 037a5203 | Gerd Hoffmann | .bInterval = 0x0a,
|
97 | 037a5203 | Gerd Hoffmann | }, |
98 | 037a5203 | Gerd Hoffmann | }, |
99 | 037a5203 | Gerd Hoffmann | }; |
100 | f6d2a316 | balrog | |
101 | 037a5203 | Gerd Hoffmann | static const USBDescDevice desc_device_wacom = { |
102 | 037a5203 | Gerd Hoffmann | .bcdUSB = 0x0110,
|
103 | 037a5203 | Gerd Hoffmann | .bMaxPacketSize0 = 8,
|
104 | 037a5203 | Gerd Hoffmann | .bNumConfigurations = 1,
|
105 | 037a5203 | Gerd Hoffmann | .confs = (USBDescConfig[]) { |
106 | 037a5203 | Gerd Hoffmann | { |
107 | 037a5203 | Gerd Hoffmann | .bNumInterfaces = 1,
|
108 | 037a5203 | Gerd Hoffmann | .bConfigurationValue = 1,
|
109 | 037a5203 | Gerd Hoffmann | .bmAttributes = 0x80,
|
110 | 037a5203 | Gerd Hoffmann | .bMaxPower = 40,
|
111 | add75088 | Brad Hards | .nif = 1,
|
112 | 037a5203 | Gerd Hoffmann | .ifs = &desc_iface_wacom, |
113 | 037a5203 | Gerd Hoffmann | }, |
114 | 037a5203 | Gerd Hoffmann | }, |
115 | f6d2a316 | balrog | }; |
116 | f6d2a316 | balrog | |
117 | 037a5203 | Gerd Hoffmann | static const USBDesc desc_wacom = { |
118 | 037a5203 | Gerd Hoffmann | .id = { |
119 | 037a5203 | Gerd Hoffmann | .idVendor = 0x056a,
|
120 | 037a5203 | Gerd Hoffmann | .idProduct = 0x0000,
|
121 | 037a5203 | Gerd Hoffmann | .bcdDevice = 0x4210,
|
122 | 037a5203 | Gerd Hoffmann | .iManufacturer = STR_MANUFACTURER, |
123 | 037a5203 | Gerd Hoffmann | .iProduct = STR_PRODUCT, |
124 | 037a5203 | Gerd Hoffmann | .iSerialNumber = STR_SERIALNUMBER, |
125 | 037a5203 | Gerd Hoffmann | }, |
126 | 037a5203 | Gerd Hoffmann | .full = &desc_device_wacom, |
127 | 037a5203 | Gerd Hoffmann | .str = desc_strings, |
128 | f6d2a316 | balrog | }; |
129 | f6d2a316 | balrog | |
130 | f6d2a316 | balrog | static void usb_mouse_event(void *opaque, |
131 | f6d2a316 | balrog | int dx1, int dy1, int dz1, int buttons_state) |
132 | f6d2a316 | balrog | { |
133 | f6d2a316 | balrog | USBWacomState *s = opaque; |
134 | f6d2a316 | balrog | |
135 | f6d2a316 | balrog | s->dx += dx1; |
136 | f6d2a316 | balrog | s->dy += dy1; |
137 | f6d2a316 | balrog | s->dz += dz1; |
138 | f6d2a316 | balrog | s->buttons_state = buttons_state; |
139 | 2ca2078e | François Revol | s->changed = 1;
|
140 | f6d2a316 | balrog | } |
141 | f6d2a316 | balrog | |
142 | f6d2a316 | balrog | static void usb_wacom_event(void *opaque, |
143 | f6d2a316 | balrog | int x, int y, int dz, int buttons_state) |
144 | f6d2a316 | balrog | { |
145 | f6d2a316 | balrog | USBWacomState *s = opaque; |
146 | f6d2a316 | balrog | |
147 | 2ca2078e | François Revol | /* scale to Penpartner resolution */
|
148 | 2ca2078e | François Revol | s->x = (x * 5040 / 0x7FFF); |
149 | 2ca2078e | François Revol | s->y = (y * 3780 / 0x7FFF); |
150 | f6d2a316 | balrog | s->dz += dz; |
151 | f6d2a316 | balrog | s->buttons_state = buttons_state; |
152 | 2ca2078e | François Revol | s->changed = 1;
|
153 | f6d2a316 | balrog | } |
154 | f6d2a316 | balrog | |
155 | f6d2a316 | balrog | static inline int int_clamp(int val, int vmin, int vmax) |
156 | f6d2a316 | balrog | { |
157 | f6d2a316 | balrog | if (val < vmin)
|
158 | f6d2a316 | balrog | return vmin;
|
159 | f6d2a316 | balrog | else if (val > vmax) |
160 | f6d2a316 | balrog | return vmax;
|
161 | f6d2a316 | balrog | else
|
162 | f6d2a316 | balrog | return val;
|
163 | f6d2a316 | balrog | } |
164 | f6d2a316 | balrog | |
165 | f6d2a316 | balrog | static int usb_mouse_poll(USBWacomState *s, uint8_t *buf, int len) |
166 | f6d2a316 | balrog | { |
167 | f6d2a316 | balrog | int dx, dy, dz, b, l;
|
168 | f6d2a316 | balrog | |
169 | f6d2a316 | balrog | if (!s->mouse_grabbed) {
|
170 | f6d2a316 | balrog | s->eh_entry = qemu_add_mouse_event_handler(usb_mouse_event, s, 0,
|
171 | f6d2a316 | balrog | "QEMU PenPartner tablet");
|
172 | b2d4d832 | Gerd Hoffmann | qemu_activate_mouse_event_handler(s->eh_entry); |
173 | f6d2a316 | balrog | s->mouse_grabbed = 1;
|
174 | f6d2a316 | balrog | } |
175 | f6d2a316 | balrog | |
176 | f6d2a316 | balrog | dx = int_clamp(s->dx, -128, 127); |
177 | f6d2a316 | balrog | dy = int_clamp(s->dy, -128, 127); |
178 | f6d2a316 | balrog | dz = int_clamp(s->dz, -128, 127); |
179 | f6d2a316 | balrog | |
180 | f6d2a316 | balrog | s->dx -= dx; |
181 | f6d2a316 | balrog | s->dy -= dy; |
182 | f6d2a316 | balrog | s->dz -= dz; |
183 | f6d2a316 | balrog | |
184 | f6d2a316 | balrog | b = 0;
|
185 | f6d2a316 | balrog | if (s->buttons_state & MOUSE_EVENT_LBUTTON)
|
186 | f6d2a316 | balrog | b |= 0x01;
|
187 | f6d2a316 | balrog | if (s->buttons_state & MOUSE_EVENT_RBUTTON)
|
188 | f6d2a316 | balrog | b |= 0x02;
|
189 | f6d2a316 | balrog | if (s->buttons_state & MOUSE_EVENT_MBUTTON)
|
190 | f6d2a316 | balrog | b |= 0x04;
|
191 | f6d2a316 | balrog | |
192 | f6d2a316 | balrog | buf[0] = b;
|
193 | f6d2a316 | balrog | buf[1] = dx;
|
194 | f6d2a316 | balrog | buf[2] = dy;
|
195 | f6d2a316 | balrog | l = 3;
|
196 | f6d2a316 | balrog | if (len >= 4) { |
197 | f6d2a316 | balrog | buf[3] = dz;
|
198 | f6d2a316 | balrog | l = 4;
|
199 | f6d2a316 | balrog | } |
200 | f6d2a316 | balrog | return l;
|
201 | f6d2a316 | balrog | } |
202 | f6d2a316 | balrog | |
203 | f6d2a316 | balrog | static int usb_wacom_poll(USBWacomState *s, uint8_t *buf, int len) |
204 | f6d2a316 | balrog | { |
205 | f6d2a316 | balrog | int b;
|
206 | f6d2a316 | balrog | |
207 | f6d2a316 | balrog | if (!s->mouse_grabbed) {
|
208 | f6d2a316 | balrog | s->eh_entry = qemu_add_mouse_event_handler(usb_wacom_event, s, 1,
|
209 | f6d2a316 | balrog | "QEMU PenPartner tablet");
|
210 | b2d4d832 | Gerd Hoffmann | qemu_activate_mouse_event_handler(s->eh_entry); |
211 | f6d2a316 | balrog | s->mouse_grabbed = 1;
|
212 | f6d2a316 | balrog | } |
213 | f6d2a316 | balrog | |
214 | f6d2a316 | balrog | b = 0;
|
215 | f6d2a316 | balrog | if (s->buttons_state & MOUSE_EVENT_LBUTTON)
|
216 | f6d2a316 | balrog | b |= 0x01;
|
217 | f6d2a316 | balrog | if (s->buttons_state & MOUSE_EVENT_RBUTTON)
|
218 | 2ca2078e | François Revol | b |= 0x40;
|
219 | f6d2a316 | balrog | if (s->buttons_state & MOUSE_EVENT_MBUTTON)
|
220 | 2ca2078e | François Revol | b |= 0x20; /* eraser */ |
221 | f6d2a316 | balrog | |
222 | f6d2a316 | balrog | if (len < 7) |
223 | f6d2a316 | balrog | return 0; |
224 | f6d2a316 | balrog | |
225 | f6d2a316 | balrog | buf[0] = s->mode;
|
226 | 2ca2078e | François Revol | buf[5] = 0x00 | (b & 0xf0); |
227 | 2ca2078e | François Revol | buf[1] = s->x & 0xff; |
228 | 2ca2078e | François Revol | buf[2] = s->x >> 8; |
229 | 2ca2078e | François Revol | buf[3] = s->y & 0xff; |
230 | 2ca2078e | François Revol | buf[4] = s->y >> 8; |
231 | 2ca2078e | François Revol | if (b & 0x3f) { |
232 | f6d2a316 | balrog | buf[6] = 0; |
233 | f6d2a316 | balrog | } else {
|
234 | f6d2a316 | balrog | buf[6] = (unsigned char) -127; |
235 | f6d2a316 | balrog | } |
236 | f6d2a316 | balrog | |
237 | f6d2a316 | balrog | return 7; |
238 | f6d2a316 | balrog | } |
239 | f6d2a316 | balrog | |
240 | f6d2a316 | balrog | static void usb_wacom_handle_reset(USBDevice *dev) |
241 | f6d2a316 | balrog | { |
242 | f6d2a316 | balrog | USBWacomState *s = (USBWacomState *) dev; |
243 | f6d2a316 | balrog | |
244 | f6d2a316 | balrog | s->dx = 0;
|
245 | f6d2a316 | balrog | s->dy = 0;
|
246 | f6d2a316 | balrog | s->dz = 0;
|
247 | f6d2a316 | balrog | s->x = 0;
|
248 | f6d2a316 | balrog | s->y = 0;
|
249 | f6d2a316 | balrog | s->buttons_state = 0;
|
250 | f6d2a316 | balrog | s->mode = WACOM_MODE_HID; |
251 | f6d2a316 | balrog | } |
252 | f6d2a316 | balrog | |
253 | 007fd62f | Hans de Goede | static int usb_wacom_handle_control(USBDevice *dev, USBPacket *p, |
254 | 007fd62f | Hans de Goede | int request, int value, int index, int length, uint8_t *data) |
255 | f6d2a316 | balrog | { |
256 | f6d2a316 | balrog | USBWacomState *s = (USBWacomState *) dev; |
257 | 037a5203 | Gerd Hoffmann | int ret;
|
258 | 037a5203 | Gerd Hoffmann | |
259 | 007fd62f | Hans de Goede | ret = usb_desc_handle_control(dev, p, request, value, index, length, data); |
260 | 037a5203 | Gerd Hoffmann | if (ret >= 0) { |
261 | 037a5203 | Gerd Hoffmann | return ret;
|
262 | 037a5203 | Gerd Hoffmann | } |
263 | f6d2a316 | balrog | |
264 | 037a5203 | Gerd Hoffmann | ret = 0;
|
265 | f6d2a316 | balrog | switch (request) {
|
266 | f6d2a316 | balrog | case DeviceRequest | USB_REQ_GET_INTERFACE:
|
267 | f6d2a316 | balrog | data[0] = 0; |
268 | f6d2a316 | balrog | ret = 1;
|
269 | f6d2a316 | balrog | break;
|
270 | f6d2a316 | balrog | case DeviceOutRequest | USB_REQ_SET_INTERFACE:
|
271 | f6d2a316 | balrog | ret = 0;
|
272 | f6d2a316 | balrog | break;
|
273 | f6d2a316 | balrog | case WACOM_SET_REPORT:
|
274 | b2d4d832 | Gerd Hoffmann | if (s->mouse_grabbed) {
|
275 | b2d4d832 | Gerd Hoffmann | qemu_remove_mouse_event_handler(s->eh_entry); |
276 | b2d4d832 | Gerd Hoffmann | s->mouse_grabbed = 0;
|
277 | b2d4d832 | Gerd Hoffmann | } |
278 | f6d2a316 | balrog | s->mode = data[0];
|
279 | f6d2a316 | balrog | ret = 0;
|
280 | f6d2a316 | balrog | break;
|
281 | f6d2a316 | balrog | case WACOM_GET_REPORT:
|
282 | f6d2a316 | balrog | data[0] = 0; |
283 | f6d2a316 | balrog | data[1] = s->mode;
|
284 | f6d2a316 | balrog | ret = 2;
|
285 | f6d2a316 | balrog | break;
|
286 | f6d2a316 | balrog | /* USB HID requests */
|
287 | f6d2a316 | balrog | case HID_GET_REPORT:
|
288 | f6d2a316 | balrog | if (s->mode == WACOM_MODE_HID)
|
289 | f6d2a316 | balrog | ret = usb_mouse_poll(s, data, length); |
290 | f6d2a316 | balrog | else if (s->mode == WACOM_MODE_WACOM) |
291 | f6d2a316 | balrog | ret = usb_wacom_poll(s, data, length); |
292 | f6d2a316 | balrog | break;
|
293 | 2ca2078e | François Revol | case HID_GET_IDLE:
|
294 | 2ca2078e | François Revol | ret = 1;
|
295 | 2ca2078e | François Revol | data[0] = s->idle;
|
296 | 2ca2078e | François Revol | break;
|
297 | f6d2a316 | balrog | case HID_SET_IDLE:
|
298 | 2ca2078e | François Revol | s->idle = (uint8_t) (value >> 8);
|
299 | f6d2a316 | balrog | ret = 0;
|
300 | f6d2a316 | balrog | break;
|
301 | f6d2a316 | balrog | default:
|
302 | f6d2a316 | balrog | ret = USB_RET_STALL; |
303 | f6d2a316 | balrog | break;
|
304 | f6d2a316 | balrog | } |
305 | f6d2a316 | balrog | return ret;
|
306 | f6d2a316 | balrog | } |
307 | f6d2a316 | balrog | |
308 | f6d2a316 | balrog | static int usb_wacom_handle_data(USBDevice *dev, USBPacket *p) |
309 | f6d2a316 | balrog | { |
310 | f6d2a316 | balrog | USBWacomState *s = (USBWacomState *) dev; |
311 | 4f4321c1 | Gerd Hoffmann | uint8_t buf[p->iov.size]; |
312 | f6d2a316 | balrog | int ret = 0; |
313 | f6d2a316 | balrog | |
314 | f6d2a316 | balrog | switch (p->pid) {
|
315 | f6d2a316 | balrog | case USB_TOKEN_IN:
|
316 | f6d2a316 | balrog | if (p->devep == 1) { |
317 | 2ca2078e | François Revol | if (!(s->changed || s->idle))
|
318 | 2ca2078e | François Revol | return USB_RET_NAK;
|
319 | 2ca2078e | François Revol | s->changed = 0;
|
320 | f6d2a316 | balrog | if (s->mode == WACOM_MODE_HID)
|
321 | 4f4321c1 | Gerd Hoffmann | ret = usb_mouse_poll(s, buf, p->iov.size); |
322 | f6d2a316 | balrog | else if (s->mode == WACOM_MODE_WACOM) |
323 | 4f4321c1 | Gerd Hoffmann | ret = usb_wacom_poll(s, buf, p->iov.size); |
324 | 4f4321c1 | Gerd Hoffmann | usb_packet_copy(p, buf, ret); |
325 | f6d2a316 | balrog | break;
|
326 | f6d2a316 | balrog | } |
327 | f6d2a316 | balrog | /* Fall through. */
|
328 | f6d2a316 | balrog | case USB_TOKEN_OUT:
|
329 | f6d2a316 | balrog | default:
|
330 | f6d2a316 | balrog | ret = USB_RET_STALL; |
331 | f6d2a316 | balrog | break;
|
332 | f6d2a316 | balrog | } |
333 | f6d2a316 | balrog | return ret;
|
334 | f6d2a316 | balrog | } |
335 | f6d2a316 | balrog | |
336 | f6d2a316 | balrog | static void usb_wacom_handle_destroy(USBDevice *dev) |
337 | f6d2a316 | balrog | { |
338 | f6d2a316 | balrog | USBWacomState *s = (USBWacomState *) dev; |
339 | f6d2a316 | balrog | |
340 | b2d4d832 | Gerd Hoffmann | if (s->mouse_grabbed) {
|
341 | b2d4d832 | Gerd Hoffmann | qemu_remove_mouse_event_handler(s->eh_entry); |
342 | b2d4d832 | Gerd Hoffmann | s->mouse_grabbed = 0;
|
343 | b2d4d832 | Gerd Hoffmann | } |
344 | f6d2a316 | balrog | } |
345 | f6d2a316 | balrog | |
346 | 806b6024 | Gerd Hoffmann | static int usb_wacom_initfn(USBDevice *dev) |
347 | f6d2a316 | balrog | { |
348 | 806b6024 | Gerd Hoffmann | USBWacomState *s = DO_UPCAST(USBWacomState, dev, dev); |
349 | a980a065 | Gerd Hoffmann | usb_desc_init(dev); |
350 | 2ca2078e | François Revol | s->changed = 1;
|
351 | 806b6024 | Gerd Hoffmann | return 0; |
352 | 806b6024 | Gerd Hoffmann | } |
353 | f6d2a316 | balrog | |
354 | ccce9fd2 | Gerd Hoffmann | static const VMStateDescription vmstate_usb_wacom = { |
355 | ccce9fd2 | Gerd Hoffmann | .name = "usb-wacom",
|
356 | ccce9fd2 | Gerd Hoffmann | .unmigratable = 1,
|
357 | ccce9fd2 | Gerd Hoffmann | }; |
358 | ccce9fd2 | Gerd Hoffmann | |
359 | 806b6024 | Gerd Hoffmann | static struct USBDeviceInfo wacom_info = { |
360 | 06384698 | Markus Armbruster | .product_desc = "QEMU PenPartner Tablet",
|
361 | 556cd098 | Markus Armbruster | .qdev.name = "usb-wacom-tablet",
|
362 | 556cd098 | Markus Armbruster | .qdev.desc = "QEMU PenPartner Tablet",
|
363 | fa7c70c3 | Gerd Hoffmann | .usbdevice_name = "wacom-tablet",
|
364 | 037a5203 | Gerd Hoffmann | .usb_desc = &desc_wacom, |
365 | 806b6024 | Gerd Hoffmann | .qdev.size = sizeof(USBWacomState),
|
366 | ccce9fd2 | Gerd Hoffmann | .qdev.vmsd = &vmstate_usb_wacom, |
367 | 806b6024 | Gerd Hoffmann | .init = usb_wacom_initfn, |
368 | 806b6024 | Gerd Hoffmann | .handle_packet = usb_generic_handle_packet, |
369 | 806b6024 | Gerd Hoffmann | .handle_reset = usb_wacom_handle_reset, |
370 | 806b6024 | Gerd Hoffmann | .handle_control = usb_wacom_handle_control, |
371 | 806b6024 | Gerd Hoffmann | .handle_data = usb_wacom_handle_data, |
372 | 806b6024 | Gerd Hoffmann | .handle_destroy = usb_wacom_handle_destroy, |
373 | 806b6024 | Gerd Hoffmann | }; |
374 | f6d2a316 | balrog | |
375 | 806b6024 | Gerd Hoffmann | static void usb_wacom_register_devices(void) |
376 | 806b6024 | Gerd Hoffmann | { |
377 | 806b6024 | Gerd Hoffmann | usb_qdev_register(&wacom_info); |
378 | f6d2a316 | balrog | } |
379 | 806b6024 | Gerd Hoffmann | device_init(usb_wacom_register_devices) |