Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 953d575

Browse files
committed
refactor: split sources
Signed-off-by: 82Flex <82flex@gmail.com>
1 parent 3211fbd commit 953d575

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2205
-2221
lines changed

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ TrollSpeed_CFLAGS += -Isources
2020
TrollSpeed_CFLAGS += -Isources/KIF
2121
TrollSpeed_CFLAGS += -Iheaders
2222
TrollSpeed_CFLAGS += -include hud-prefix.pch
23-
TrollSpeed_CCFLAGS += -DNOTIFY_LAUNCHED_HUD=\"ch.xxtou.notification.hud.launched\"
24-
TrollSpeed_CCFLAGS += -DNOTIFY_DISMISSAL_HUD=\"ch.xxtou.notification.hud.dismissal\"
25-
TrollSpeed_CCFLAGS += -DNOTIFY_RELOAD_HUD=\"ch.xxtou.notification.hud.reload\"
26-
TrollSpeed_CCFLAGS += -DNOTIFY_RELOAD_APP=\"ch.xxtou.notification.app.reload\"
2723
ifeq ($(SPAWN_AS_ROOT),1)
2824
TrollSpeed_CCFLAGS += -DSPAWN_AS_ROOT
2925
endif
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#import <Foundation/Foundation.h>
2+
3+
#import "AXEventPathInfoRepresentation.h"
4+
5+
@interface AXEventHandInfoRepresentation : NSObject
6+
- (NSArray <AXEventPathInfoRepresentation *> *)paths;
7+
@end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#import <Foundation/Foundation.h>
2+
3+
@interface AXEventPathInfoRepresentation : NSObject
4+
@property (assign, nonatomic) unsigned char pathIdentity;
5+
@end

headers/AXEventRepresentation.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#import <Foundation/Foundation.h>
2+
3+
#import "IOKit+SPI.h"
4+
#import "AXEventHandInfoRepresentation.h"
5+
6+
@interface AXEventRepresentation : NSObject
7+
@property (nonatomic, readonly) BOOL isTouchDown;
8+
@property (nonatomic, readonly) BOOL isMove;
9+
@property (nonatomic, readonly) BOOL isChordChange;
10+
@property (nonatomic, readonly) BOOL isLift;
11+
@property (nonatomic, readonly) BOOL isInRange;
12+
@property (nonatomic, readonly) BOOL isInRangeLift;
13+
@property (nonatomic, readonly) BOOL isCancel;
14+
+ (instancetype)representationWithHIDEvent:(IOHIDEventRef)event hidStreamIdentifier:(NSString *)identifier;
15+
- (AXEventHandInfoRepresentation *)handInfo;
16+
- (CGPoint)location;
17+
@end

headers/BackboardServices.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#import <Foundation/Foundation.h>
2+
3+
#import "IOKit+SPI.h"
4+
5+
#if __cplusplus
6+
extern "C" {
7+
#endif
8+
void *BKSHIDEventRegisterEventCallback(void (*)(void *, void *, IOHIDServiceRef, IOHIDEventRef));
9+
void UIApplicationInstantiateSingleton(id aclass);
10+
void UIApplicationInitialize();
11+
void BKSDisplayServicesStart();
12+
void GSInitialize();
13+
void GSEventInitialize(Boolean registerPurple);
14+
void GSEventPopRunLoopMode(CFStringRef mode);
15+
void GSEventPushRunLoopMode(CFStringRef mode);
16+
void GSEventRegisterEventCallBack(void (*)(GSEventRef));
17+
#if __cplusplus
18+
}
19+
#endif

headers/FBSOrientationObserver.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#import <Foundation/Foundation.h>
2+
3+
@interface FBSOrientationObserver : NSObject
4+
- (long long)activeInterfaceOrientation;
5+
- (void)activeInterfaceOrientationWithCompletion:(id)arg1;
6+
- (void)invalidate;
7+
- (void)setHandler:(id)arg1;
8+
- (id)handler;
9+
@end

