mdiiorio / isynergyclient

Automatically exported from code.google.com/p/isynergyclient
0 stars 0 forks source link

Feature: Keyboard Support #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Feature Req: Keyboard support using HID-Support

Below is a patch that adds keyboard support using your HID-SUPPORT. The old 
mouse support was left in place since it displays the cursor and seemed to work 
better on my device (iPad 2 5.0.1)

Add libhidsupport.dylib to the project, and its header:

### Eclipse Workspace Patch 1.0
#P iSynergyClient
Index: SynergyClient.h
===================================================================
--- SynergyClient.h (revision 2)
+++ SynergyClient.h (working copy)
@@ -84,6 +84,7 @@

 -(BOOL) openConnection:(NSString *) remote;
 -(void) handleSocketCallback;
+- (void) sendResetOptionsMessage;
 -(void) handleMessageWithLen:(uint16_t)len;
 -(NSString *) connectionStatus;
 -(BOOL) isConnecting;
@@ -98,6 +99,8 @@
 -(NSString *) serverAddress;
 -(void) setClientName:(NSString *) clientName;
 -(NSString *) clientName;
+-(BOOL) homeButtonHotkey;
+-(void) setHomeButtonHotKey:(BOOL) homeButtonHotKey;
 -(CLIENT_STATE) clientState;
 @property (nonatomic, assign) id delegate;
 @property (nonatomic, retain) NSString *connectionError;
Index: ConfigurationViewController.m
===================================================================
--- ConfigurationViewController.m   (revision 2)
+++ ConfigurationViewController.m   (working copy)
@@ -39,6 +39,7 @@
 @synthesize serverAddress;
 @synthesize clientName;
 @synthesize activeSwitch;
+@synthesize homeButtonSwitch;
 @synthesize activityIndicator;

 #pragma mark -
@@ -103,7 +104,7 @@

 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
     // Return the number of sections.
-    return 3;
+    return 4;
 }

 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
@@ -112,7 +113,7 @@
 }

 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
-   static NSString * titles[] = { @"Server Address", @"Client Name", 
@"Activation", @"Status", @"Keyboard Support"}; 
+   static NSString * titles[] = { @"Server Address", @"Client Name", @"Special 
Keys", @"Activation", @"Status", @"Keyboard Support"}; 
    return titles[section];
 }

@@ -156,6 +157,12 @@
                    }
                    break;
                case 2:
+                    cell.textLabel.text = @"Home Button Hot Key";
+                   homeButtonSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
+                   homeButtonSwitch.on = [synergyClient homeButtonHotkey];
+                   cell.accessoryView = homeButtonSwitch;
+                   break;
+               case 3:
                    cell.textLabel.text = @"Mouse";
                    activeSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
                    activeSwitch.on = [synergyClient enabled];
@@ -163,9 +170,6 @@
                    activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
                    cell.accessoryView = activeSwitch;
                    break;
-               case 3:
-                   // cell.textLabel.text = [synergyClient connectionStatus];
-                   break;
                case 4:
                    cell.textLabel.text = @"Purchase BTstack Keyboard from Cydia Store";
                    // keyboard support installed?
@@ -197,12 +201,13 @@
        NSString * helpTexts[] = {
            @"IP address of Synergy server, either as dot notation like 192.168.3.2 or server.home.com",
            @"Client name as configured on server, leave empty for local hostname",
+            @"Use Command + Shift + H to simulate pressing the Home button?",
            @"Start/stop connection to server",
            @"Current status, indicates if connection was established successfully",
            @"To enter text, the BTstack Keyboard package is required"
        };

