44#define POWER_BUTTON 104
55#define HOME_BUTTON 101
66
7- static NSString *respringSequence = @" UDUD" ;
8- static NSString *safeModeSequence = @" SSUDUD" ;
9- static id sharedInstance;
7+ static NSString *pauseMusicSequence = @" " ;
8+ static NSString *skipTrackSequence = @" " ;
9+ static NSString *toggleRepeatSequence = @" " ;
10+ static NSString *f15Sequence = @" " ;
11+ static NSString *b15Sequence = @" " ;
12+ static NSTimer *bopTimer;
13+
14+
15+ static void loadPrefs ();
16+
17+
18+ id sharedInstance;
1019static BOOL tweakEnabled = YES ;
1120static BOOL isRunning = NO ;
12- // static NSString *pauseMusicSequence = @"V";
1321
1422static void triggerButton (char button) {
1523 if (tweakEnabled && !isRunning) {
@@ -30,7 +38,6 @@ static void triggerButton(char button) {
3038}
3139%end
3240
33-
3441// iOS 13.3 and below
3542%hook SBFluidSwitcherGestureManager
3643-(void )grabberTongueBeganPulling:(id )arg1 withDistance:(double )arg2 andVelocity:(double )arg3 {
@@ -42,13 +49,11 @@ static void triggerButton(char button) {
4249
4350
4451%hook SpringBoard
45-
4652-(void )_ringerChanged:(struct __IOHIDEvent *)arg1 {
4753 triggerButton (' S' );
4854 %orig ;
4955}
5056
51-
5257-(_Bool )_handlePhysicalButtonEvent:(UIPressesEvent *)arg1 {
5358 // type = 101 -> Home button
5459 // type = 104 -> Power button
@@ -92,37 +97,48 @@ static void triggerButton(char button) {
9297
9398
9499@implementation Bop
95-
96100NSMutableString *sequence = [@" " mutableCopy ];
97101NSTimeInterval lastPress;
98102
103+ + (id )sharedInstance {
104+ return sharedInstance;
105+ }
106+
99107-(id )init {
100108 lastPress = 0.0 ;
101109 return self;
102110}
103111
112+
113+
104114-(void )buttonPressed_LG : (char )button {
105115
106116 NSTimeInterval now = [[NSDate date ] timeIntervalSince1970 ] * 1000 ;
107- if (now - lastPress > 650.0 )
117+ if (now - lastPress > 650.0 ){
108118 [sequence setString: @" " ];
119+ } else {
120+ if (bopTimer)
121+ [bopTimer invalidate ];
122+ }
109123 if (now - lastPress < 100.0 )
110124 [sequence deleteCharactersInRange: NSMakeRange ([sequence length ]-1 , 1 )];
111125 lastPress = now;
112126
113127 [sequence appendFormat: @" %c " , button];
114- NSLog (@" [BOP] Sequence:%@ Added:%c " , sequence, button);
115- if ([respringSequence length ] >= [safeModeSequence length ]) {
116- if ([[sequence copy ] containsString: respringSequence])
117- [self respring_LG: NO ];
118- else if ([[sequence copy ] containsString: safeModeSequence])
119- [self respring_LG: YES ];
120- } else {
121- if ([[sequence copy ] containsString: safeModeSequence])
122- [self respring_LG: YES ];
123- else if ([[sequence copy ] containsString: respringSequence])
124- [self respring_LG: NO ];
125- }
128+ NSLog (@" [BOP] Sequence:%@ Added:%c " , sequence, button);
129+ bopTimer = [NSTimer scheduledTimerWithTimeInterval: 2.0
130+ target: self
131+ selector: @selector (interpSeq )
132+ userInfo: nil
133+ repeats: NO ];
134+ }
135+ -(void )interpSeq {
136+
137+ if ([[sequence copy ] isEqualToString: pauseMusicSequence]) {[self pauseMusic ];}
138+ if ([[sequence copy ] isEqualToString: skipTrackSequence]) {[self skipTrack ];}
139+ if ([[sequence copy ] isEqualToString: toggleRepeatSequence]) {[self repeatMusic ];}
140+ if ([[sequence copy ] isEqualToString: f15Sequence]) {[self f15Music ];}
141+ if ([[sequence copy ] isEqualToString: b15Sequence]) {[self b15Music ];}
126142}
127143
128144-(void )respring_LG : (BOOL )safeMode {
@@ -136,16 +152,36 @@ NSTimeInterval lastPress;
136152 posix_spawn (&pid, " /usr/bin/killall" , NULL , NULL , (char * const *)args, NULL );
137153 }
138154}
155+ -(void )pauseMusic {
156+ MRMediaRemoteSendCommand (kMRTogglePlayPause , 0 );
157+ }
158+ -(void )repeatMusic {
159+ MRMediaRemoteSendCommand (kMRToggleRepeat , 0 );
160+ }
161+ -(void )skipTrack {
162+ MRMediaRemoteSendCommand (kMRNextTrack , 0 );
163+ }
164+ -(void )f15Music {
165+ MRMediaRemoteSendCommand (kMRSkipFifteenSeconds , 0 );
166+ }
167+ -(void )b15Music {
168+ MRMediaRemoteSendCommand (kMRGoBackFifteenSeconds , 0 );
169+ }
170+ -(void )loadPrefs {
171+ loadPrefs ();
172+ }
173+
139174
140175@end
141176
142177
143178
144- // static void loadPrefs() {
145- // NSDictionary *prefs = [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.squidkingdom.boppreferences.defaults"];
146- // pauseMusicSequence = [[prefs objectForKey:@"pauseMusicSequence"] uppercaseString];
147- // }
179+ static void loadPrefs () {
180+ NSDictionary *prefs = [[NSUserDefaults standardUserDefaults ] persistentDomainForName: @" com.squidkingdom.boppreferences.defaults" ];
181+ pauseMusicSequence = [[prefs objectForKey: @" pauseMusicSequence" ] uppercaseString ];
182+ skipTrackSequence = [[prefs objectForKey: @" skipTrackSequence" ] uppercaseString ];
183+ }
148184
149185%ctor {
150- // loadPrefs();
186+ loadPrefs ();
151187}
0 commit comments