headers/FBSOrientationUpdate.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#import <Foundation/Foundation.h>
2+
3+
@interface FBSOrientationUpdate : NSObject
4+
- (unsigned long long)sequenceNumber;
5+
- (long long)rotationDirection;
6+
- (long long)orientation;
7+
- (double)duration;
8+
@end

headers/IOKit+SPI.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
typedef struct __IOHIDEvent *IOHIDEventRef;
2+
typedef struct __IOHIDNotification *IOHIDNotificationRef;
3+
typedef struct __IOHIDService *IOHIDServiceRef;
4+
typedef struct __GSEvent *GSEventRef;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#import <Foundation/Foundation.h>
2+
3+
@interface SBSAccessibilityWindowHostingController : NSObject
4+
- (void)registerWindowWithContextID:(unsigned)arg1 atLevel:(double)arg2;
5+
@end

headers/SpringBoardServices.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#import <Foundation/Foundation.h>
22

3-
FOUNDATION_EXPORT mach_port_t SBSSpringBoardServerPort();
3+
OBJC_EXPORT mach_port_t SBSSpringBoardServerPort();
44

55
FOUNDATION_EXPORT void SBFrontmostApplicationDisplayIdentifier(mach_port_t port, char *result);
66
NSString *SBSCopyFrontmostApplicationDisplayIdentifier();

headers/UIApplication+Private.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@
77
//
88

99
#import <UIKit/UIKit.h>
10+
#import "IOKit+SPI.h"
1011

1112
@interface UIApplication (Private)
1213
- (UIEvent *)_touchesEvent;
14+
- (void)_run;
15+
- (void)suspend;
16+
- (void)_accessibilityInit;
17+
- (void)terminateWithSuccess;
18+
- (void)__completeAndRunAsPlugin;
19+
- (id)_systemAnimationFenceExemptQueue;
20+
- (void)_enqueueHIDEvent:(IOHIDEventRef)event;
1321
@end

headers/UIApplicationRotationFollowingController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#import <Foundation/Foundation.h>
12
#import <UIKit/UIViewController.h>
23

