TTach / isynergyclient

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

Feature: handle orientation changes #3

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Installing latest iSynergyClient 0.8 (with 05-March update - which fixed 
previous CRASH problem that occured!)
2. Using Windows 7 as the server with latest version of server (beta)
3. Activate Mouse in the iSynergyClient App 
4. Get the mouse cursor into the iPad screen (works great!)
5. Open a Note (or other) App and try to type in with the desktop keyboard
6. Change the orientaion of iPad and move the mouse (this is not related to #5 
step)

What is the expected output? What do you see instead?
1. Typing text (inside a focused text field) while inside iPad screen should 
work but it does not do anything (not in iPad and not in Desktop) not matter 
what App is used.
2. (Unrelated to #1) - When changing iPad orientation, the mouse orientation 
should be adjusted but it stays as if the device is still in Portrait mode.

Please provide any additional information below.

Original issue reported on code.google.com by shemesh.mail on 7 Mar 2012 at 5:46

GoogleCodeExporter commented 8 years ago
Sorry only now seen that the project is not supporting keyboard yet.
Still the orientation issue stands

Original comment by shemesh.mail on 7 Mar 2012 at 5:57

GoogleCodeExporter commented 8 years ago
orientation support wasn't implemented either. of course, it would be good to 
have. :) (as well as keyboard support)

Original comment by matthias.ringwald@gmail.com on 21 Mar 2012 at 4:37

GoogleCodeExporter commented 8 years ago
Here's a patch for orientation support below. I started looking at HID-SUPPORT 
as working it in seems really easy, but i couldn't get it integrated with the 
project and the doc is a little sparse (point me in the right direction and 
i'll circle back)

iPad 2 5.0.1 (greenpois0n jailbreak), I do still get a connection broken if 
start touching but implementation of HID-SUPPORT will probably fix that. : 
[SynergyClient handleSocketCallback] Connection broken!

Index: AppDelegate.m
===================================================================
--- AppDelegate.m   (revision 2)
+++ AppDelegate.m   (working copy)
@@ -63,9 +63,33 @@
    // NSLog(@"Screen width = %f, height = %f", screenBound.size.width, screenBound.size.height);
    [synergyClient setScreenWidth:screenBound.size.width andHeight:screenBound.size.height];

+    //saiyen
+    //Detect orientation change
+    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
+    [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(detectOrientation) 
name:@"UIDeviceOrientationDidChangeNotification" object:nil];
+    //saiyen
+    
+    
    return YES;
 }

+//saiyen
+-(void)detectOrientation{
+    UIScreen *screen = [UIScreen mainScreen];
+    CGRect fullScreenRect = screen.bounds; //implicitly in Portrait 
orientation.        
+    
+    if (UIInterfaceOrientationIsLandscape([[UIDevice currentDevice] 
orientation])) 
+    {
+        CGRect temp;
+        temp.size.width = fullScreenRect.size.height;
+        temp.size.height = fullScreenRect.size.width;
+        fullScreenRect = temp;      
+    }
+   [self.synergyClient setScreenWidth:fullScreenRect.size.width 
andHeight:fullScreenRect.size.height];
+    [self.synergyClient sendResetOptionsMessage];
+}
+//saiyen
+
 - (void)applicationWillTerminate:(UIApplication *)application{
    [configViewController updateDefaultsFromView];
 }
Index: SynergyClient.h
===================================================================
--- SynergyClient.h (revision 2)
+++ SynergyClient.h (working copy)
@@ -84,6 +84,9 @@

 -(BOOL) openConnection:(NSString *) remote;
 -(void) handleSocketCallback;
+//saiyen
+- (void) sendResetOptionsMessage;
+//saiyen
 -(void) handleMessageWithLen:(uint16_t)len;
 -(NSString *) connectionStatus;
 -(BOOL) isConnecting;
Index: SynergyClient.m
===================================================================
--- SynergyClient.m (revision 2)
+++ SynergyClient.m (working copy)
@@ -44,7 +44,7 @@
 #include <dlfcn.h>

 #include "mouse_msgs.h"

 NSString *keyServerAddress = @"ServerAddress";
 NSString *keyClientName    = @"ClientName";
@@ -485,6 +485,17 @@
    }
 }

+//saiyen
+//send a screensaver ended message to cause the server to re-query screen 
resolution.
+- (void) sendResetOptionsMessage {
+   if (clientState == STATE_CONNECTED || clientState == STATE_LIVE) {
+        [self deactivateMouse];
+        [self writeMessage:kMsgDInfo, 0, 0, screenWidth, screenHeight, 
screenWidth/2, screenHeight/2];
+        [self activateMouse];
+   }
+}
+//saiyen
+
 - (void) handleMessageWithLen:(uint16_t)len {

    static int mouseButton = 0;
@@ -494,7 +505,7 @@
    static int ctrlDown = 0;
    // int ok;

-   // NSLog(@"Message: '%s'\n", message);
+    NSLog(@"Message: '%s'\n", message);
    // [self hexdump:len];

    if (strncmp("Synergy", (char*)message, 7) == 0){
@@ -520,26 +531,26 @@
    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);
+        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(@"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);
+        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(@"CtrlActive = %u, ShiftActive = %u\n", ctrlDown, shiftDown);
    }       
    if (strncmp(kMsgDMouseMove, (char*)message, 4) == 0){
        int x, y;
@@ -580,13 +591,13 @@
                NSString *currentMode = [activator currentEventMode];
                event = [[[laEventClass alloc] initWithName:eventName mode:currentMode] autorelease];
            } else {
-               // NSLog(@"Activator other button %u", button);
+                NSLog(@"Activator other button %u", button);
            }
            if (event) {
-               // NSLog(@"Activator event %@", eventName);
+                NSLog(@"Activator event %@", eventName);
                [activator sendEventToListener:event];
            } else {
-               // NSLog(@"event creation failed");
+                NSLog(@"event creation failed");
            }
        }

