Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions PlayTools/Controls/PTFakeTouch/NSObject+Swizzle.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#import "PTFakeMetaTouch.h"
#import <VideoSubscriberAccount/VideoSubscriberAccount.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreMotion/CoreMotion.h>

__attribute__((visibility("hidden")))
@interface PTSwizzleLoader : NSObject
Expand Down Expand Up @@ -150,6 +151,15 @@ - (void)hook_requestRecordPermission:(void (^)(BOOL))response {
}
}

- (instancetype)hook_CMMotionManager_init {
CMMotionManager *motionManager = (CMMotionManager *)[self hook_CMMotionManager_init];
// The default update interval is 0, which may lead to excessive CPU usage
motionManager.accelerometerUpdateInterval = 0.01;
motionManager.deviceMotionUpdateInterval = 0.01;
motionManager.gyroUpdateInterval = 0.01;
return motionManager;
}

// Hook for UIUserInterfaceIdiom

// - (long long) hook_userInterfaceIdiom {
Expand Down Expand Up @@ -287,6 +297,10 @@ + (void)load {
if ([[PlaySettings shared] checkMicPermissionSync]) {
[objc_getClass("AVAudioSession") swizzleInstanceMethod:@selector(requestRecordPermission:) withMethod:@selector(hook_requestRecordPermission:)];
}

if ([[PlaySettings shared] limitMotionUpdateFrequency]) {
[objc_getClass("CMMotionManager") swizzleInstanceMethod:@selector(init) withMethod:@selector(hook_CMMotionManager_init)];
}
}

@end
3 changes: 3 additions & 0 deletions PlayTools/PlaySettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ let settings = PlaySettings.shared
@objc lazy var hideTitleBar = settingsData.hideTitleBar

@objc lazy var checkMicPermissionSync = settingsData.checkMicPermissionSync

@objc lazy var limitMotionUpdateFrequency = settingsData.limitMotionUpdateFrequency
}

struct AppSettingsData: Codable {
Expand All @@ -111,4 +113,5 @@ struct AppSettingsData: Codable {
var enableScrollWheel = true
var hideTitleBar = false
var checkMicPermissionSync = false
var limitMotionUpdateFrequency = false
}