aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTorne Wuff <torne@wolfpuppy.org.uk>2014-03-01 17:19:02 +0000
committerTorne Wuff <torne@wolfpuppy.org.uk>2014-03-01 17:36:34 +0000
commit0b91943a7e04875d33663bc822fe3a7273aec371 (patch)
treeef45747328584b79c1d68e6fc89459ef174b131d
parentfb1d457d31686b8c78aede8817eca65084715ed0 (diff)
downloadconnectbot-0b91943a7e04875d33663bc822fe3a7273aec371.tar.gz
connectbot-0b91943a7e04875d33663bc822fe3a7273aec371.tar.bz2
connectbot-0b91943a7e04875d33663bc822fe3a7273aec371.zip
Fix ctrl key on hardware keyboards.
We were only masking off META_CTRL_ON before calling getUnicodeChar, which caused many keymaps to return 0 since one of the other ctrl key bits was still set. Masking off *all* the ctrl bits makes it return the actual character for the key pressed, and then we handle it right.
-rw-r--r--src/org/connectbot/service/TerminalKeyListener.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/org/connectbot/service/TerminalKeyListener.java b/src/org/connectbot/service/TerminalKeyListener.java
index 3f82259..d242a00 100644
--- a/src/org/connectbot/service/TerminalKeyListener.java
+++ b/src/org/connectbot/service/TerminalKeyListener.java
@@ -64,7 +64,11 @@ public class TerminalKeyListener implements OnKeyListener, OnSharedPreferenceCha
// backport constants from api level 11
private final static int KEYCODE_ESCAPE = 111;
- private final static int HC_META_CTRL_ON = 4096;
+ private final static int HC_META_CTRL_ON = 0x1000;
+ private final static int HC_META_CTRL_LEFT_ON = 0x2000;
+ private final static int HC_META_CTRL_RIGHT_ON = 0x4000;
+ private final static int HC_META_CTRL_MASK = HC_META_CTRL_ON | HC_META_CTRL_RIGHT_ON
+ | HC_META_CTRL_LEFT_ON;
private final static int HC_META_ALT_MASK = KeyEvent.META_ALT_ON | KeyEvent.META_ALT_LEFT_ON
| KeyEvent.META_ALT_RIGHT_ON;
@@ -283,9 +287,9 @@ public class TerminalKeyListener implements OnKeyListener, OnSharedPreferenceCha
// Ask the system to use the keymap to give us the unicode character for this key,
// with our derived modifier state applied.
- int uchar = event.getUnicodeChar(derivedMetaState & ~HC_META_CTRL_ON);
+ int uchar = event.getUnicodeChar(derivedMetaState & ~HC_META_CTRL_MASK);
int ucharWithoutAlt = event.getUnicodeChar(
- derivedMetaState & ~(HC_META_ALT_MASK | HC_META_CTRL_ON));
+ derivedMetaState & ~(HC_META_ALT_MASK | HC_META_CTRL_MASK));
if (uchar != ucharWithoutAlt) {
// The alt key was used to modify the character returned; therefore, drop the alt
// modifier from the state so we don't end up sending alt+key.