diff options
Diffstat (limited to 'apps/plugins')
-rwxr-xr-x | apps/plugins/lua/rbdefines_helper.pl | 2 | ||||
-rw-r--r-- | apps/plugins/lua/rockaux.c | 44 | ||||
-rw-r--r-- | apps/plugins/lua_scripts/print_buttons.lua | 70 |
3 files changed, 95 insertions, 21 deletions
diff --git a/apps/plugins/lua/rbdefines_helper.pl b/apps/plugins/lua/rbdefines_helper.pl index eca09187fa..e788855e87 100755 --- a/apps/plugins/lua/rbdefines_helper.pl +++ b/apps/plugins/lua/rbdefines_helper.pl | |||
@@ -47,7 +47,7 @@ if ($def_type eq "rb_defines") { | |||
47 | '^PLAYLIST_(INSERT|PREPEND|REPLACE)', | 47 | '^PLAYLIST_(INSERT|PREPEND|REPLACE)', |
48 | '^TOUCHSCREEN_(POINT|BUTTON)$', | 48 | '^TOUCHSCREEN_(POINT|BUTTON)$', |
49 | '^SYS_CHARGER_(DIS|)CONNECTED$', | 49 | '^SYS_CHARGER_(DIS|)CONNECTED$', |
50 | '^SYS_(TIMEOUT|POWEROFF)$', | 50 | '^SYS_(TIMEOUT|POWEROFF|BATTERY_UPDATE)$', |
51 | '^SYS_USB_(DIS|)CONNECTED$', | 51 | '^SYS_USB_(DIS|)CONNECTED$', |
52 | '^HOME_DIR$', | 52 | '^HOME_DIR$', |
53 | '^PLUGIN_DIR$', | 53 | '^PLUGIN_DIR$', |
diff --git a/apps/plugins/lua/rockaux.c b/apps/plugins/lua/rockaux.c index 25bace3451..73fe458889 100644 --- a/apps/plugins/lua/rockaux.c +++ b/apps/plugins/lua/rockaux.c | |||
@@ -133,28 +133,32 @@ int splash_scroller(int timeout, const char* str) | |||
133 | } | 133 | } |
134 | 134 | ||
135 | rb->lcd_update(); | 135 | rb->lcd_update(); |
136 | 136 | if (timeout >= TIMEOUT_BLOCK) | |
137 | action = rb->get_action(CONTEXT_STD, timeout); | ||
138 | switch(action) | ||
139 | { | 137 | { |
140 | case ACTION_STD_OK: | 138 | action = rb->get_action(CONTEXT_STD, timeout); |
141 | case ACTION_STD_CANCEL: | 139 | switch(action) |
142 | cycles--; | 140 | { |
143 | /* Fall Through */ | 141 | case ACTION_STD_OK: |
144 | case ACTION_NONE: | 142 | case ACTION_STD_CANCEL: |
145 | cycles--; | 143 | cycles--; |
146 | break; | 144 | /* Fall Through */ |
147 | case ACTION_STD_PREV: | 145 | case ACTION_NONE: |
148 | timeout = TIMEOUT_BLOCK; /* disable timeout */ | 146 | cycles--; |
149 | if(firstline > 0) | 147 | break; |
150 | firstline--; | 148 | case ACTION_STD_PREV: |
151 | break; | 149 | timeout = TIMEOUT_BLOCK; /* disable timeout */ |
152 | case ACTION_STD_NEXT: | 150 | if(firstline > 0) |
153 | timeout = TIMEOUT_BLOCK; /* disable timeout */ | 151 | firstline--; |
154 | if (linesdisp == max_lines) | 152 | break; |
155 | firstline++; | 153 | case ACTION_STD_NEXT: |
156 | break; | 154 | timeout = TIMEOUT_BLOCK; /* disable timeout */ |
155 | if (linesdisp == max_lines) | ||
156 | firstline++; | ||
157 | break; | ||
158 | } | ||
157 | } | 159 | } |
160 | else | ||
161 | break; | ||
158 | } | 162 | } |
159 | return action; | 163 | return action; |
160 | } | 164 | } |
diff --git a/apps/plugins/lua_scripts/print_buttons.lua b/apps/plugins/lua_scripts/print_buttons.lua new file mode 100644 index 0000000000..1b488ddd64 --- /dev/null +++ b/apps/plugins/lua_scripts/print_buttons.lua | |||
@@ -0,0 +1,70 @@ | |||
1 | -- bilgus 4/2021 | ||
2 | require "buttons" | ||
3 | local BUTTON_NONE = 0 | ||
4 | |||
5 | local function decode_ord_btn(btn) | ||
6 | local btntxt = "" | ||
7 | for k, v in pairs(rb.buttons) do | ||
8 | if btn > BUTTON_NONE and v ~= BUTTON_NONE and bit.band(btn, v) == v then | ||
9 | if #btntxt > 0 then | ||
10 | btntxt = btntxt .. " | " | ||
11 | end | ||
12 | btntxt = btntxt .. k | ||
13 | end | ||
14 | end | ||
15 | if btntxt == "" then return nil end | ||
16 | return btntxt | ||
17 | end | ||
18 | |||
19 | local _, w, h = rb.font_getstringsize("W", rb.FONT_UI) | ||
20 | local max_lines = rb.LCD_HEIGHT / h - 1 | ||
21 | |||
22 | button_text = {} | ||
23 | for k, v in pairs(rb.buttons) do | ||
24 | button_text[v] = k | ||
25 | end | ||
26 | |||
27 | --Add the system button codes to the button_text table | ||
28 | for k, v in pairs(rb) do | ||
29 | if string.find(k or "", "SYS_", 1, true) and type(v) == "number" then | ||
30 | button_text[v] = k | ||
31 | end | ||
32 | end | ||
33 | |||
34 | local s = {[1] = "Buttons Found:"} | ||
35 | for k, v in pairs(button_text) do | ||
36 | table.insert(s, tostring(k) .. " : " .. tostring(v)) | ||
37 | end | ||
38 | rb.splash_scroller(rb.HZ, table.concat(s, "\n")) | ||
39 | |||
40 | button_text[BUTTON_NONE] = " " | ||
41 | |||
42 | local lastbtn = BUTTON_NONE | ||
43 | local lastkey = BUTTON_NONE | ||
44 | local s_t = {"Press same button 3x to exit"} | ||
45 | local keyrpt = 0 | ||
46 | |||
47 | repeat | ||
48 | |||
49 | local btn | ||
50 | if lastbtn == BUTTON_NONE then | ||
51 | btn = rb.button_get(true) | ||
52 | else | ||
53 | btn = rb.button_get_w_tmo(rb.HZ) | ||
54 | end | ||
55 | |||
56 | if btn ~= lastkey then | ||
57 | table.insert(s_t, 1, (button_text[btn] or decode_ord_btn(btn) or "unknown " .. tostring (btn))) | ||
58 | end | ||
59 | |||
60 | if btn == lastbtn then keyrpt = keyrpt + 1 end | ||
61 | if button_text[btn] then lastbtn = btn end | ||
62 | lastkey = btn | ||
63 | |||
64 | rb.splash_scroller(-2, table.concat(s_t, "\n")) | ||
65 | |||
66 | if #s_t > max_lines then | ||
67 | table.remove(s_t) | ||
68 | end | ||
69 | |||
70 | until keyrpt >= 2 | ||