changeset 154:86f903100573

disable auto-repeat on monitor special key
author Carl Byington <carl@five-ten-sg.com>
date Mon, 23 Jun 2014 11:54:26 -0700
parents 3ca280646f2d
children 156b53fc4815
files src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java
diffstat 1 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java	Mon Jun 23 11:18:02 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java	Mon Jun 23 11:54:26 2014 -0700
@@ -140,6 +140,8 @@
      */
     public boolean onKey(View v, int keyCode, KeyEvent event) {
         try {
+            int repeat = event.getRepeatCount();
+
             // skip keys if we aren't connected yet or have been disconnected
             if (bridge.isDisconnected()) return false;
 
@@ -362,8 +364,7 @@
             }
 
             // try handling keymode shortcuts
-            if (hardKeyboard && !hardKeyboardHidden &&
-                    event.getRepeatCount() == 0) {
+            if (hardKeyboard && !hardKeyboardHidden && (repeat == 0)) {
                 if (PreferenceConstants.KEYMODE_RIGHT.equals(keymode)) {
                     switch (keyCode) {
                         case KeyEvent.KEYCODE_ALT_RIGHT:
@@ -426,7 +427,7 @@
 
             // look for special chars
             switch (keyCode) {
-                case KEYCODE_ESCAPE:
+                case KeyEvent.KEYCODE_ESCAPE:
                     sendEscape();
                     return true;
 
@@ -434,13 +435,13 @@
                     buffer.keyPressed(vt320.KEY_TAB, ' ',  getStateForBuffer());
                     return true;
 
-                case KEYCODE_PAGE_DOWN:
+                case KeyEvent.KEYCODE_PAGE_DOWN:
                     buffer.keyPressed(vt320.KEY_PAGE_DOWN, ' ', getStateForBuffer());
                     metaState &= ~META_TRANSIENT;
                     bridge.tryKeyVibrate();
                     return true;
 
-                case KEYCODE_PAGE_UP:
+                case KeyEvent.KEYCODE_PAGE_UP:
                     buffer.keyPressed(vt320.KEY_PAGE_UP, ' ', getStateForBuffer());
                     metaState &= ~META_TRANSIENT;
                     bridge.tryKeyVibrate();
@@ -463,35 +464,35 @@
                     String hwbuttonShortcut = manager.prefs.getString(
                                                   PreferenceConstants.CAMERA,
                                                   PreferenceConstants.HWBUTTON_SCREEN_CAPTURE);
-                    return (handleShortcut(v, hwbuttonShortcut));
+                    return (handleShortcut(v, hwbuttonShortcut, repeat));
 
                 case KeyEvent.KEYCODE_VOLUME_UP:
                     // check to see which shortcut the volume button triggers
                     hwbuttonShortcut = manager.prefs.getString(
                                            PreferenceConstants.VOLUP,
                                            PreferenceConstants.HWBUTTON_CTRL);
-                    return (handleShortcut(v, hwbuttonShortcut));
+                    return (handleShortcut(v, hwbuttonShortcut, repeat));
 
                 case KeyEvent.KEYCODE_VOLUME_DOWN:
                     // check to see which shortcut the camera button triggers
                     hwbuttonShortcut = manager.prefs.getString(
                                            PreferenceConstants.VOLDN,
                                            PreferenceConstants.HWBUTTON_TAB);
-                    return (handleShortcut(v, hwbuttonShortcut));
+                    return (handleShortcut(v, hwbuttonShortcut, repeat));
 
                 case KeyEvent.KEYCODE_SEARCH:
                     // check to see which shortcut the search button triggers
                     hwbuttonShortcut = manager.prefs.getString(
                                            PreferenceConstants.SEARCH,
                                            PreferenceConstants.HWBUTTON_ESC);
-                    return (handleShortcut(v, hwbuttonShortcut));
+                    return (handleShortcut(v, hwbuttonShortcut, repeat));
 
                 case KeyEvent.KEYCODE_BUTTON_L2:
                     // check to see which shortcut the ptt button triggers
                     hwbuttonShortcut = manager.prefs.getString(
                                            PreferenceConstants.PTT,
                                            PreferenceConstants.HWBUTTON_MONITOR);
-                    return (handleShortcut(v, hwbuttonShortcut));
+                    return (handleShortcut(v, hwbuttonShortcut, repeat));
 
                 case KeyEvent.KEYCODE_DEL:
                     if ((metaState & META_ALT_MASK) != 0) {
@@ -598,11 +599,13 @@
         return false;
     }
 
-    private boolean handleShortcut(View v, String shortcut) {
+    private boolean handleShortcut(View v, String shortcut, int repeat) {
         if (PreferenceConstants.HWBUTTON_SCREEN_CAPTURE.equals(shortcut)) {
+            if (repeat > 0) return false;
             bridge.captureScreen();
         }
         else if (PreferenceConstants.HWBUTTON_MONITOR.equals(shortcut)) {
+            if (repeat > 0) return false;
             buffer.monitorKey(true);    // key down
         }
         else if (PreferenceConstants.HWBUTTON_CTRL.equals(shortcut)) {
@@ -1174,4 +1177,3 @@
         }
     }
 }
-