blob: 45a994a906092de1ecb28ef9be60089bde751a59 [file] [log] [blame]
David 'Digit' Turner34f29742010-05-25 18:16:10 -07001/* 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
17void
18user_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
25void
26user_event_keycode(int kcode)
27{
28 kbd_put_keycode(kcode);
29}
30
31void
32user_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
44void
45user_event_mouse(int dx, int dy, int dz, unsigned buttons_state)
46{
47 kbd_mouse_event(dx, dy, dz, buttons_state);
48}
49
50static QEMUPutGenericEvent *generic_event_callback;
51static void* generic_event_opaque;
52
53void user_event_register_generic(void* opaque, QEMUPutGenericEvent *callback)
54{
55 generic_event_callback = callback;
56 generic_event_opaque = opaque;
57}
58
59void
60user_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}