]> git.saurik.com Git - veency.git/commitdiff
Somewhat got the iPad keyboard working. v0.9.3167
authorJay Freeman (saurik) <saurik@saurik.com>
Thu, 29 Apr 2010 08:58:17 +0000 (08:58 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 29 Apr 2010 08:58:17 +0000 (08:58 +0000)
Tweak.mm
control
makefile

index f64bcc419992f9a831cce73c7263c20be2c131b2..00467083f5fd30296702cfa651706dbe35aad95c 100644 (file)
--- a/Tweak.mm
+++ b/Tweak.mm
@@ -394,6 +394,9 @@ static void VNCPointer(int buttons, int x, int y, rfbClientPtr client) {
         mach_port_deallocate(mach_task_self(), purple);
 }
 
+GSEventRef (*$GSEventCreateKeyEvent)(int, CGPoint, CFStringRef, CFStringRef, id, UniChar, short, short);
+GSEventRef (*$GSCreateSyntheticKeyEvent)(UniChar, BOOL, BOOL);
+
 static void VNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client) {
     if (!down)
         return;
@@ -406,9 +409,21 @@ static void VNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client) {
     if (key > 0xfff)
         return;
 
-    GSEventRef event(_GSCreateSyntheticKeyEvent(key, YES, YES));
-    GSEventRecord *record(_GSEventGetGSEventRecord(event));
-    record->type = GSEventTypeKeyDown;
+    CGPoint point(CGPointMake(x_, y_));
+
+    UniChar unicode(key);
+    CFStringRef string(NULL);
+
+    GSEventRef event0, event1(NULL);
+    if ($GSEventCreateKeyEvent != NULL) {
+        string = CFStringCreateWithCharacters(kCFAllocatorDefault, &unicode, 1);
+        event0 = (*$GSEventCreateKeyEvent)(10, point, string, string, nil, unicode, 0, 1);
+        event1 = (*$GSEventCreateKeyEvent)(11, point, string, string, nil, unicode, 0, 1);
+    } else if ($GSCreateSyntheticKeyEvent != NULL) {
+        event0 = (*$GSCreateSyntheticKeyEvent)(unicode, YES, YES);
+        GSEventRecord *record(_GSEventGetGSEventRecord(event0));
+        record->type = GSEventTypeKeyDown;
+    } else return;
 
     mach_port_t port(0);
 
@@ -416,7 +431,7 @@ static void VNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client) {
         NSArray *displays([server displays]);
         if (displays != nil && [displays count] != 0)
             if (CAWindowServerDisplay *display = [displays objectAtIndex:0])
-                port = [display clientPortAtPosition:CGPointMake(x_, y_)];
+                port = [display clientPortAtPosition:point];
     }
 
     mach_port_t purple(0);
@@ -427,13 +442,20 @@ static void VNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client) {
         port = purple;
     }
 
-    if (port != 0)
-        GSSendEvent(record, port);
+    if (port != 0) {
+        GSSendEvent(_GSEventGetGSEventRecord(event0), port);
+        if (event1 != NULL)
+            GSSendEvent(_GSEventGetGSEventRecord(event1), port);
+    }
 
     if (purple != 0 && PurpleAllocated)
         mach_port_deallocate(mach_task_self(), purple);
 
-    CFRelease(event);
+    CFRelease(event0);
+    if (event1 != NULL)
+        CFRelease(event1);
+    if (string != NULL)
+        CFRelease(string);
 }
 
 static void VNCDisconnect(rfbClientPtr client) {
@@ -604,6 +626,11 @@ MSHook(void, rfbRegisterSecurityHandler, rfbSecurityHandler *handler) {
     [pool release];
 }
 
+template <typename Type_>
+static void dlset(Type_ &function, const char *name) {
+    function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
+}
+
 MSInitialize {
     NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
 
@@ -620,6 +647,9 @@ MSInitialize {
     else
         Level_ = 0;
 
+    dlset($GSEventCreateKeyEvent, "GSEventCreateKeyEvent");
+    dlset($GSCreateSyntheticKeyEvent, "_GSCreateSyntheticKeyEvent");
+
     MSHookFunction(&IOMobileFramebufferSwapSetLayer, MSHake(IOMobileFramebufferSwapSetLayer));
     MSHookFunction(&rfbRegisterSecurityHandler, MSHake(rfbRegisterSecurityHandler));
 
diff --git a/control b/control
index 8c20f8d898956e9fde17126fa6daa94bf5d4a061..bd14fd93c306d461d23573a5db6a496f111cac8e 100644 (file)
--- a/control
+++ b/control
@@ -5,7 +5,7 @@ Priority: optional
 Section: Networking
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
-Version: 0.9.3165-1
+Version: 0.9.3167-1
 Description: a VNC /server/ for the iPhone
 Name: Veency
 Depends: mobilesubstrate (>= 0.9.2966-1), libvncserver, com.saurik.iphone.ske, preferenceloader, jp.ashikase.mousesupport | firmware (<< 3.0)
index 3f0ac4b88c8870c7a91f0cc4388590253c165769..03f593a8e94c28182acff2c67609380b89d3ca27 100644 (file)
--- a/makefile
+++ b/makefile
@@ -1,6 +1,6 @@
 name := Veency
 id := vncs
-flags := -lvncserver -framework IOMobileFramebuffer -framework CoreSurface -framework IOKit -framework GraphicsServices -I/apl/inc/iPhoneOS-2.0 -framework QuartzCore
+flags := -lvncserver -framework IOMobileFramebuffer -framework CoreSurface -framework IOKit -framework GraphicsServices -I/apl/inc/iPhoneOS-2.0 -framework QuartzCore -weak_reference_mismatches weak
 base := ../tweaks
 include ../tweaks/tweak.mk