From: Po Lu Date: Sat, 16 Dec 2023 02:55:18 +0000 (+0800) Subject: Provide for Num Lock and Scroll Lock on Android X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a2c2ec548bb7fc03e1f050c2c784b65e9725fea1;p=emacs.git Provide for Num Lock and Scroll Lock on Android * java/org/gnu/emacs/EmacsWindow.java (onKeyDown, onKeyUp): Retain META_NUM_LOCK_ON and META_SCROLL_LOCK_ON while filtering meta state. --- diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java index 3c9e6eb215f..0dc4a274731 100644 --- a/java/org/gnu/emacs/EmacsWindow.java +++ b/java/org/gnu/emacs/EmacsWindow.java @@ -644,7 +644,7 @@ public final class EmacsWindow extends EmacsHandleObject public void onKeyDown (int keyCode, KeyEvent event) { - int state, state_1; + int state, state_1, num_lock_flag; long serial; String characters; @@ -665,13 +665,23 @@ public final class EmacsWindow extends EmacsHandleObject state = eventModifiers (event); + /* Num Lock and Scroll Lock aren't supported by systems older than + Android 3.0. */ + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) + num_lock_flag = (KeyEvent.META_NUM_LOCK_ON + | KeyEvent.META_SCROLL_LOCK_ON); + else + num_lock_flag = 0; + /* Ignore meta-state understood by Emacs for now, or key presses such as Ctrl+C and Meta+C will not be recognized as an ASCII key press event. */ state_1 = state & ~(KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK - | KeyEvent.META_SYM_ON | KeyEvent.META_META_MASK); + | KeyEvent.META_SYM_ON | KeyEvent.META_META_MASK + | num_lock_flag); synchronized (eventStrings) { @@ -692,19 +702,29 @@ public final class EmacsWindow extends EmacsHandleObject public void onKeyUp (int keyCode, KeyEvent event) { - int state, state_1, unicode_char; + int state, state_1, unicode_char, num_lock_flag; long time; /* Compute the event's modifier mask. */ state = eventModifiers (event); + /* Num Lock and Scroll Lock aren't supported by systems older than + Android 3.0. */ + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) + num_lock_flag = (KeyEvent.META_NUM_LOCK_ON + | KeyEvent.META_SCROLL_LOCK_ON); + else + num_lock_flag = 0; + /* Ignore meta-state understood by Emacs for now, or key presses such as Ctrl+C and Meta+C will not be recognized as an ASCII key press event. */ state_1 = state & ~(KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK - | KeyEvent.META_SYM_ON | KeyEvent.META_META_MASK); + | KeyEvent.META_SYM_ON | KeyEvent.META_META_MASK + | num_lock_flag); unicode_char = getEventUnicodeChar (event, state_1);