Commit 3988e8977b8267a468377a03cc9afb643615a8fa
1 parent
7483750d
ADB reset support (Joceylin Mayer)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1295 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
28 additions
and
4 deletions
hw/adb.c
... | ... | @@ -248,13 +248,25 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf, |
248 | 248 | return olen; |
249 | 249 | } |
250 | 250 | |
251 | +static int adb_kbd_reset(ADBDevice *d) | |
252 | +{ | |
253 | + KBDState *s = d->opaque; | |
254 | + | |
255 | + d->handler = 1; | |
256 | + d->devaddr = ADB_KEYBOARD; | |
257 | + memset(s, 0, sizeof(KBDState)); | |
258 | + | |
259 | + return 0; | |
260 | +} | |
261 | + | |
251 | 262 | void adb_kbd_init(ADBBusState *bus) |
252 | 263 | { |
253 | 264 | ADBDevice *d; |
254 | 265 | KBDState *s; |
255 | 266 | s = qemu_mallocz(sizeof(KBDState)); |
256 | - d = adb_register_device(bus, ADB_KEYBOARD, adb_kbd_request, NULL, s); | |
257 | - d->handler = 1; | |
267 | + d = adb_register_device(bus, ADB_KEYBOARD, adb_kbd_request, | |
268 | + adb_kbd_reset, s); | |
269 | + adb_kbd_reset(d); | |
258 | 270 | qemu_add_kbd_event_handler(adb_kbd_put_keycode, d); |
259 | 271 | } |
260 | 272 | |
... | ... | @@ -374,13 +386,25 @@ static int adb_mouse_request(ADBDevice *d, uint8_t *obuf, |
374 | 386 | return olen; |
375 | 387 | } |
376 | 388 | |
389 | +static int adb_mouse_reset(ADBDevice *d) | |
390 | +{ | |
391 | + MouseState *s = d->opaque; | |
392 | + | |
393 | + d->handler = 2; | |
394 | + d->devaddr = ADB_MOUSE; | |
395 | + memset(s, 0, sizeof(MouseState)); | |
396 | + | |
397 | + return 0; | |
398 | +} | |
399 | + | |
377 | 400 | void adb_mouse_init(ADBBusState *bus) |
378 | 401 | { |
379 | 402 | ADBDevice *d; |
380 | 403 | MouseState *s; |
381 | 404 | |
382 | 405 | s = qemu_mallocz(sizeof(MouseState)); |
383 | - d = adb_register_device(bus, ADB_MOUSE, adb_mouse_request, NULL, s); | |
384 | - d->handler = 2; | |
406 | + d = adb_register_device(bus, ADB_MOUSE, adb_mouse_request, | |
407 | + adb_mouse_reset, s); | |
408 | + adb_mouse_reset(d); | |
385 | 409 | qemu_add_mouse_event_handler(adb_mouse_event, d); |
386 | 410 | } | ... | ... |