-       if ([indexPath indexAtPosition:0] == 2) {
+       if ([indexPath indexAtPosition:0] == 3) {
            cell.textLabel.text = [NSString stringWithFormat:@"Current status: %@", [synergyClient connectionStatus]];
            CLIENT_STATE state = [synergyClient clientState];
            switch (state) {
@@ -310,6 +315,7 @@
 - (void) updateDefaultsFromView {
    [synergyClient setClientName:clientName.text];
    [synergyClient setServerAddress:serverAddress.text];
+    [synergyClient setHomeButtonHotKey:homeButtonSwitch.on];
    [synergyClient setEnabled:activeSwitch.on];
 }

@@ -322,6 +328,7 @@
    [BackgroundApplication setRunInBackground:NO];
    serverAddress.enabled = YES;
    clientName.enabled = YES;
+    homeButtonSwitch.enabled = YES;
    serverAddress.borderStyle = UITextBorderStyleBezel;
    clientName.borderStyle = UITextBorderStyleBezel;
 }
@@ -350,6 +357,7 @@
        clientName.borderStyle = 0;
        serverAddress.enabled = NO;
        clientName.enabled = NO;
+        homeButtonSwitch.enabled = NO;
        [self.tableView reloadData];
        [BackgroundApplication setRunInBackground:YES];

@@ -385,6 +393,7 @@
    [clientName release];
    [activeSwitch release];
    [activityIndicator release];
+    [homeButtonSwitch release];
 }

 @end
Index: ConfigurationViewController.h
===================================================================
--- ConfigurationViewController.h   (revision 2)
+++ ConfigurationViewController.h   (working copy)
@@ -37,6 +37,7 @@
    UITextField *serverAddress;
    UITextField *clientName;
    UISwitch *activeSwitch;
+    UISwitch *homeButtonSwitch;
    UIActivityIndicatorView *activityIndicator;
 }
 - (void) updateDefaultsFromView;
@@ -44,5 +45,6 @@
 @property (nonatomic, retain) UITextField *serverAddress;
 @property (nonatomic, retain) UITextField *clientName;
 @property (nonatomic, retain) UISwitch *activeSwitch;
+@property (nonatomic, retain) UISwitch *homeButtonSwitch;
 @property (nonatomic, retain) UIActivityIndicatorView *activityIndicator;
 @end
Index: SynergyClient.m
===================================================================
--- SynergyClient.m (revision 2)
+++ SynergyClient.m (working copy)
@@ -45,9 +45,11 @@

 #include "mouse_msgs.h"
 #import "../libactivator/libactivator.h"
+#import "hid-support.h"

 NSString *keyServerAddress = @"ServerAddress";
 NSString *keyClientName    = @"ClientName";
+NSString *keyHomeButtonHotkey = @"HomeButtonHotKey";
 NSString *keyActivatorDefautsApplied = @"ActivatorDefaultsApplied";

 const char*     kMsgHello          = "Synergy%2i%2i";
@@ -87,6 +89,10 @@

 #define KEEPALIVE_PERIOD 2

