diff options
| author | Po Lu | 2023-12-16 10:55:18 +0800 |
|---|---|---|
| committer | Po Lu | 2023-12-16 10:55:18 +0800 |
| commit | a2c2ec548bb7fc03e1f050c2c784b65e9725fea1 (patch) | |
| tree | d0dcc080b298482e597fc350a17dd1a27a5e4171 /java | |
| parent | 4072e06a5f7d14b11799d8dd41d7c50082dca4e6 (diff) | |
| download | emacs-a2c2ec548bb7fc03e1f050c2c784b65e9725fea1.tar.gz emacs-a2c2ec548bb7fc03e1f050c2c784b65e9725fea1.zip | |
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.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsWindow.java | 28 |
1 files changed, 24 insertions, 4 deletions
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 | |||
| 644 | public void | 644 | public void |
| 645 | onKeyDown (int keyCode, KeyEvent event) | 645 | onKeyDown (int keyCode, KeyEvent event) |
| 646 | { | 646 | { |
| 647 | int state, state_1; | 647 | int state, state_1, num_lock_flag; |
| 648 | long serial; | 648 | long serial; |
| 649 | String characters; | 649 | String characters; |
| 650 | 650 | ||
| @@ -665,13 +665,23 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 665 | 665 | ||
| 666 | state = eventModifiers (event); | 666 | state = eventModifiers (event); |
| 667 | 667 | ||
| 668 | /* Num Lock and Scroll Lock aren't supported by systems older than | ||
| 669 | Android 3.0. */ | ||
| 670 | |||
| 671 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) | ||
| 672 | num_lock_flag = (KeyEvent.META_NUM_LOCK_ON | ||
| 673 | | KeyEvent.META_SCROLL_LOCK_ON); | ||
| 674 | else | ||
| 675 | num_lock_flag = 0; | ||
| 676 | |||
| 668 | /* Ignore meta-state understood by Emacs for now, or key presses | 677 | /* Ignore meta-state understood by Emacs for now, or key presses |
| 669 | such as Ctrl+C and Meta+C will not be recognized as an ASCII | 678 | such as Ctrl+C and Meta+C will not be recognized as an ASCII |
| 670 | key press event. */ | 679 | key press event. */ |
| 671 | 680 | ||
| 672 | state_1 | 681 | state_1 |
| 673 | = state & ~(KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK | 682 | = state & ~(KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK |
| 674 | | KeyEvent.META_SYM_ON | KeyEvent.META_META_MASK); | 683 | | KeyEvent.META_SYM_ON | KeyEvent.META_META_MASK |
| 684 | | num_lock_flag); | ||
| 675 | 685 | ||
| 676 | synchronized (eventStrings) | 686 | synchronized (eventStrings) |
| 677 | { | 687 | { |
| @@ -692,19 +702,29 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 692 | public void | 702 | public void |
| 693 | onKeyUp (int keyCode, KeyEvent event) | 703 | onKeyUp (int keyCode, KeyEvent event) |
| 694 | { | 704 | { |
| 695 | int state, state_1, unicode_char; | 705 | int state, state_1, unicode_char, num_lock_flag; |
| 696 | long time; | 706 | long time; |
| 697 | 707 | ||
| 698 | /* Compute the event's modifier mask. */ | 708 | /* Compute the event's modifier mask. */ |
| 699 | state = eventModifiers (event); | 709 | state = eventModifiers (event); |
| 700 | 710 | ||
| 711 | /* Num Lock and Scroll Lock aren't supported by systems older than | ||
| 712 | Android 3.0. */ | ||
| 713 | |||
| 714 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) | ||
| 715 | num_lock_flag = (KeyEvent.META_NUM_LOCK_ON | ||
| 716 | | KeyEvent.META_SCROLL_LOCK_ON); | ||
| 717 | else | ||
| 718 | num_lock_flag = 0; | ||
| 719 | |||
| 701 | /* Ignore meta-state understood by Emacs for now, or key presses | 720 | /* Ignore meta-state understood by Emacs for now, or key presses |
| 702 | such as Ctrl+C and Meta+C will not be recognized as an ASCII | 721 | such as Ctrl+C and Meta+C will not be recognized as an ASCII |
| 703 | key press event. */ | 722 | key press event. */ |
| 704 | 723 | ||
| 705 | state_1 | 724 | state_1 |
| 706 | = state & ~(KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK | 725 | = state & ~(KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK |
| 707 | | KeyEvent.META_SYM_ON | KeyEvent.META_META_MASK); | 726 | | KeyEvent.META_SYM_ON | KeyEvent.META_META_MASK |
| 727 | | num_lock_flag); | ||
| 708 | 728 | ||
| 709 | unicode_char = getEventUnicodeChar (event, state_1); | 729 | unicode_char = getEventUnicodeChar (event, state_1); |
| 710 | 730 | ||