Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Remove more PTFakeTouch

Remove CGGeometry Reference

Fix cursor

More cleanup

Axe more unused functions

Fix warning

More unused functions

More unused functions

Remove OS Version Checks

Mac Catalyst on Monterey and Ventura will alwyas be iOS 15+ therefore these platform checks are unnecessary.

Remove unnecessary swizzle

Remove unused struct

Remove more unused structs

Remove more functions

Remove whitespace

Remove UIApplication unused methods

Remove more

Remove private interfaces from KIF headers

Rename folder

Whitespace fixes

Remove unused swizzle method

Whitespace

Move script

Fix comment

Remove unused selectors

Comments

Change to init swizzle

Try again

Bump deployment target + remove folder

- Removed ‘Recovered References’ Folder
- Bump deployment targets to match PlayCover (introduces a couple deprecation warnings)

Fix deprecation warnings

More cursor disable to AKInterface

Remove PTFakeTouch disable cursor

Whitespace

Remove unnecssary Obj-C Hacks (Needs testing)

Seems to work but I don’t entirely understand their original function, so needs to be tested.

Remove check (handled by dispatch_once)

Remove view specification

Whitespace

Remove more

Remove more

Remove more

Add back toucher/view cacher

Remove unused available checks

Simplify PlayLoader

- `dyld_get_base_platform` returns PLATFORM_IOS even when passed PLATFORM_IOSMAC
- `sysctlbyname` calls `sysctl` under the hood
-  `csops` Nothing is changed

Add comments to PlayLoader

Add source

Fix compilation error

Add back sysctlbyname interpose

Fix indentation

Remove unused PlayUI

Remove unused FileManager extension

Remove some unused variables + cleanup
  • Loading branch information
IsaacMarovitz committed Nov 9, 2022
1 parent df1ef2a commit e3e422b
Show file tree
Hide file tree
Showing 42 changed files with 292 additions and 2,227 deletions.
3 changes: 3 additions & 0 deletions AKPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import AppKit
import CoreGraphics
import Foundation

