From 71bb14f826775867d16e7d382cfdc48e6ca46ccb Mon Sep 17 00:00:00 2001 From: Vladimir Chtchetkine Date: Wed, 7 Jul 2010 15:57:00 -0700 Subject: 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 --- android/keycode-array.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 android/keycode-array.c (limited to 'android/keycode-array.c') 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 +#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; + } +} -- cgit v1.1