/* Convert the keypress event into a string. */ static unsigned char* lookup_key(XEvent* ev, int* pcount) { KeySym keysym; int count; static unsigned char kbuf[KBUFSIZE]; unsigned char* s; unsigned char* str; count = XLookupString(&ev->xkey, (char*)kbuf, KBUFSIZE, &keysym, NULL); s = NULL; if (IsFunctionKey(keysym) || IsMiscFunctionKey(keysym) || (keysym == XK_Next) || (keysym == XK_Prior) || (keysym == XK_Delete) || (keysym == XK_BackSpace)) { s = get_keycode_value(func_key_table, keysym, kbuf, KBUFSIZE, sun_function_keys); } else if (IsCursorKey(keysym) || IsPFKey(keysym)) { s = get_keycode_value(other_key_table, keysym, kbuf, KBUFSIZE, app_cur_keys); } else { s = get_keycode_value(kp_key_table, keysym, kbuf, KBUFSIZE, app_kp_keys); } if (s != NULL) { *pcount = strlen((char*)s); str = s; } else { str = kbuf; if ((ev->xkey.state & Mod1Mask) && (count == 1)) { if (is_eightbit()) { kbuf[0] |= 0200; *pcount = 1; } else { kbuf[1] = kbuf[0]; kbuf[0] = '\033'; *pcount = 2; } } else { *pcount = count; } } return(str); }
gcc_visibility_default void Java_org_xcsoar_EventBridge_onKeyDown(JNIEnv *env, jclass cls, jint key_code) { if (event_queue == NULL) /* XCSoar not yet initialised */ return; if (!has_cursor_keys && IsCursorKey(key_code)) /* enable this flag as soon as we see the first cursor event; used by HasCursorKeys() */ has_cursor_keys = true; event_queue->Push(Event(Event::KEY_DOWN, TranslateKeyCode(key_code))); ResetUserIdle(); }