Skip to content

Commit a2ac601

Browse files
desktop: add global escape key for back action
1 parent 84de3b7 commit a2ac601

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

internal_filesystem/boot_unix.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import sys
99
sys.path.append('lib/')
1010

11+
import mpos.ui
12+
1113
#TFT_HOR_RES=640
1214
#TFT_VER_RES=480
1315
TFT_HOR_RES=320
@@ -23,10 +25,25 @@
2325
import sdl_pointer
2426
mouse = sdl_pointer.SDLPointer()
2527

26-
import sdl_keyboard
27-
keyboard = sdl_keyboard.SDLKeyboard()
28+
def catch_escape_key(indev, indev_data):
29+
global sdlkeyboard
30+
#print(f"keypad_cb {indev} {indev_data}")
31+
#key = indev.get_key() # always 0
32+
#print(f"key {key}")
33+
#key = indev_data.key
34+
#state = indev_data.state
35+
#print(f"indev_data: {state} and {key}") # this catches the previous key release instead of the next key press
36+
pressed, code = sdlkeyboard._get_key() # get the current key and state
37+
print(f"catch_escape_key caught: {pressed}, {code}")
38+
if pressed == 1 and code == 27:
39+
mpos.ui.back_screen()
40+
sdlkeyboard._read(indev, indev_data)
2841

2942

43+
import sdl_keyboard
44+
sdlkeyboard = sdl_keyboard.SDLKeyboard()
45+
sdlkeyboard._indev_drv.set_read_cb(catch_escape_key) # check for escape
46+
3047
#def keyboard_cb(event):
3148
# global canvas
3249
# event_code=event.get_code()

0 commit comments

Comments
 (0)