changeset 148:69333ca1563c

add ptt button p2 preference
author Carl Byington <carl@five-ten-sg.com>
date Sun, 22 Jun 2014 13:02:36 -0700
parents 1350adb077b1
children eff82d6c11d9
files res/values/arrays.xml res/values/strings.xml res/xml/preferences.xml src/com/five_ten_sg/connectbot/service/TerminalMonitor.java src/com/five_ten_sg/connectbot/transport/AbsTransport.java src/com/five_ten_sg/connectbot/transport/TN5250.java src/com/five_ten_sg/connectbot/util/PreferenceConstants.java src/de/mud/terminal/vt320.java
diffstat 8 files changed, 58 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/res/values/arrays.xml	Sun Jun 22 07:57:20 2014 -0700
+++ b/res/values/arrays.xml	Sun Jun 22 13:02:36 2014 -0700
@@ -56,9 +56,11 @@
 		<item>@string/list_hwbutton_ctrlaspace</item>
 		<item>@string/list_hwbutton_ctrla</item>
 		<item>@string/list_hwbutton_esc_a</item>
+		<item>@string/list_hwbutton_monitor</item>
 		<item>@string/list_hwbutton_none</item>
 	</string-array>
 
+    <!-- must match PreferenceConstants -->
 	<string-array name="list_hwbutton_values" translatable="false">
 		<item>CTRL</item>
 		<item>Esc</item>
@@ -67,6 +69,7 @@
 		<item>Ctrl+A then Space</item>
 		<item>Ctrl+A</item>
 		<item>Esc+A</item>
+		<item>Monitor Key</item>
 		<item>None</item>
 	</string-array>
 
--- a/res/values/strings.xml	Sun Jun 22 07:57:20 2014 -0700
+++ b/res/values/strings.xml	Sun Jun 22 13:02:36 2014 -0700
@@ -215,7 +215,6 @@
 
 	<!-- Name for the camera shortcut usage preference -->
 	<string name="pref_camera_title">"Camera button"</string>
-	<!-- Summary for the camera shortcut usage preference -->
 	<string name="pref_camera_summary">"Action triggered by pressing the camera button"</string>
 
 	<!-- Name for the volup shortcut usage preference -->
@@ -226,10 +225,14 @@
 	<string name="pref_voldn_title">"Volume down button"</string>
 	<string name="pref_voldn_summary">"Action triggered by pressing the volume down button"</string>
 
-	<!-- Name for the volup shortcut usage preference -->
+	<!-- Name for the search shortcut usage preference -->
 	<string name="pref_search_title">"Search button"</string>
 	<string name="pref_search_summary">"Action triggered by pressing the search button"</string>
 
+	<!-- Name for the ptt shortcut usage preference -->
+	<string name="pref_ptt_title">"PTT (L2) button"</string>
+	<string name="pref_ptt_summary">"Action triggered by pressing the ptt button"</string>
+
 	<!-- Name for the keep screen on preference -->
 	<string name="pref_keepalive_title">"Keep screen awake"</string>
 	<!-- Summary for the camera shortcut usage preference -->
--- a/res/xml/preferences.xml	Sun Jun 22 07:57:20 2014 -0700
+++ b/res/xml/preferences.xml	Sun Jun 22 13:02:36 2014 -0700
@@ -132,7 +132,7 @@
 			android:summary="@string/pref_voldn_summary"
 			android:entries="@array/list_hwbutton"
 			android:entryValues="@array/list_hwbutton_values"
-			android:defaultValue="None"
+			android:defaultValue="Tab"
 			/>
 
 		<ListPreference
@@ -144,6 +144,15 @@
 			android:defaultValue="None"
 			/>
 
+		<ListPreference
+			android:key="ptt"
+			android:title="@string/pref_ptt_title"
+			android:summary="@string/pref_ptt_summary"
+			android:entries="@array/list_hwbutton"
+			android:entryValues="@array/list_hwbutton_values"
+			android:defaultValue="Monitor Key"
+			/>
+
 		<CheckBoxPreference
 			android:key="keepalive"
 			android:title="@string/pref_keepalive_title"
--- a/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Sun Jun 22 07:57:20 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Sun Jun 22 13:02:36 2014 -0700
@@ -316,9 +316,9 @@
         sendScreen(MONITOR_CMD_ACTIVATE);
     }
 