class AKPlugin: NSObject, Plugin {
Expand Down Expand Up @@ -38,10 +39,12 @@ class AKPlugin: NSObject, Plugin {

func hideCursor() {
NSCursor.hide()
CGAssociateMouseAndMouseCursorPosition(0)
}

func unhideCursor() {
NSCursor.unhide()
CGAssociateMouseAndMouseCursorPosition(1)
}

func terminateApplication() {
Expand Down
172 changes: 10 additions & 162 deletions PlayTools.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions PlayTools/Controls/ControlMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ public class ControlMode {
}
if PlaySettings.shared.mouseMapping {
AKInterface.shared!.unhideCursor()
disableCursor(1)
}
PlayInput.shared.invalidate()
}
} else {
if visible {
if PlaySettings.shared.mouseMapping {
AKInterface.shared!.hideCursor()
disableCursor(0)
}
if screen.fullscreen {
screen.switchDock(false)
Expand Down
5 changes: 1 addition & 4 deletions PlayTools/Controls/MenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,9 @@ var keymappingSelectors = [#selector(UIApplication.switchEditorMode(_:)),

class MenuController {
init(with builder: UIMenuBuilder) {
if #available(iOS 15.0, *) {
builder.insertSibling(MenuController.keymappingMenu(), afterMenu: .view)
}
builder.insertSibling(MenuController.keymappingMenu(), afterMenu: .view)
}

@available(iOS 15.0, *)
class func keymappingMenu() -> UIMenu {
let keyCommands = [ "K", UIKeyCommand.inputDelete, UIKeyCommand.inputUpArrow, UIKeyCommand.inputDownArrow, "R" ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
// Copyright © 2016年 PugaTang. All rights reserved.
//


typedef struct __IOHIDEvent * IOHIDEventRef;
IOHIDEventRef kif_IOHIDEventWithTouches(NSArray *touches) CF_RETURNS_RETAINED;
IOHIDEventRef kif_IOHIDEventWithTouches(NSArray *touches) CF_RETURNS_RETAINED;
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
void IOHIDEventSetIntegerValue(IOHIDEventRef event, IOHIDEventField field, int value);
void IOHIDEventSetSenderID(IOHIDEventRef event, uint64_t sender);

// Derived from https://opensource.apple.com/source/IOHIDFamily/IOHIDFamily-606.1.7/IOHIDFamily/IOHIDEventTypes.h

enum {
kIOHIDDigitizerTransducerTypeStylus = 0,
kIOHIDDigitizerTransducerTypePuck,
kIOHIDDigitizerTransducerTypeFinger,
kIOHIDDigitizerTransducerTypeHand
};

enum {
kIOHIDEventTypeNULL, // 0
kIOHIDEventTypeVendorDefined,
Expand All @@ -54,7 +57,7 @@
kIOHIDEventTypeGyro, // 20
kIOHIDEventTypeCompass,
kIOHIDEventTypeZoomToggle,
kIOHIDEventTypeDockSwipe, // just like kIOHIDEventTypeNavigationSwipe, but intended for consumption by Dock
kIOHIDEventTypeDockSwipe, // Just like kIOHIDEventTypeNavigationSwipe, but intended for consumption by Dock
kIOHIDEventTypeSymbolicHotKey,
kIOHIDEventTypePower, // 25
kIOHIDEventTypeLED,
Expand All @@ -65,27 +68,34 @@
kIOHIDEventTypeAtmosphericPressure,
kIOHIDEventTypeUndefined,
kIOHIDEventTypeCount, // This should always be last

// DEPRECATED:
kIOHIDEventTypeSwipe = kIOHIDEventTypeNavigationSwipe,
kIOHIDEventTypeMouse = kIOHIDEventTypePointer
};

enum {
kIOHIDDigitizerEventRange = 0x00000001,
kIOHIDDigitizerEventTouch = 0x00000002,
kIOHIDDigitizerEventPosition = 0x00000004,
kIOHIDDigitizerEventStop = 0x00000008,
kIOHIDDigitizerEventPeak = 0x00000010,
kIOHIDDigitizerEventIdentity = 0x00000020,
kIOHIDDigitizerEventAttribute = 0x00000040,
kIOHIDDigitizerEventCancel = 0x00000080,
kIOHIDDigitizerEventStart = 0x00000100,
kIOHIDDigitizerEventResting = 0x00000200,
kIOHIDDigitizerEventSwipeUp = 0x01000000,
kIOHIDDigitizerEventSwipeDown = 0x02000000,
kIOHIDDigitizerEventSwipeLeft = 0x04000000,
kIOHIDDigitizerEventSwipeRight = 0x08000000,
kIOHIDDigitizerEventSwipeMask = 0xFF000000,
kIOHIDDigitizerEventRange = 1<<0,
kIOHIDDigitizerEventTouch = 1<<1,
kIOHIDDigitizerEventPosition = 1<<2,
kIOHIDDigitizerEventStop = 1<<3,
kIOHIDDigitizerEventPeak = 1<<4,
kIOHIDDigitizerEventIdentity = 1<<5,
kIOHIDDigitizerEventAttribute = 1<<6,
kIOHIDDigitizerEventCancel = 1<<7,
kIOHIDDigitizerEventStart = 1<<8,
kIOHIDDigitizerEventResting = 1<<9,
kIOHIDDigitizerEventFromEdgeFlat = 1<<10,
kIOHIDDigitizerEventFromEdgeTip = 1<<11,
kIOHIDDigitizerEventFromCorner = 1<<12,
kIOHIDDigitizerEventSwipePending = 1<<13,
kIOHIDDigitizerEventSwipeUp = 1<<24,
kIOHIDDigitizerEventSwipeDown = 1<<25,
kIOHIDDigitizerEventSwipeLeft = 1<<26,
kIOHIDDigitizerEventSwipeRight = 1<<27,
kIOHIDDigitizerEventSwipeMask = 0xFF<<24,
};

enum {
kIOHIDEventFieldDigitizerX = IOHIDEventFieldBase(kIOHIDEventTypeDigitizer),
kIOHIDEventFieldDigitizerY,
Expand All @@ -98,7 +108,7 @@
kIOHIDEventFieldDigitizerRange,
kIOHIDEventFieldDigitizerTouch,
kIOHIDEventFieldDigitizerPressure,
kIOHIDEventFieldDigitizerAuxiliaryPressure, //BarrelPressure
kIOHIDEventFieldDigitizerAuxiliaryPressure, // BarrelPressure
kIOHIDEventFieldDigitizerTwist,
kIOHIDEventFieldDigitizerTiltX,
kIOHIDEventFieldDigitizerTiltY,
Expand All @@ -115,18 +125,18 @@
kIOHIDEventFieldDigitizerIsDisplayIntegrated,
kIOHIDEventFieldDigitizerQualityRadiiAccuracy,
};

IOHIDEventRef IOHIDEventCreateDigitizerEvent(CFAllocatorRef allocator, AbsoluteTime timeStamp, IOHIDDigitizerTransducerType type,
uint32_t index, uint32_t identity, uint32_t eventMask, uint32_t buttonMask,
IOHIDFloat x, IOHIDFloat y, IOHIDFloat z, IOHIDFloat tipPressure, IOHIDFloat barrelPressure,
Boolean range, Boolean touch, IOOptionBits options);

IOHIDEventRef IOHIDEventCreateDigitizerFingerEventWithQuality(CFAllocatorRef allocator, AbsoluteTime timeStamp,
uint32_t index, uint32_t identity, uint32_t eventMask,
IOHIDFloat x, IOHIDFloat y, IOHIDFloat z, IOHIDFloat tipPressure, IOHIDFloat twist,
IOHIDFloat minorRadius, IOHIDFloat majorRadius, IOHIDFloat quality, IOHIDFloat density, IOHIDFloat irregularity,
Boolean range, Boolean touch, IOOptionBits options);



IOHIDEventRef kif_IOHIDEventWithTouches(NSArray *touches) {
uint64_t abTime = mach_absolute_time();
AbsoluteTime timeStamp;
Expand All @@ -148,8 +158,8 @@ IOHIDEventRef kif_IOHIDEventWithTouches(NSArray *touches) {
true, // touch
0); // options
IOHIDEventSetIntegerValue(handEvent, kIOHIDEventFieldDigitizerIsDisplayIntegrated, true);
for (UITouch *touch in touches)
{

for (UITouch *touch in touches) {
uint32_t eventMask = (touch.phase == UITouchPhaseMoved) ? kIOHIDDigitizerEventPosition : (kIOHIDDigitizerEventRange | kIOHIDDigitizerEventTouch);
uint32_t isTouching = (touch.phase == UITouchPhaseEnded) ? 0 : 1;
CGPoint touchLocation = [touch locationInView:touch.window];
Expand Down Expand Up @@ -177,11 +187,3 @@ IOHIDEventRef kif_IOHIDEventWithTouches(NSArray *touches) {
}
return handEvent;
}








22 changes: 22 additions & 0 deletions PlayTools/Controls/PTFakeTouch/Additions/UITouch-KIFAdditions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// UITouch-KIFAdditions.h
// KIF
//
// Created by Eric Firestone on 5/20/11.
// Licensed to Square, Inc. under one or more contributor license agreements.
// See the LICENSE file distributed with this work for the terms under
// which Square, Inc. licenses this file to you.

#import <UIKit/UIKit.h>
#import "IOHIDEvent+KIF.h"
#import "UITouch+Private.h"

@interface UITouch (KIFAdditions)

- (id)initAtPoint:(CGPoint)point inWindow:(UIWindow *)window onView:(UIView*)view;
- (id)initTouch;

- (void)setLocationInWindow:(CGPoint)location;
- (void)setPhaseAndUpdateTimestamp:(UITouchPhase)phase;

@end
106 changes: 106 additions & 0 deletions PlayTools/Controls/PTFakeTouch/Additions/UITouch-KIFAdditions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
//
// UITouch-KIFAdditions.m
// KIF
//
// Created by Eric Firestone on 5/20/11.
// Licensed to Square, Inc. under one or more contributor license agreements.
// See the LICENSE file distributed with this work for the terms under
// which Square, Inc. licenses this file to you.

#import "UITouch-KIFAdditions.h"
#import <objc/runtime.h>
#import "PTFakeMetaTouch.h"

@implementation UITouch (KIFAdditions)

- (id)initAtPoint:(CGPoint)point inWindow:(UIWindow *)window onView:(UIView*)view;
{
self = [super init];
if (self == nil) {
return nil;
}

// Create a fake tap touch
[self setWindow:window]; // Wipes out some values. Needs to be first.

[self _setLocationInWindow:point resetPrevious:YES];

UIView *hitTestView = view;

[self setView:hitTestView];
[self setPhase:UITouchPhaseBegan];
if (![[NSProcessInfo processInfo] isiOSAppOnMac] && ![[NSProcessInfo processInfo] isMacCatalystApp]) {
[self _setIsTapToClick:NO];
} else {
[self _setIsFirstTouchForView:YES];
[self setIsTap:NO];
}
[self setTimestamp: [[NSProcessInfo processInfo] systemUptime]];
if ([self respondsToSelector:@selector(setGestureView:)]) {
[self setGestureView:hitTestView];
}

[self kif_setHidEvent];
return self;
}

- (id)initTouch;
{
//DLog(@"init...touch...");
self = [super init];
if (self == nil) {
return nil;
}
NSArray *scenes = [[[UIApplication sharedApplication] connectedScenes] allObjects];
NSArray *windows = [[scenes objectAtIndex:0] windows];
UIWindow *window = [windows lastObject];
CGPoint point = CGPointMake(0, 0);
[self setWindow:window]; // Wipes out some values. Needs to be first.

[self _setLocationInWindow:point resetPrevious:YES];

UIView *hitTestView = [window hitTest:point withEvent:nil];

[self setView:hitTestView];
[self setPhase:UITouchPhaseEnded];
//DLog(@"init...touch...setPhase 3");
if (![[NSProcessInfo processInfo] isiOSAppOnMac] && ![[NSProcessInfo processInfo] isMacCatalystApp]) {
[self _setIsTapToClick:NO];
} else {
[self _setIsFirstTouchForView:YES];
[self setIsTap:NO];
}
[self setTimestamp: [[NSProcessInfo processInfo] systemUptime]];
if ([self respondsToSelector:@selector(setGestureView:)]) {
[self setGestureView:hitTestView];
}

[self kif_setHidEvent];
return self;
}

//
// setLocationInWindow:
//
// Setter to allow access to the _locationInWindow member.
//
- (void)setLocationInWindow:(CGPoint)location
{
[self setTimestamp: [[NSProcessInfo processInfo] systemUptime]];
[self _setLocationInWindow:location resetPrevious:NO];
}

- (void)setPhaseAndUpdateTimestamp:(UITouchPhase)phase
{
//DLog(@"setPhaseAndUpdateTimestamp : %ld",(long)phase);
[self setTimestamp: [[NSProcessInfo processInfo] systemUptime]];
[self setPhase:phase];
}

- (void)kif_setHidEvent {
IOHIDEventRef event = kif_IOHIDEventWithTouches(@[self]);
[self _setHidEvent:event];
CFRelease(event);
}

@end
33 changes: 0 additions & 33 deletions PlayTools/Controls/PTFakeTouch/FixCategoryBug.h

This file was deleted.

2 changes: 0 additions & 2 deletions PlayTools/Controls/PTFakeTouch/NSObject+Swizzle.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ NS_ASSUME_NONNULL_BEGIN

@interface NSObject (Swizzle)

+ (void)swizzleClassMethod:(SEL)origSelector withMethod:(SEL)newSelector;
- (void)swizzleInstanceMethod:(SEL)origSelector withMethod:(SEL)newSelector;
- (void)isMethodExists:(SEL)origSelector;

@end

Expand Down
Loading

0 comments on commit e3e422b

Please sign in to comment.