+
+//not the best place for it, but im lazy
+NSInteger printableCharacters[] = 
{32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,5
8,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,
85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108
,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,128,129
,130,131,132,134,135,137,139,140,141,142,143,144,145,146,147,148,149,151,153,155
,156,157,158,161,162,163,164,165,166,167,169,170,171,172,174,175,176,177,178,179
,181,182,183,184,185,186,187,188,189,190,191,197,198,199,208,215,216,222,223,229
,230,231,240,247,248,254};
+
 static void socketDataCallback (CFSocketRef s,
                                CFSocketCallBackType callbackType,
                                CFDataRef address,
@@ -520,36 +537,87 @@
    if (strncmp(kMsgDKeyDown, (char*)message, 4) == 0){
        int a1, a2, a3;
        [self parseMessage:kMsgDKeyDown, &a1, &a2, &a3];
-       // NSLog(@("kMsgDKeyDown ID %04x, MASK %04x, BUTTON %04x\n", a1, a2, a3);
-       if (a1 == 0xefe1) {
-           shiftDown = 1;
-       }
-       if (a1 == 0xefe3) {
-           ctrlDown = 1;
-       }
-       // NSLog(@("CtrlActive = %u, ShiftActive = %u\n", ctrlDown, shiftDown);
+        //NSLog(@"kMsgDKeyDown ID %04x, MASK %04x, BUTTON %04x\n", a1, a2, a3);
+        //NSLog(@"DOWN %u, %u, %u\n", a1, a2, a3);
+        //Do some checking that function keys are translated properly
+        //if its not a printable character and not a supported function key 
dont emulate it
+        //here are the function keys we're going to support.
+        /*
+        NSUpArrowFunctionKey  61266
+        NSDownArrowFunctionKey  61268
+        NSLeftArrowFunctionKey  61265
+        NSRightArrowFunctionKey  61267
+        NSBackspaceKey  61192
+        NSCarriageReturnKey 61197
+        NSDeleteKey
+         */
+        switch (a1) {
+            case 61266:
+                a1 = NSUpArrowFunctionKey;
+                break;
+            case 61268:
+                a1 = NSDownArrowFunctionKey;
+                break;
+            case 61265:
+                a1 = NSLeftArrowFunctionKey;
+                break;
+            case 61267:
+                a1 = NSRightArrowFunctionKey;
+                break;
+            case 61192:
+                a1 = NSBackspaceKey;
+                break;
+            case 61197:
+                a1 = NSCarriageReturnKey;
+                break;
+            default:{
+                //cant call contains with an int, run through the array, if 
found, break, else return
+                BOOL found = NO;
+                int len=sizeof(printableCharacters)/sizeof(int);
+                for (int i=0;i<len; i++){
+                    if(a1 == printableCharacters[i]){
+                        found = YES;
+                        break;
+                    }
+                }
+                if(!found){
+                    return;
+                }
+            }
+                break;
+        }
+        
+        //Shift+apple+H = home key
+        //HWButtonHome
+        if(a1 == 72 && a3 == 5 &&  [self homeButtonHotkey]){
+            hid_inject_button_down(HWButtonHome);
+            hid_inject_button_up(HWButtonHome);
+            return;
+        }
+        
+        hid_inject_key_down(a1, 0);
+       // NSLog(@"CtrlActive = %u, ShiftActive = %u\n", ctrlDown, shiftDown);
    }       
    if (strncmp(kMsgDKeyUp, (char*)message, 4) == 0){
        int a1, a2, a3;
        [self parseMessage:kMsgDKeyUp, &a1, &a2, &a3];
-       // NSLog(@("kMsgDKeyUp ID %04x, MASK %04x, BUTTON %04x\n", a1, a2, a3);
-       if (a1 == 0xefe1) {
-           shiftDown = 0;
-       }
-       if (a1 == 0xefe3) {
-           ctrlDown = 0;
-       }
-       // NSLog(@("CtrlActive = %u, ShiftActive = %u\n", ctrlDown, shiftDown);
+       //NSLog(@"kMsgDKeyUp ID %04x, MASK %04x, BUTTON %04x\n", a1, a2, a3);
+        //NSLog(@"UP %u, %u, %u\n", a1, a2, a3);
+        
+        //a1 is always 0, problem with parse message? or by design?
+        hid_inject_key_up(a1);
+       // NSLog(@"CtrlActive = %u, ShiftActive = %u\n", ctrlDown, shiftDown);
    }       
    if (strncmp(kMsgDMouseMove, (char*)message, 4) == 0){
        int x, y;
        [self parseMessage:kMsgDMouseMove, &x, &y];
        mouseX = x; mouseY = y;
-       mouseSendEvent( mouseX, mouseY, mouseButton);
+        //hid_inject_mouse_abs_move(mouseButton, mouseX, mouseY);
+        mouseSendEvent( mouseX, mouseY, mouseButton);
+        //NSLog(@"Mouse button %u at %f,%f\n", mouseButton, mouseX, mouseY);
    }
    if (strncmp(kMsgDMouseDown, (char*)message, 4) == 0){
-
-       int button;
+        int button;
        [self parseMessage:kMsgDMouseDown, &button];

        // simulate middle/right mouse button
@@ -596,15 +664,17 @@
        } else {
            mouseButton = 0;
        }
+        //hid_inject_mouse_abs_move(mouseButton, mouseX, mouseY);
        mouseSendEvent( mouseX, mouseY, mouseButton);
-       // NSLog(@("Mouse down %u at %f,%f\n", button, mouseX, mouseY);
+       // NSLog(@"Mouse down %u at %f,%f\n", mouseButton, mouseX, mouseY);
    }
    if (strncmp(kMsgDMouseUp, (char*)message, 4) == 0){
        int i;
        [self parseMessage:kMsgDMouseUp, &i];
        mouseButton = 0;
+        //hid_inject_mouse_abs_move(mouseButton, mouseX, mouseY);
        mouseSendEvent( mouseX, mouseY, mouseButton);
-       // NSLog(@("Mouse up %u at %f,%f\n", i, mouseX, mouseY);
+       // NSLog(@"Mouse up %u at %f,%f\n", mouseButton, mouseX, mouseY);
    }
    if (strncmp(kMsgCEnter, (char*)message, 4) == 0){
        // connected
@@ -687,7 +757,7 @@
    return _enabled;
 }
 -(BOOL) keyboardSupportInstalled{
-   return NO;
+   return YES;
 }

 -(void) setScreenWidth:(int)width andHeight:(int)height{
@@ -708,4 +778,10 @@
 -(void) setClientName:(NSString *) clientName{
    [[NSUserDefaults standardUserDefaults] setObject:clientName forKey:keyClientName];
 }
+-(BOOL) homeButtonHotkey{
+   return [[NSUserDefaults standardUserDefaults] boolForKey:keyHomeButtonHotkey];
+}
+-(void) setHomeButtonHotKey:(BOOL) homeButtonHotKey{
+   [[NSUserDefaults standardUserDefaults] setBool:homeButtonHotKey 
forKey:keyHomeButtonHotkey];
+}
 @end

Original issue reported on code.google.com by supersai...@gmail.com on 26 May 2012 at 4:17

GoogleCodeExporter commented 9 years ago
For the mouse cursor only using 2/3 of the iPad Air screen (Comment #40, #44, 
#45). Using Flex, you can correct the width/height parameters. It doesn't allow 
rotating the iPad but at least it works:

Class: SynergyClient
Method: -(void) setScreenWidth:(int) andHeight:(int)

Set width to 1024 and height to 768 for landscape. Switch the values if you're 
using portrait orientation. Tested on IOS 8.1.2 using the iSynergyClient from 
http://www.myrepospace.com/profile/thenorth

Original comment by alan.s...@gmail.com on 17 Jan 2015 at 4:51

GoogleCodeExporter commented 9 years ago
I'm working on a little project to make my iphone function as a laptop. I'm 
really close to getting it all to work.
Basically, I want to use a raspberrypi connected to a motorola lapdock as a 
terminal to connect remotely to my iphone 5.
I'm planning on using rplay and airplay mirroring for the video.
Before investigating synergy I tried out hidclient to connect the keyboard and 
mouse over bluetooth, but there wasn't enough documentation for me to get it 
working.
I also know that the Aten Tap Cs533 and the IOGear BLuetooth KVMs would work 
great to convert the usb mouse and keyboard over to bluetooth, but they are 
expensive and bulky.
I then found isynergyclient and deciced to give it a try. I too had the same 
issue with the mouse not covering the full screen.
I downloaded Full Force and had to set it to expand to iphone 6 screen size 
since I'm also using the Little Brother screen zoom hack.
Anyway, everything works great now except backspace and the arrow keys. I tried 
mapping the "\" key to backspace instead, but it's like the isynergyclient 
can't even pass the command to the phone.
Also, the on screen keyboard won't go away. Has anyone found a fix to these 
issues? It's just so anoying to be a backspace button and a couple of arrow 
keys away from finishing my project.
Anyway, I'm not much of a programmer so keep that in mind for your responses. 

Original comment by maedanie...@gmail.com on 22 Feb 2015 at 10:19

GoogleCodeExporter commented 9 years ago
I tested thenorth iSynergyClient 0.9-2 and orientationnotify 0.1.0-2 on an iPad 
Air Retina (iOS 8.1.2). The synergy server is a Windows 8.1 with Synergy 
version 1.3.1.

The landscape mode / rotation doesn't work. The event is ignored, independant 
of the iSynergyClient being in foreground or background. The portrait mode 
works fine.

I installed the software via Cydia from thenorth.

Did somebody already patch it into portrait mode and has got a binary package?

Original comment by wishi...@gmail.com on 2 Mar 2015 at 7:36

GoogleCodeExporter commented 9 years ago
AFAIK no one has patched rotation yet (iOS 8 changed a lot of things with 
rotation), though someone did fork the code on github 
https://github.com/supersaiyen/iSynergyClient 

Original comment by supersai...@gmail.com on 2 Mar 2015 at 8:08

GoogleCodeExporter commented 9 years ago
I've just followed the workaround in comment #51 but it's not working for me. 
I'm also using an iPad Air on iOS 8.1.2 and the cursor bumps up against that 
invisible wall. Does the version or variety of Synergy server have any effect 
on this issue? I'm using Synergy 1.5.0 in Win 7.

Original comment by tye...@gmail.com on 5 Mar 2015 at 4:39