34
@interface UIApplicationRotationFollowingController : UIViewController {

headers/UIApplicationRotationFollowingControllerNoTouches.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#import <Foundation/Foundation.h>
12
#import "UIApplicationRotationFollowingController.h"
23

34
@interface UIApplicationRotationFollowingControllerNoTouches : UIApplicationRotationFollowingController

headers/UIApplicationRotationFollowingWindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#import <Foundation/Foundation.h>
12
#import <UIKit/UIWindow.h>
23

34
@interface UIApplicationRotationFollowingWindow : UIWindow

headers/UIEventDispatcher.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#import <Foundation/Foundation.h>
2+
3+
@interface UIEventDispatcher : NSObject
4+
- (void)_installEventRunLoopSources:(CFRunLoopRef)arg1;
5+
@end

headers/UIEventFetcher.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#import <Foundation/Foundation.h>
2+
#import "IOKit+SPI.h"
3+
4+
@class UIEventDispatcher;
5+
6+
@interface UIEventFetcher : NSObject
7+
- (void)_receiveHIDEvent:(IOHIDEventRef)arg1;
8+
- (void)setEventFetcherSink:(UIEventDispatcher *)arg1;
9+
@end

headers/UITouch+Private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#import <UIKit/UIKit.h>
10+
#import "IOKit+SPI.h"
1011

1112
@interface UITouch (Private)
1213

headers/UIWindow+Private.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#import <UIKit/UIKit.h>
2+
3+
@interface UIWindow (Private)
4+
- (unsigned int)_contextId;
5+
@end

hud-prefix.pch

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,10 @@
1111
#import <Foundation/NSUserDefaults+Private.h>
1212
#import <UIKit/UIKit.h>
1313
#import <os/log.h>
14-
#endif
14+
#endif
15+
16+
#define FADE_OUT_DURATION 0.25
17+
#define NOTIFY_LAUNCHED_HUD "ch.xxtou.notification.hud.launched"
18+
#define NOTIFY_DISMISSAL_HUD "ch.xxtou.notification.hud.dismissal"
19+
#define NOTIFY_RELOAD_HUD "ch.xxtou.notification.hud.reload"
20+
#define NOTIFY_RELOAD_APP "ch.xxtou.notification.app.reload"

sources/HUDApp.mm

Lines changed: 12 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,24 @@
1-
#import <cstddef>
2-
#import <cstring>
3-
#import <cstdlib>
4-
#import <dlfcn.h>
5-
#import <spawn.h>
61
#import <notify.h>
7-
#import <unistd.h>
82
#import <os/log.h>
93
#import <rootless.h>
10-
#import <objc/objc.h>
11-
#import <sys/param.h>
12-
#import <sys/sysctl.h>
134
#import <mach-o/dyld.h>
14-
#import <objc/runtime.h>
15-
#import <CoreFoundation/CoreFoundation.h>
16-
#import <Foundation/Foundation.h>
175
#import <UIKit/UIKit.h>
6+
#import <objc/runtime.h>
187

8+
#import "IOKit+SPI.h"
9+
#import "HUDHelper.h"
10+
#import "JetsamHelper.h"
1911

20-
#pragma mark -
21-
22-
typedef struct __IOHIDEvent *IOHIDEventRef;
23-
typedef struct __IOHIDNotification *IOHIDNotificationRef;
24-
typedef struct __IOHIDService *IOHIDServiceRef;
25-
typedef struct __GSEvent *GSEventRef;
26-
27-
#if __cplusplus
28-
extern "C" {
29-
#endif
30-
void *BKSHIDEventRegisterEventCallback(void (*)(void *, void *, IOHIDServiceRef, IOHIDEventRef));
31-
void UIApplicationInstantiateSingleton(id aclass);
32-
void UIApplicationInitialize();
33-
void BKSDisplayServicesStart();
34-
void GSInitialize();
35-
void GSEventInitialize(Boolean registerPurple);
36-
void GSEventPopRunLoopMode(CFStringRef mode);
37-
void GSEventPushRunLoopMode(CFStringRef mode);
38-
void GSEventRegisterEventCallBack(void (*)(GSEventRef));
39-
#if __cplusplus
40-
}
41-
#endif
42-
43-
44-
#pragma mark -
45-
46-
@interface UIApplication (Private)
47-
- (id)_systemAnimationFenceExemptQueue;
48-
- (void)_accessibilityInit;
49-
- (void)_enqueueHIDEvent:(IOHIDEventRef)event;
50-
- (void)__completeAndRunAsPlugin;
51-
@end
52-
53-
@interface UIEventFetcher : NSObject
54-
- (void)_receiveHIDEvent:(IOHIDEventRef)arg1;
55-
@end
56-
57-
@interface AXEventPathInfoRepresentation : NSObject
58-
@property (assign, nonatomic) unsigned char pathIdentity;
59-
@end
60-
61-
@interface AXEventHandInfoRepresentation : NSObject
62-
- (NSArray <AXEventPathInfoRepresentation *> *)paths;
63-
@end
64-
65-
@interface AXEventRepresentation : NSObject
66-
@property (nonatomic, readonly) BOOL isTouchDown;
67-
@property (nonatomic, readonly) BOOL isMove;
68-
@property (nonatomic, readonly) BOOL isChordChange;
69-
@property (nonatomic, readonly) BOOL isLift;
70-
@property (nonatomic, readonly) BOOL isInRange;
71-
@property (nonatomic, readonly) BOOL isInRangeLift;
72-
@property (nonatomic, readonly) BOOL isCancel;
73-
+ (instancetype)representationWithHIDEvent:(IOHIDEventRef)event hidStreamIdentifier:(NSString *)identifier;
74-
- (AXEventHandInfoRepresentation *)handInfo;
75-
- (CGPoint)location;
76-
@end
77-
12+
#import "TSEventFetcher.h"
13+
#import "BackboardServices.h"
14+
#import "AXEventRepresentation.h"
7815

79-
#pragma mark -
16+
#import "UIApplication+Private.h"
8017

81-
#import "TSEventFetcher.h"
18+
#define PID_PATH "/var/mobile/Library/Caches/ch.xxtou.hudapp.pid"
8219

83-
static __used void _HUDEventCallback(void *target, void *refcon, IOHIDServiceRef service, IOHIDEventRef event)
20+
static __used
21+
void _HUDEventCallback(void *target, void *refcon, IOHIDServiceRef service, IOHIDEventRef event)
8422
{
8523
static UIApplication *app = [UIApplication sharedApplication];
8624
#if DEBUG
@@ -150,44 +88,6 @@ static __used void _HUDEventCallback(void *target, void *refcon, IOHIDServiceRef
15088
}
15189
}
15290

153-
154-
#pragma mark -
155-
156-
#define PID_PATH "/var/mobile/Library/Caches/ch.xxtou.hudapp.pid"
157-
158-
#ifdef __cplusplus
159-
extern "C" {
160-
#endif
161-
#import "libproc.h"
162-
#import "kern_memorystatus.h"
163-
#ifdef __cplusplus
164-
}
165-
#endif
166-
167-
__unused
168-
static inline
169-
void BypassJetsamByProcess(pid_t me, BOOL critical) {
170-
int rc; memorystatus_priority_properties_t props = { JETSAM_PRIORITY_CRITICAL, 0 };
171-
rc = memorystatus_control(MEMORYSTATUS_CMD_SET_PRIORITY_PROPERTIES, me, 0, &props, sizeof(props));
172-
if (critical && rc < 0) { perror ("memorystatus_control"); exit(rc); }
173-
rc = memorystatus_control(MEMORYSTATUS_CMD_SET_JETSAM_HIGH_WATER_MARK, me, -1, NULL, 0);
174-
if (critical && rc < 0) { perror ("memorystatus_control"); exit(rc); }
175-
rc = memorystatus_control(MEMORYSTATUS_CMD_SET_JETSAM_TASK_LIMIT, me, 0, NULL, 0);
176-
if (critical && rc < 0) { perror ("memorystatus_control"); exit(rc); }
177-
rc = memorystatus_control(MEMORYSTATUS_CMD_SET_PROCESS_IS_MANAGED, me, 0, NULL, 0);
178-
if (critical && rc < 0) { perror ("memorystatus_control"); exit(rc); }
179-
rc = memorystatus_control(MEMORYSTATUS_CMD_SET_PROCESS_IS_FREEZABLE, me, 0, NULL, 0);
180-
if (critical && rc < 0) { perror ("memorystatus_control"); exit(rc); }
181-
rc = proc_track_dirty(me, 0);
182-
if (critical && rc != 0) { perror("proc_track_dirty"); exit(rc); }
183-
os_log_debug(OS_LOG_DEFAULT, "Oh, My Jetsam: %d", me);
184-
}
185-
186-
187-
#pragma mark -
188-
189-
OBJC_EXTERN void SetHUDEnabled(BOOL isEnabled);
190-
19191
int main(int argc, char *argv[])
19292
{
19393
@autoreleasepool
@@ -283,4 +183,4 @@ int main(int argc, char *argv[])
283183
else return EXIT_SUCCESS; // No PID file, so HUD is not running
284184
}
285185
}
286-
}
186+
}

sources/HUDHelper.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#import <Foundation/Foundation.h>
2+
3+
OBJC_EXTERN BOOL _shouldToggleHUDAfterLaunch;
4+
OBJC_EXTERN BOOL IsHUDEnabled(void);
5+
OBJC_EXTERN void SetHUDEnabled(BOOL isEnabled);
6+
7+
#if DEBUG && SPAWN_AS_ROOT
8+
OBJC_EXTERN void SimulateMemoryPressure(void);
9+
#endif

0 commit comments

Comments
 (0)