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

Commit 80274e0

Browse files
committed
adjust position by dragging
Signed-off-by: 82Flex <[email protected]>
1 parent 3ddda67 commit 80274e0

File tree

9 files changed

+280
-40
lines changed

9 files changed

+280
-40
lines changed

CHANGELOG.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
- Add `UILaunchStoryboardName` entry to Info.plist
2-
- Fix touches on iOS 17
1+
- Adjust vertical position of the HUD by tapping and long-pressing (Not available for centered HUD)

HUDApp.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static __used void _HUDEventCallback(void *target, void *refcon, IOHIDServiceRef
124124

125125
UIView *keyView = [keyWindow hitTest:[rep location] withEvent:nil];
126126

127-
UITouchPhase phase = UITouchPhaseCancelled;
127+
UITouchPhase phase = UITouchPhaseEnded;
128128
if ([rep isTouchDown])
129129
phase = UITouchPhaseBegan;
130130
else if ([rep isMove])

HUDMainApplication.mm

Lines changed: 220 additions & 12 deletions
Large diffs are not rendered by default.

MainApplication.mm

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ @implementation RootViewController {
9494
BOOL _supportsCenterMost;
9595
}
9696

97+
- (void)registerNotifications
98+
{
99+
int token;
100+
notify_register_dispatch(NOTIFY_RELOAD_APP, &token, dispatch_get_main_queue(), ^(int token) {
101+
[self loadUserDefaults:YES];
102+
});
103+
104+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toggleHUDNotificationReceived:) name:kToggleHUDAfterLaunchNotificationName object:nil];
105+
}
106+
97107
- (void)loadView
98108
{
99109
CGRect bounds = UIScreen.mainScreen.bounds;
@@ -244,7 +254,7 @@ - (void)viewDidLayoutSubviews {
244254

245255
- (void)viewDidLoad {
246256
[super viewDidLoad];
247-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toggleHUDNotificationReceived:) name:kToggleHUDAfterLaunchNotificationName object:nil];
257+
[self registerNotifications];
248258
}
249259

250260
- (void)viewDidAppear:(BOOL)animated {
@@ -315,6 +325,10 @@ - (NSInteger)selectedMode
315325
- (void)setSelectedMode:(NSInteger)selectedMode
316326
{
317327
[self loadUserDefaults:NO];
328+
// Remove some keys that are not persistent
329+
[_userDefaults removeObjectsForKeys:@[
330+
@"currentPositionY",
331+
]];
318332
[_userDefaults setObject:@(selectedMode) forKey:@"selectedMode"];
319333
[self saveUserDefaults];
320334
}
@@ -403,6 +417,20 @@ - (void)setUsesRotation:(BOOL)usesRotation
403417
[self saveUserDefaults];
404418
}
405419

