-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMusicMod_Volume_210_v3.pbp
280 lines (238 loc) · 6.22 KB
/
MusicMod_Volume_210_v3.pbp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
; This patch changes behaviour of stock Music app.
; Short press on up/down buttons will change volume,
; and long press will switch tracks.
;
; Implementation details:
; Android do support relative volume changes,
; i.e. pressing button on watch is equivalent to
; pressing phone's volume button.
; But iOS only supports absolute volume control,
; i.e. we only can send "Set volume to x %" command,
; but not "Increase volume by X percent".
; So we start with 50% volume and then change it.
; We cannot know current phone's volume on iOS.
#ver 210
; Possible options:
;@music_mimic_musicboss
; this will cause stock Music app
; to mimic MusicBoss UUID.
; This allows switching to Music app
; from Glance app (just tell it to switch to MusicBoss).
; Warning: don't use this together with MusicBoss app!
; Or else your watch will reboot or behave badly.
; So only use it if you don't use MusicBoss at all.
;WIP @music_return_to_glance
; this will cause stock Music app
; to (try to) launch Glance app on exit,
; just like MusicBoss with appropriate option enabled.
;and also these:
;@global_longpress_delay_ms val
; This option controls longpress delay. 250 ms means 1/4 seconds, 1000 ms means 1 second, etc.
#default global_longpress_delay_ms 250
;and the following options are not meant to be exposed to user:
; iOS volume changes from 0 to 127.
; Step 16 means 8 overal volume grades.
#default music_ios_volume_step 16
; Start with 50% volume
#default music_ios_volume_start 64
04 20 bd e8 10 40 ?4 10 bd ?4 @
08 b5 ?4 4f f4 7a 71 {
proc music_app_down_click
}
05 20 bd e8 10 40 ?4 10 bd ?4 @
08 b5 ?4 4f f4 7a 71 {
proc music_app_up_click
}
38 b5 04 46 ?4 00 22 4f f4 7a 71 {
proc music_app_select_click
}
; this is for android..
0c 4b 13 b5 1b 78 04 46 02 2b 05 d0 0a 48 02 b0 {
proc music_app_send_spp_command
}
; ...and these are for ios:
50 30 02 21 ?4 ?4 ?4 @
08 b5 ?4 bd e8 08 40 ?4 {
proc get_avrcp_stack
}
07 b5 7f 29 28 bf 7f 21 02 aa 02 f8 04 1d {
proc avrcp_volume_set
} ; R0: stack_id, R1: volume (0..7f)
#include includes/click_config_210.pbi
; read music_app_remote_os, which is stored after music_app_main
07 b0 bd e8 30 40 ?4 07 b0 30 bd @ ?4 {
val music_app_remote_os
}
; Got from LaunchBank14_20; will use next memory address.
; This matches some SerialConsole-related proc
; which references memory address used for serial console read buffer.
; We will use this address to store timer value.
08 B5 05 4B 1B 78 13 B9 3E 20 ?4 03 4B
00 22 C3 F8 84 20 08 BD ?4 @ ?4 {
val counter_ptr
}
#ifdef music_mimic_musicboss
; if mimicking MusicBoss, replace Music app's empty UUID
; with MusicBoss' one:
43 00 00 00 c7 00 00 00 cf 01 00 00 df 03 00 00 ; some Music-related icon for disambig
@ ; our empty uuid:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
18 00 00 00 ?4 00 00 00 00 ?4 ; and other parts of appinfo_music
{
; change empty uuid to MusicBoss':
; E4168F6C-B485-4B6F-99C4-94AA957E86D5
db E4 16 8f 6c b4 85 4b 6f 99 c4 94 aa 95 7e 86 d5
}
#endif
; append to the end of music_app_avrcp_service_handler, to handle volume events
61 79 bd e8 10 40 ?4 @ 10 bd 00 00 {
B.W my_volume_handler
}
; replace (full) music_app_click_config_provider proc:
08 b5 03 20 06 49 ?4
02 20 05 49 ?4
05 49 01 20
bd e8 08 40 ?4
00 bf ?4 ?4 ?4
{
PUSH {LR}
MOV R0, 2 ; button_id_select
LDR R1, pSelClick
BL window_single_click_subscribe
MOV R0, 1 ; button_id_up
MOV R1, ${global_longpress_delay_ms}
LDR R2, pUpClick ; down_handler
MOV R3, 0 ; up_handler
BL window_long_click_subscribe
B.W my_code
ALIGN 4
pSelClick: DCD music_app_select_click+1
pUpClick: DCD music_app_up_click+1
}
; floating block:
{
proc my_code
MOV R0, 3 ; button_id_down
MOV R1, ${global_longpress_delay_ms}
LDR R2, pDownClick ; down_handler
MOV R3, 0 ; up_handler
BL window_long_click_subscribe
MOV R0, 1 ; button_id_up
LDR R1, pVolUp
BL window_single_click_subscribe
MOV R0, 3 ; button_id_down
LDR R1, pVolDown
BL window_single_click_subscribe
#ifdef music_return_to_glance
MOV R0, 0 ; button_id_back
LDR R1, pBackPressed
BL window_single_click_subscribe
#endif
; initialize iOS default volume
LDR R0, pCurrVol
MOV R1, ${music_ios_volume_start}
STRB R1, [R0]
POP {PC}
; data block:
ALIGN 4
pDownClick: DCD music_app_down_click+1
pVolUp: DCD volume_up+1
pVolDown: DCD volume_down+1
#ifdef music_return_to_glance
pBackPressed: DCD back_pressed+1
#endif
pCurrVol: DCD counter_ptr+4
}
;;;;;;;;;;;;;;;;;;;;;;;;;;
;; And now our handlers ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;
{
;ALIGN 4
global volume_up
MOV R3, 6 ; SPP_volume_up
B volume
;ALIGN 4
global volume_down
MOV R3, 7 ; SPP_volume_down
volume:
PUSH {R4,LR}
LDR R0, pRemoteOs
LDRB R0, [R0]
CMP R0, 2
BNE not_droid
android: ;;;;;;;;;
MOV R0, R3 ; SPP command
BL music_app_send_spp_command
B ret
not_droid:
CMP R0, 1
BNE ret
ios: ;;;;;;;;;;;;;
BL get_avrcp_stack
LDR R2, pCurrVol
LDRB R1, [R2]
UXTB R1, R1
SUB R3, 6 ; convert SPP command to 0/1
CBNZ R3, ios_voldown
CMP R1, 127
BCS ret ; if already maximum volume (or bigger: we'll have 128), return
ADD R1, ${music_ios_volume_step}
B ios_ok
ios_voldown:
CBZ R1, ret ; if already 0, return
SUB R1, ${music_ios_volume_step}
ios_ok:
STRB R1, [R2] ; save new volume
BL avrcp_volume_set
ret:
POP {R4,PC}
; data:
ALIGN 4
pRemoteOs: DCD music_app_remote_os
pCurrVol: DCD counter_ptr+4
}
; and yet another handler
{
proc my_volume_handler
; here R3 is msg type,
; [R4,5] has msg data
CMP R3, 2
BNE volh_ret
; Volume changed event
LDRB R1, [R4,5] ; new volume
LDR R0, pCurrVol
STRB R1, [R0]
volh_ret:
POP {R4,PC}
; data:
ALIGN 4
pCurrVol: DCD counter_ptr+4
}
#ifdef music_return_to_glance
; for 2.0.x: 30 b5 85 b0 05 46 00 21 68 46 10 22 {
38 b5 05 46 ?4 08 b1 {
proc app_manager_find_app_info_by_uuid
}
1f b5 04 46 20 b9 09 48 {
proc app_manager_launch
}
10 b5 04 46 ?4 18 b1 20 46 ?4 fa e7 {
proc window_stack_pop_all
}
{
proc back_pressed
PUSH {LR}
MOV R0, 0 ; animated (bool)
BL window_stack_pop_all ; terminate app
ADR R0, uuidGlance
BL app_manager_find_app_info_by_uuid
CBZ R0, ret ; no glance installed? -> just exit
BL app_manager_launch
ret:
POP {PC}
; data:
ALIGN 4
; glance UUID: 4B760064-1488-4044-967A-1B1D3AB30574
uuidGlance: db 4b 76 00 64 14 88 40 44 96 7a 1b 1d 3a b3 05 74
}
#endif