David 'Digit' Turner | 34f2974 | 2010-05-25 18:16:10 -0700 | [diff] [blame] | 1 | /* Copyright (C) 2010 The Android Open Source Project |
| 2 | ** |
| 3 | ** This software is licensed under the terms of the GNU General Public |
| 4 | ** License version 2, as published by the Free Software Foundation, and |
| 5 | ** may be copied, distributed, and modified under those terms. |
| 6 | ** |
| 7 | ** This program is distributed in the hope that it will be useful, |
| 8 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | ** GNU General Public License for more details. |
| 11 | */ |
| 12 | #include "user-events.h" |
| 13 | #include "android/utils/debug.h" |
| 14 | #include "console.h" |
| 15 | #include <stdio.h> |
| 16 | |
| 17 | void |
| 18 | user_event_keycodes(int *kcodes, int count) |
| 19 | { |
| 20 | int nn; |
| 21 | for (nn = 0; nn < count; nn++) |
| 22 | user_event_keycode(kcodes[nn]); |
| 23 | } |
| 24 | |
| 25 | void |
| 26 | user_event_keycode(int kcode) |
| 27 | { |
| 28 | kbd_put_keycode(kcode); |
| 29 | } |
| 30 | |
| 31 | void |
| 32 | user_event_key(unsigned code, unsigned down) |
| 33 | { |
| 34 | if(code == 0) { |
| 35 | return; |
| 36 | } |
| 37 | if (VERBOSE_CHECK(keys)) |
| 38 | printf(">> KEY [0x%03x,%s]\n", (code & 0x1ff), down ? "down" : " up " ); |
| 39 | |
| 40 | user_event_keycode((code & 0x1ff) | (down ? 0x200 : 0)); |
| 41 | } |
| 42 | |
| 43 | |
| 44 | void |
| 45 | user_event_mouse(int dx, int dy, int dz, unsigned buttons_state) |
| 46 | { |
| 47 | kbd_mouse_event(dx, dy, dz, buttons_state); |
| 48 | } |
| 49 | |
| 50 | static QEMUPutGenericEvent *generic_event_callback; |
| 51 | static void* generic_event_opaque; |
| 52 | |
| 53 | void user_event_register_generic(void* opaque, QEMUPutGenericEvent *callback) |
| 54 | { |
| 55 | generic_event_callback = callback; |
| 56 | generic_event_opaque = opaque; |
| 57 | } |
| 58 | |
| 59 | void |
| 60 | user_event_generic(int type, int code, int value) |
| 61 | { |
| 62 | if (generic_event_callback) |
| 63 | generic_event_callback(generic_event_opaque, type, code, value); |
| 64 | } |