|
14 | 14 | #import <VideoSubscriberAccount/VideoSubscriberAccount.h> |
15 | 15 | #import <AVFoundation/AVFoundation.h> |
16 | 16 | #import <CoreMotion/CoreMotion.h> |
| 17 | +#import <GameController/GameController.h> |
17 | 18 |
|
18 | 19 | __attribute__((visibility("hidden"))) |
19 | 20 | @interface PTSwizzleLoader : NSObject |
@@ -62,6 +63,30 @@ - (void) swizzleExchangeMethod:(SEL)origSelector withMethod:(SEL)newSelector |
62 | 63 | method_exchangeImplementations(originalMethod, swizzledMethod); |
63 | 64 | } |
64 | 65 |
|
| 66 | ++ (void) swizzleClassMethod:(SEL)origSelector withMethod:(SEL)newSelector { |
| 67 | + Class cls = object_getClass((id)self); |
| 68 | + Method originalMethod = class_getClassMethod(cls, origSelector); |
| 69 | + Method swizzledMethod = class_getClassMethod(cls, newSelector); |
| 70 | + |
| 71 | + if (class_addMethod(cls, |
| 72 | + origSelector, |
| 73 | + method_getImplementation(swizzledMethod), |
| 74 | + method_getTypeEncoding(swizzledMethod))) { |
| 75 | + class_replaceMethod(cls, |
| 76 | + newSelector, |
| 77 | + method_getImplementation(originalMethod), |
| 78 | + method_getTypeEncoding(originalMethod)); |
| 79 | + } else { |
| 80 | + class_replaceMethod(cls, |
| 81 | + newSelector, |
| 82 | + class_replaceMethod(cls, |
| 83 | + origSelector, |
| 84 | + method_getImplementation(swizzledMethod), |
| 85 | + method_getTypeEncoding(swizzledMethod)), |
| 86 | + method_getTypeEncoding(originalMethod)); |
| 87 | + } |
| 88 | +} |
| 89 | + |
65 | 90 | - (BOOL) hook_prefersPointerLocked { |
66 | 91 | return false; |
67 | 92 | } |
@@ -160,6 +185,14 @@ - (instancetype)hook_CMMotionManager_init { |
160 | 185 | return motionManager; |
161 | 186 | } |
162 | 187 |
|
| 188 | ++ (GCMouse *)hook_GCMouse_current { |
| 189 | + return nil; |
| 190 | +} |
| 191 | + |
| 192 | ++ (NSArray *)hook_GCMouse_mice { |
| 193 | + return @[]; |
| 194 | +} |
| 195 | + |
163 | 196 | // Hook for UIUserInterfaceIdiom |
164 | 197 |
|
165 | 198 | // - (long long) hook_userInterfaceIdiom { |
@@ -301,6 +334,11 @@ + (void)load { |
301 | 334 | if ([[PlaySettings shared] limitMotionUpdateFrequency]) { |
302 | 335 | [objc_getClass("CMMotionManager") swizzleInstanceMethod:@selector(init) withMethod:@selector(hook_CMMotionManager_init)]; |
303 | 336 | } |
| 337 | + |
| 338 | + if (([[PlaySettings shared] disableBuiltinMouse])) { |
| 339 | + [objc_getClass("GCMouse") swizzleClassMethod:@selector(current) withMethod:@selector(hook_GCMouse_current)]; |
| 340 | + [objc_getClass("GCMouse") swizzleClassMethod:@selector(mice) withMethod:@selector(hook_GCMouse_mice)]; |
| 341 | + } |
304 | 342 | } |
305 | 343 |
|
306 | 344 | @end |
0 commit comments