-
Notifications
You must be signed in to change notification settings - Fork 1
/
LaunchBank14_260.pbp
110 lines (93 loc) · 2.86 KB
/
LaunchBank14_260.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
; This patch changes behaviour of the Back button
; in watchfaces:
; If you (from any watchface)
; press Back button and shortly after then any button,
; it will launch an app installed in bank N,
; where N is a button ID (Back=0, Up=1, Select=2, Down=3).
; I.e. you can turn on backlight with Back button alone,
; launch app0 with Back-Back,
; launch app1 with Back-Up, app2 with Back-Select
; and app3 with Back-Down.
; You may choose which app is installed in which bank
; by uninstalling and reinstalling apps in desired order.
; This is greatly simplified since 2.0 app with Locker.
#ver 260
; just a simple mask to find named proc
07 4b 10 b5 04 46 58 68 48 b1 {
proc app_manager_get_bank_info
}
c0 d1 80 00 @
01 21 ?4 00 00 {
proc app_manager_launch
}
37 B5 0D 46 04 46 0D F1 02 01 01 A8 {
proc time_ms
}
; 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 48 bd e8 70 40 ?4 07 48 ?4 bd e8 70 40 01 20 ?4 00 bf @ ?4 {
val counter_ptr
}
; This matches beginning of watchface_button_handler proc.
37 b5 05 46 ?4 43 7c @ 00 2b 48 d1 {
; was: CMP R3, 0; BNE ret
B.W my_code
global continue ; and will return here if we wouldn't like to consume button :)
}
; and append our code
{
proc my_code
CMP R3, 0 ; reexecute replaced code
BNE ret
; We can use: R0,R1,R2,R3,R4
; R5 is button event struct
; check if this is first or subsequent btn press
LDR R0, counter
LDR R4, [R0] ; get old counter value
MOV R1, 0
BL time_ms
LDR R2, counter
LDR R1, [R2]
MOV.W R3, 1000
MUL R1, R3 ; convert seconds to millis
ADD R1, R0 ; now R1 contains full timestamp
; check current button
LDRB R0, [R5]
CBNZ R0, notupdate
; let's handle both press and release events for timer update.
; I.e. update counter even on Release events.
; This may help users.
; update counter only if this was Back btn
STR R1, [R2] ; update counter value
B updated
notupdate:
STR R4, [R2] ; restore old value
updated:
; check diff
SUB R1, R1, R4 ; calculate diff
MOV.W R3, 500 ; delay in millis
CMP R1, R3
BHI cont ; if diff is too large, pass this button to original proc
; now check if it is release event
LDRB R1, [R5,9]
CMP R1, 5
BEQ cont ; and pass it to original proc, which will cancel stock QL's timer
; now launch app: get its info -
; R0 holds button id, which we use as bank id,
; i.e. launch app from bank 0..3 depending on button
BL app_manager_get_bank_info
CBZ R0, ret ; if no such app, just return
LDR R0, [R0,0x10] ; get app id from bank info
BL app_manager_launch
ret: ; terminate proc
ADD SP,SP,0xC
POP {R4,R5,PC}
cont: ; return to original proc and let it handle this button
B.W continue
; ---------------------------
; data block
ALIGN 4
counter: ; memory location for click counter.
DCD counter_ptr ; this should be a serial console's read buffer
}