aboutsummaryrefslogtreecommitdiffstats
path: root/android/keycode-array.c
diff options
context:
space:
mode:
authorVladimir Chtchetkine <vchtchetkine@google.com>2010-07-07 15:57:00 -0700
committerVladimir Chtchetkine <vchtchetkine@google.com>2010-07-07 16:49:12 -0700
commit71bb14f826775867d16e7d382cfdc48e6ca46ccb (patch)
tree9e533673a8c4f7e8bc4b2b1f83589196e0957c0f /android/keycode-array.c
parenta21ac6912568a1d36a2919669f905bc58be21244 (diff)
downloadexternal_qemu-71bb14f826775867d16e7d382cfdc48e6ca46ccb.zip
external_qemu-71bb14f826775867d16e7d382cfdc48e6ca46ccb.tar.gz
external_qemu-71bb14f826775867d16e7d382cfdc48e6ca46ccb.tar.bz2
Move key event generation out of the UI realm into neutral space.
Abstracted keycode event array into keycode_array.[hc], Moved key to keycode translation into charmap.c Change-Id: I4de0c9853fa93d675895fc361e62ee36c1c0a652
Diffstat (limited to 'android/keycode-array.c')
-rw-r--r--android/keycode-array.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/android/keycode-array.c b/android/keycode-array.c
new file mode 100644
index 0000000..cf7ec21
--- /dev/null
+++ b/android/keycode-array.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 2010 The Android Open Source Project
+**
+** This software is licensed under the terms of the GNU General Public
+** License version 2, as published by the Free Software Foundation, and
+** may be copied, distributed, and modified under those terms.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+*/
+
+#include <stdio.h>
+#include "android/utils/debug.h"
+#include "android/keycode-array.h"
+#include "user-events.h"
+
+void
+android_keycodes_add_key_event( AKeycodeBuffer* keycodes,
+ unsigned code,
+ unsigned down )
+{
+ if (code != 0 && keycodes->keycode_count < MAX_KEYCODES) {
+ keycodes->keycodes[(int)keycodes->keycode_count++] =
+ ( (code & 0x1ff) | (down ? 0x200 : 0) );
+ }
+}
+
+void
+android_keycodes_flush(AKeycodeBuffer* keycodes)
+{
+ if (keycodes->keycode_count > 0) {
+ if (VERBOSE_CHECK(keys)) {
+ int nn;
+ printf(">> KEY" );
+ for (nn = 0; nn < keycodes->keycode_count; nn++) {
+ int code = keycodes->keycodes[nn];
+ printf(" [0x%03x,%s]", (code & 0x1ff), (code & 0x200) ? "down" : " up " );
+ }
+ printf( "\n" );
+ }
+ user_event_keycodes(keycodes->keycodes, keycodes->keycode_count);
+ keycodes->keycode_count = 0;
+ }
+}