From 913c474d32db136308d87e7504b9f0fea5ca2353 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Wed, 30 Dec 2015 00:46:08 +0100 Subject: [PATCH] Input normal ^ even on other unicode char input Some bluetooth keyboards [1] input U+02C6, the unicode character MODIFIER LETTER CIRCUMFLEX ACCENT instead of the more common ^ (U+005E CIRCUMFLEX ACCENT). Remap it to the common caret since that is what terminal programs expect. [1] https://plus.google.com/100972300636796512022/posts/f7PKpXWesgG --- .../java/com/termux/view/TerminalView.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/termux/view/TerminalView.java b/app/src/main/java/com/termux/view/TerminalView.java index 83984748..d9e04856 100644 --- a/app/src/main/java/com/termux/view/TerminalView.java +++ b/app/src/main/java/com/termux/view/TerminalView.java @@ -644,13 +644,20 @@ public final class TerminalView extends View { if (resultingKeyCode > -1) { handleKeyCode(resultingKeyCode, 0); } else { - // The below two workarounds are needed on at least Logitech Keyboard k810 on Samsung Galaxy Tab Pro - // (Android 4.4) with the stock Samsung Keyboard. They should be harmless when not used since the need - // to input the original characters instead of the new ones using the keyboard should be low. - // Rewrite U+02DC 'SMALL TILDE' to U+007E 'TILDE' for ~ to work in shells: - if (codePoint == 0x02DC) codePoint = 0x07E; - // Rewrite U+02CB 'MODIFIER LETTER GRAVE ACCENT' to U+0060 'GRAVE ACCENT' for ` (backticks) to work: - if (codePoint == 0x02CB) codePoint = 0x60; + // Work around bluetooth keyboards sending funny unicode characters instead + // of the more normal ones from ASCII that terminal programs expect - the + // desire to input the original characters should be low. + switch (codePoint) { + case 0x02DC: // SMALL TILDE. + codePoint = 0x007E; // TILDE (~). + break; + case 0x02CB: // MODIFIER LETTER GRAVE ACCENT. + codePoint = 0x0060; // GRAVE ACCENT (`). + break; + case 0x02C6: // MODIFIER LETTER CIRCUMFLEX ACCENT. + codePoint = 0x005E; // CIRCUMFLEX ACCENT (^). + break; + } // If left alt, send escape before the code point to make e.g. Alt+B and Alt+F work in readline: mTermSession.writeCodePoint(leftAltDownFromEvent, codePoint);