420+
- (BOOL)keepInPlace
421+
{
422+
[self loadUserDefaults:NO];
423+
NSNumber *mode = [_userDefaults objectForKey:@"keepInPlace"];
424+
return mode ? [mode boolValue] : NO;
425+
}
426+
427+
- (void)setKeepInPlace:(BOOL)keepInPlace
428+
{
429+
[self loadUserDefaults:NO];
430+
[_userDefaults setObject:@(keepInPlace) forKey:@"keepInPlace"];
431+
[self saveUserDefaults];
432+
}
433+
406434
- (void)reloadMainButtonState
407435
{
408436
_isHUDActive = IsHUDEnabled();

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ TrollSpeed_CFLAGS += -include hud-prefix.pch
1616
TrollSpeed_CCFLAGS += -DNOTIFY_LAUNCHED_HUD=\"ch.xxtou.notification.hud.launched\"
1717
TrollSpeed_CCFLAGS += -DNOTIFY_DISMISSAL_HUD=\"ch.xxtou.notification.hud.dismissal\"
1818
TrollSpeed_CCFLAGS += -DNOTIFY_RELOAD_HUD=\"ch.xxtou.notification.hud.reload\"
19+
TrollSpeed_CCFLAGS += -DNOTIFY_RELOAD_APP=\"ch.xxtou.notification.app.reload\"
1920
MainApplication.mm_CCFLAGS += -std=c++14
2021
TrollSpeed_FRAMEWORKS += CoreGraphics QuartzCore UIKit
2122
TrollSpeed_PRIVATE_FRAMEWORKS += BackBoardServices GraphicsServices IOKit SpringBoardServices

TSEventFetcher.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ + (NSInteger)receiveAXEventID:(NSInteger)eventId
105105
BOOL newState = !oldState;
106106
if (newState)
107107
{
108-
if (phase == UITouchPhaseEnded)
108+
if (phase == UITouchPhaseEnded || phase == UITouchPhaseCancelled)
109109
return deleted;
110110
touch = [[UITouch alloc] initAtPoint:coordinate inWindow:window onView:view];
111111
[_livingTouchAry addObject:touch];

TSSettingsController.swift

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,24 @@ import UIKit
1212
internal var restartRequired = false
1313

1414
open override func settingsCount() -> Int {
15-
return 6;
15+
return 7;
1616
}
1717

1818
open override func settingTitle(index: Int, highlighted: Bool) -> String {
1919
if index == 0 {
2020
return NSLocalizedString("Pass-through", comment: "")
2121
} else if index == 1 {
22-
return NSLocalizedString("Incoming Only", comment: "")
22+
return NSLocalizedString("Keep In-place", comment: "")
2323
} else if index == 2 {
24-
return NSLocalizedString("Unit", comment: "")
24+
return NSLocalizedString("Incoming Only", comment: "")
2525
} else if index == 3 {
26-
return NSLocalizedString("Prefixes", comment: "")
26+
return NSLocalizedString("Landscape", comment: "")
2727
} else if index == 4 {
2828
return NSLocalizedString("Size", comment: "")
29+
} else if index == 5 {
30+
return NSLocalizedString("Unit", comment: "")
2931
} else {
30-
return NSLocalizedString("Landscape", comment: "")
32+
return NSLocalizedString("Prefixes", comment: "")
3133
}
3234
}
3335

@@ -36,44 +38,41 @@ import UIKit
3638
if restartRequired {
3739
return NSLocalizedString("Re-open to apply", comment: "")
3840
} else {
39-
if alreadyLaunched {
40-
restartRequired = true
41-
}
4241
if (highlighted) {
4342
return NSLocalizedString("ON", comment: "")
4443
} else {
4544
return NSLocalizedString("OFF", comment: "")
4645
}
4746
}
48-
} else if index == 1 {
47+
} else if index == 1 || index == 2 {
4948
if (highlighted) {
5049
return NSLocalizedString("ON", comment: "")
5150
} else {
5251
return NSLocalizedString("OFF", comment: "")
5352
}
54-
} else if index == 2 {
55-
if (highlighted) {
56-
return NSLocalizedString("b/s", comment: "")
57-
} else {
58-
return NSLocalizedString("B/s", comment: "")
59-
}
6053
} else if index == 3 {
6154
if (highlighted) {
62-
return NSLocalizedString("↑↓", comment: "")
55+
return NSLocalizedString("Follow", comment: "")
6356
} else {
64-
return NSLocalizedString("▲▼", comment: "")
57+
return NSLocalizedString("Hide", comment: "")
6558
}
6659
} else if index == 4 {
6760
if (highlighted) {
6861
return NSLocalizedString("Large", comment: "")
6962
} else {
7063
return NSLocalizedString("Standard", comment: "")
7164
}
65+
} else if index == 5 {
66+
if (highlighted) {
67+
return NSLocalizedString("b/s", comment: "")
68+
} else {
69+
return NSLocalizedString("B/s", comment: "")
70+
}
7271
} else {
7372
if (highlighted) {
74-
return NSLocalizedString("Follow", comment: "")
73+
return NSLocalizedString("↑↓", comment: "")
7574
} else {
76-
return NSLocalizedString("Hide", comment: "")
75+
return NSLocalizedString("▲▼", comment: "")
7776
}
7877
}
7978
}
@@ -82,15 +81,17 @@ import UIKit
8281
if index == 0 {
8382
return "passthroughMode"
8483
} else if index == 1 {
85-
return "singleLineMode"
84+
return "keepInPlace"
8685
} else if index == 2 {
87-
return "usesBitrate"
86+
return "singleLineMode"
8887
} else if index == 3 {
89-
return "usesArrowPrefixes"
88+
return "usesRotation"
9089
} else if index == 4 {
9190
return "usesLargeFont"
91+
} else if index == 5 {
92+
return "usesBitrate"
9293
} else {
93-
return "usesRotation"
94+
return "usesArrowPrefixes"
9495
}
9596
}
9697

@@ -104,6 +105,9 @@ import UIKit
104105
}
105106

106107
open override func settingDidSelect(index: Int, completion: @escaping () -> ()) {
108+
if index == 0 && alreadyLaunched {
109+
restartRequired = true
110+
}
107111
delegate?.settingDidSelect(key: settingKey(index: index))
108112
completion()
109113
}
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)