@@ -597,14 +608,14 @@
            mouseButton = 0;
        }
        mouseSendEvent( mouseX, mouseY, mouseButton);
-       // NSLog(@("Mouse down %u at %f,%f\n", button, mouseX, mouseY);
+        NSLog(@"Mouse down %u at %f,%f\n", button, mouseX, mouseY);
    }
    if (strncmp(kMsgDMouseUp, (char*)message, 4) == 0){
        int i;
        [self parseMessage:kMsgDMouseUp, &i];
        mouseButton = 0;
        mouseSendEvent( mouseX, mouseY, mouseButton);
-       // NSLog(@("Mouse up %u at %f,%f\n", i, mouseX, mouseY);
+        NSLog(@"Mouse up %u at %f,%f\n", i, mouseX, mouseY);
    }
    if (strncmp(kMsgCEnter, (char*)message, 4) == 0){
        // connected
Index: mouse_msgs.mm
===================================================================
--- mouse_msgs.mm   (revision 2)
+++ mouse_msgs.mm   (working copy)
@@ -78,8 +78,35 @@
     if (mouseMessagePort) {
         // Create and send message
         MouseEvent event;
-        event.x = x;
-        event.y = y;
+        
+        //saiyen
+        //Get orientation, if orientation is landscape, switch x and y 
optionally invert
+        UIScreen *screen = [UIScreen mainScreen];
+        CGRect fullScreenRect = screen.bounds; //implicitly in Portrait 
orientation.        
+        
+        if (UIInterfaceOrientationIsLandscape([[UIDevice currentDevice] 
orientation])) 
+        {
+            CGRect temp;
+            temp.size.width = fullScreenRect.size.height;
+            temp.size.height = fullScreenRect.size.width;
+            fullScreenRect = temp;      
+        }
+
+        if (([[UIDevice currentDevice] orientation] == 
UIDeviceOrientationLandscapeLeft)) {
+            event.x = fullScreenRect.size.height-y;
+            event.y = x;
+        }else if(([[UIDevice currentDevice] orientation] == 
UIDeviceOrientationLandscapeRight)){
+            event.x = y;
+            event.y = fullScreenRect.size.width-x;
+        }else if (([[UIDevice currentDevice] orientation] == 
UIDeviceOrientationPortraitUpsideDown)) {
+            event.x = fullScreenRect.size.width-x;
+            event.y = fullScreenRect.size.height-y;
+        }else{
+            event.x = x;
+            event.y = y;
+        }
+        //saiyen
+        
         event.absolute = YES;
         event.buttons = buttons;

Original comment by supersai...@gmail.com on 23 May 2012 at 9:12

GoogleCodeExporter commented 8 years ago
Thanks for the patch! That's the first since I've posted the code here more 
than a year ago. I'll try to integrate this and push an update.

hid-support should be very easy to use given the hid-support.h header file. see 
hidsupport test subproject for an example. It still doesn't show a mouse 
pointer tough.

Original comment by matthias.ringwald@gmail.com on 25 May 2012 at 11:44

GoogleCodeExporter commented 8 years ago
would love to see this and the keyboard support patch implemented and pushed to 
cydia!

lovely work :)

Original comment by deese...@gmail.com on 9 Jun 2012 at 4:49

GoogleCodeExporter commented 8 years ago
Any thoughts on when this will be available in Cydia?  The angle is awkward and 
balance is precarious when I use the smart cover to stand this thing up as 
portrait.

Original comment by rockandr...@gmail.com on 6 Jul 2012 at 9:36

GoogleCodeExporter commented 8 years ago
Such a cool app. I'll be the one who requests an update to the deb this month 
;-)

I tried to build the code with the above patch myself to no avail. Please 
Matthias/Super Saiyan share a binary somewhere

Original comment by dhar...@gmail.com on 12 Aug 2012 at 6:53

GoogleCodeExporter commented 8 years ago
Keyboard support would be great, but landscape support is more important. I'm 
also having a little trouble building this myself, so a binary would be awesome!

Original comment by DanH1420 on 15 Feb 2013 at 10:57

GoogleCodeExporter commented 8 years ago
Primarily Landscape please!   And then keyboard support would be nice!

Please!? or point us somewhere to download the compiled deb.

Cheers!

Original comment by fiefie on 21 Mar 2013 at 7:49

GoogleCodeExporter commented 8 years ago
I uploaded a deb in the other issue thread. 
https://code.google.com/p/isynergyclient/issues/detail?id=5#c23

Original comment by supersai...@gmail.com on 8 May 2013 at 2:13