-    public synchronized void keyState(int b) {
+    public synchronized void keyState(boolean down) {
         char[] arg = new char[3];
-        arg[2] = (char)(b & 0x0000ffff);
+        arg[2] = (char)((down) ? 1 : 0);
         monitorWrite(MONITOR_CMD_KEYSTATE, arg);
     }
 
--- a/src/com/five_ten_sg/connectbot/transport/AbsTransport.java	Sun Jun 22 07:57:20 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/transport/AbsTransport.java	Sun Jun 22 13:02:36 2014 -0700
@@ -51,16 +51,14 @@
         }
 
         // monitor injecting a field
-        @Override
-        public void setField(int l, int c, char [] data) {
-            byte[] b = new byte[data.length];
-            int i;
+        //@Override
+        //public void setField(int l, int c, char [] data)
+        // implementation in the base vt320
 
-            for (i = 0; i < b.length; i++) {
-                b[i] = (byte)(data[i] & 0x00ff);
-            }
-
-            write(b);
+        // terminal key listener found special key, send notification to monitor
+        @Override
+        public void monitorKey(boolean down) {
+            if (bridge.monitor != null) bridge.monitor.keyState(down);
         }
 
         // terminal key listener sending to the host
--- a/src/com/five_ten_sg/connectbot/transport/TN5250.java	Sun Jun 22 07:57:20 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/transport/TN5250.java	Sun Jun 22 13:02:36 2014 -0700
@@ -142,6 +142,12 @@
             screen52.setField(l, c, data);
         }
 
+        // terminal key listener found special key, send notification to monitor
+        @Override
+        public void monitorKey(boolean down) {
+            if (bridge.monitor != null) bridge.monitor.keyState(down);
+        }
+
         // terminal key listener sending to local screen
         @Override
         public void write(byte[] b) {
@@ -154,9 +160,20 @@
                 setField(17, 44, new char[] { '1', '2' });
                 keyPressed(KEY_TAB, ' ', 0);
                 keyPressed(KEY_TAB, ' ', 0);
-                setField(-1, -1, new char[] { '2', '3' });
+                setField(-1, -1, new char[] { '3', '4' });
                 setField(18, 44, new char[0]);
-                setField(-1, -1, new char[] { '4', '5' });
+                setField(-1, -1, new char[] { '5', '6' });
+                return;
+            }
+            if (b == 121) {
+                // special case y for testing
+                setField(17, 44, new char[0]);
+                setField(-1, -1, new char[] { '2', '1' });
+                keyPressed(KEY_TAB, ' ', 0);
+                keyPressed(KEY_TAB, ' ', 0);
+                setField(-1, -1, new char[] { '4', '3' });
+                setField(18, 44, new char[0]);
+                setField(-1, -1, new char[] { '6', '5' });
                 return;
             }
             if (controls.containsKey(b)) keyPressed(controls.get(b), ' ', 0);
--- a/src/com/five_ten_sg/connectbot/util/PreferenceConstants.java	Sun Jun 22 07:57:20 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/util/PreferenceConstants.java	Sun Jun 22 13:02:36 2014 -0700
@@ -55,18 +55,23 @@
     public static final String KEYMODE_RIGHT = "Use right-side keys";
     public static final String KEYMODE_LEFT = "Use left-side keys";
 
+    // must match android:key values in preferences.xml
     public static final String CAMERA = "camera";
     public static final String VOLUP = "volup";
     public static final String VOLDN = "voldn";
     public static final String SEARCH = "search";
+    public static final String PTT = "ptt";
 
+    // must match arrays.xml/list_hw_button_values
+    public static final String HWBUTTON_CTRL = "CTRL";
+    public static final String HWBUTTON_ESC = "Esc";
+    public static final String HWBUTTON_TAB  = "Tab";
     public static final String HWBUTTON_SCREEN_CAPTURE = "Screen Capture";
     public static final String HWBUTTON_CTRLA_SPACE = "Ctrl+A then Space";
     public static final String HWBUTTON_CTRLA = "Ctrl+A";
-    public static final String HWBUTTON_ESC = "Esc";
     public static final String HWBUTTON_ESC_A = "Esc+A";
-    public static final String HWBUTTON_CTRL = "CTRL";
-    public static final String HWBUTTON_TAB  = "Tab";
+    public static final String HWBUTTON_MONITOR = "Monitor Key";
+    public static final String HWBUTTON_NONE = "None";
 
     public static final String KEEP_ALIVE = "keepalive";
 
--- a/src/de/mud/terminal/vt320.java	Sun Jun 22 07:57:20 2014 -0700
+++ b/src/de/mud/terminal/vt320.java	Sun Jun 22 13:02:36 2014 -0700
@@ -78,6 +78,10 @@
         write(b);
     }
 
+    public void monitorKey(boolean down) {
+        // do nothing
+    }
+
     /**
      * Play the beep sound ...
      */