diff src/com/five_ten_sg/connectbot/monitor/MonitorService.java @ 2:f6a1aabf384f

add copyright
author Carl Byington <carl@five-ten-sg.com>
date Mon, 23 Jun 2014 16:57:39 -0700
parents 5564580fe160
children 2be5bca648ab
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/monitor/MonitorService.java	Mon May 05 14:37:11 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/monitor/MonitorService.java	Mon Jun 23 16:57:39 2014 -0700
@@ -33,13 +33,14 @@
 
     public  static final char MONITOR_CMD_INIT         = 0;
     public  static final char MONITOR_CMD_ACTIVATE     = 1;
-    public  static final char MONITOR_CMD_HOSTDATA     = 2;
+    public  static final char MONITOR_CMD_KEYSTATE     = 2;
     public  static final char MONITOR_CMD_CURSORMOVE   = 3;
     public  static final char MONITOR_CMD_SCREENCHANGE = 4;
     public  static final char MONITOR_CMD_FIELDVALUE   = 5;
     public  static final char MONITOR_CMD_SETFIELD     = 5;
     public  static final char MONITOR_CMD_GETFIELD     = 6;
     public  static final char MONITOR_CMD_SCREENWATCH  = 7;
+    public  static final char MONITOR_CMD_DEPRESS      = 8;
 
     public static final int       MONITORPORT = 6000;
 
@@ -249,8 +250,8 @@
                             System.arraycopy(packet, 3, buf, 0, plen-3);
                             teActivate(connection, packet[1], packet[2], buf);
                             break;
-                        case MONITOR_CMD_HOSTDATA:
-                            teHostData(connection, packet[1]);
+                        case MONITOR_CMD_KEYSTATE:
+                            teKeyState(connection, (packet[1] == 1));
                             break;
                         case MONITOR_CMD_CURSORMOVE:
                             teCursorMove(connection, packet[1], packet[2]);
@@ -306,17 +307,18 @@
     public void teInit(int connection, char[] buf) {
         String fn = new String(buf);
         Log.i(TAG, String.format("teInit %d file %s", connection, fn));
-        printer(String.format("init %d %s", connection, fn));
+        //printer(String.format("init %d %s", connection, fn));
     }
 
     public void teActivate(int connection, int lines, int columns, char[] buf) {
         Log.i(TAG, String.format("teActivate %d", connection));
-        printer(String.format("activate %d lines %d columns %d b.len %d", connection, lines, columns, buf.length));
+        //printer(String.format("activate %d lines %d columns %d b.len %d", connection, lines, columns, buf.length));
     }
 
-    public void teHostData(int connection, int keyCode) {
-        Log.i(TAG, String.format("teHostData %d key %d", connection, keyCode));
-        printer(String.format("key %d is %d", connection, keyCode));
+    public void teKeyState(int connection, boolean down) {
+        String d = (down) ? "yes" : "no";
+        Log.i(TAG, String.format("teKeyState %d isdown %s", connection, d));
+        //printer(String.format("keystate %d isdown %s", connection, d));
     }
 
     public void teCursorMove(int connection, int l, int c) {
@@ -381,4 +383,15 @@
     public void teSpeak(int connection, String msg, boolean flush) {
         if (speech) talker.speak(msg, (flush) ? TextToSpeech.QUEUE_FLUSH : TextToSpeech.QUEUE_ADD, null);
     }
+
+    public static void teDepress(int connection, int vk_key) {
+        // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731
+        Log.i(TAG, String.format("teDepress %d, %d", connection, vk_key));
+        CommunicationThread cm = clients.get(connection);
+        if (cm != null) {
+            char[] arg = new char[3];
+            arg[2] = (char) (vk_key & 0x0000ffff);
+            cm.clientWrite(MONITOR_CMD_DEPRESS, arg);
+        }
+    }
 }