]> git.saurik.com Git - veency.git/commitdiff
Ported Veency to 3.x.
authorJay Freeman (saurik) <saurik@saurik.com>
Sun, 12 Jul 2009 13:08:03 +0000 (13:08 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Sun, 12 Jul 2009 13:08:03 +0000 (13:08 +0000)
Hook.mm [new file with mode: 0644]
Tweak.mm
VeencyHook.plist [new file with mode: 0644]
control
makefile

diff --git a/Hook.mm b/Hook.mm
new file mode 100644 (file)
index 0000000..00ce7e9
--- /dev/null
+++ b/Hook.mm
@@ -0,0 +1,9 @@
+#include <dlfcn.h>
+#include <objc/runtime.h>
+
+extern "C" void TweakInitialize() {
+    if (Class star = objc_getClass("UIKeyboardLayoutStar")) {
+        Method method(class_getInstanceMethod(objc_getClass("UIKeyboardLayoutRoman"), @selector(handleHardwareKeyDownFromSimulator:)));
+        class_addMethod(star, @selector(handleHardwareKeyDownFromSimulator:), method_getImplementation(method), method_getTypeEncoding(method));
+    }
+}
index f405c4f2e57b255d105b0f7a06ee69879e22d131..dea38a3b1866deac6f7f1291cda984f5bccf8068 100644 (file)
--- a/Tweak.mm
+++ b/Tweak.mm
@@ -50,8 +50,7 @@
 #import <Foundation/Foundation.h>
 #import <IOMobileFramebuffer/IOMobileFramebuffer.h>
 #import <IOKit/IOKitLib.h>
-#import <UIKit/UIModalView.h>
-#import <UIKit/UIModalView-Private.h>
+#import <UIKit/UIKit.h>
 
 #import <SpringBoard/SBAlertItemsController.h>
 #import <SpringBoard/SBDismissOnlyAlertItem.h>
@@ -150,6 +149,9 @@ void VNCAlertItem$performUnlockAction(id self, SEL sel) {
 
 @end
 
+static mach_port_t (*GSTakePurpleSystemEventPort)(void);
+static bool PurpleAllocated;
+
 static void VNCPointer(int buttons, int x, int y, rfbClientPtr client) {
     x_ = x; y_ = y;
     int diff = buttons_ ^ buttons;
@@ -247,14 +249,14 @@ static void VNCPointer(int buttons, int x, int y, rfbClientPtr client) {
 
         if (port == 0) {
             if (purple == 0)
-                purple = GSCopyPurpleSystemEventPort();
+                purple = (*GSTakePurpleSystemEventPort)();
             port = purple;
         }
 
         GSSendEvent(&event.record, port);
     }
 
-    if (purple != 0)
+    if (purple != 0 && PurpleAllocated)
         mach_port_deallocate(mach_task_self(), purple);
 }
 
@@ -270,18 +272,9 @@ static void VNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client) {
     if (key > 0xfff)
         return;
 
-    struct {
-        struct GSEventRecord record;
-        struct GSEventKeyInfo data;
-    } event;
-
-    memset(&event, 0, sizeof(event));
-
-    event.record.type = GSEventTypeKeyDown;
-    event.record.timestamp = GSCurrentEventTimestamp();
-    event.record.size = sizeof(event.data);
-
-    event.data.character = key;
+    GSEventRef event(_GSCreateSyntheticKeyEvent(key, YES, YES));
+    GSEventRecord *record(_GSEventGetGSEventRecord(event));
+    record->type = GSEventTypeKeyDown;
 
     mach_port_t port(0);
 
@@ -292,8 +285,21 @@ static void VNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client) {
                 port = [display clientPortAtPosition:CGPointMake(x_, y_)];
     }
 
+    mach_port_t purple(0);
+
+    if (port == 0) {
+        if (purple == 0)
+            purple = (*GSTakePurpleSystemEventPort)();
+        port = purple;
+    }
+
     if (port != 0)
-        GSSendEvent(&event.record, port);
+        GSSendEvent(record, port);
+
+    if (purple != 0 && PurpleAllocated)
+        mach_port_deallocate(mach_task_self(), purple);
+
+    CFRelease(event);
 }
 
 static void VNCDisconnect(rfbClientPtr client) {
@@ -413,6 +419,12 @@ MSHook(kern_return_t, IOMobileFramebufferSwapSetLayer,
 }
 
 extern "C" void TweakInitialize() {
+    GSTakePurpleSystemEventPort = reinterpret_cast<mach_port_t (*)()>(dlsym(RTLD_DEFAULT, "GSGetPurpleSystemEventPort"));
+    if (GSTakePurpleSystemEventPort == NULL) {
+        GSTakePurpleSystemEventPort = reinterpret_cast<mach_port_t (*)()>(dlsym(RTLD_DEFAULT, "GSCopyPurpleSystemEventPort"));
+        PurpleAllocated = true;
+    }
+
     MSHookFunction(&IOMobileFramebufferSwapSetLayer, &$IOMobileFramebufferSwapSetLayer, &_IOMobileFramebufferSwapSetLayer);
 
     $SBAlertItemsController = objc_getClass("SBAlertItemsController");
diff --git a/VeencyHook.plist b/VeencyHook.plist
new file mode 100644 (file)
index 0000000..2ab5990
Binary files /dev/null and b/VeencyHook.plist differ
diff --git a/control b/control
index 2205a75c22ec2be13dcd1fe594fae65fcb1fbb26..9366e92f3a01a7f95e4625bb2b955e1098821dd6 100644 (file)
--- a/control
+++ b/control
@@ -5,10 +5,10 @@ Priority: optional
 Section: Networking
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
-Version: 0.9.2765-1
+Version: 0.9.2970-1
 Description: a VNC /server/ for the iPhone
 Name: Veency
-Depends: mobilesubstrate (>= 0.9.2587-1), libvncserver
+Depends: mobilesubstrate (>= 0.9.2966-1), libvncserver
 Author: Jay Freeman (saurik) <saurik@saurik.com>
 Depiction: http://cydia.saurik.com/info/veency/
 Tag: purpose::daemon, role::enduser
index 3f0ac4b88c8870c7a91f0cc4388590253c165769..84c3b3ae91846d37738d1c852045acf173cc26c6 100644 (file)
--- a/makefile
+++ b/makefile
@@ -4,6 +4,13 @@ flags := -lvncserver -framework IOMobileFramebuffer -framework CoreSurface -fram
 base := ../tweaks
 include ../tweaks/tweak.mk
 
+all: VeencyHook.dylib
+
+VeencyHook.dylib: Hook.mm makefile
+       $(target)g++ -dynamiclib -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -init _TweakInitialize -lobjc
+       ldid -S $@
+
 extra:
+       cp -a VeencyHook.dylib VeencyHook.plist package/Library/MobileSubstrate/DynamicLibraries
        mkdir -p package/System/Library/CoreServices/SpringBoard.app
        cp -a Default_Veency.png FSO_Veency.png package/System/Library/CoreServices/SpringBoard.app