mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-09-01 20:38:19 +00:00
both button press locks device in joystick ui
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#define KEY_ENTER_LONG 0xF1 /* long press enter */
|
||||
#define KEY_TO_TOP 0xF2 /* long press up → page up */
|
||||
#define KEY_TO_BOTTOM 0xF3 /* long press down → page down */
|
||||
#define KEY_LOCK 0xF4 /* user button + joystick center held together → screen lock */
|
||||
|
||||
/* Global action keys emitted by multi tap filter, handled in loop() */
|
||||
#define KEY_FLOOD_ADVERT 0x42 /* INPUT_KEY_B: 2 taps → flood advert */
|
||||
|
||||
@@ -372,6 +372,32 @@ static void joystick_ui_input_cb(struct input_event *evt, void *user_data)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Screen-lock combo: user button (INPUT_KEY_0) + joystick center
|
||||
* (INPUT_KEY_ENTER) held simultaneously. Tracked on raw press/release,
|
||||
* which are visible here on the global input bus before the per-key
|
||||
* handling below (INPUT_KEY_0 is otherwise only consumed by the
|
||||
* longpress/multi-tap filters). Latched so it fires once per combo
|
||||
* until at least one of the two is released; the stray key events the
|
||||
* two buttons emit afterwards land in the locked handler harmlessly. */
|
||||
static bool s_userbtn_down;
|
||||
static bool s_center_down;
|
||||
static bool s_lock_combo_latched;
|
||||
if (evt->code == INPUT_KEY_0) {
|
||||
s_userbtn_down = (evt->value != 0);
|
||||
} else if (evt->code == INPUT_KEY_ENTER) {
|
||||
s_center_down = (evt->value != 0);
|
||||
}
|
||||
if (s_userbtn_down && s_center_down) {
|
||||
if (!s_lock_combo_latched) {
|
||||
s_lock_combo_latched = true;
|
||||
if (joystick_queue_initialized) {
|
||||
JoystickUITask::enqueueKey(KEY_LOCK);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
s_lock_combo_latched = false;
|
||||
}
|
||||
|
||||
/* Long press fires on RELEASE so hold duration is known */
|
||||
if (evt->code == INPUT_KEY_ENTER) {
|
||||
if (evt->value) {
|
||||
@@ -809,6 +835,18 @@ void JoystickUITask::loop()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key == KEY_LOCK) {
|
||||
/* Manual lock combo — engage now and stop the idle timer
|
||||
* (unlock reschedules it). Same locked state the idle
|
||||
* lockTimerCb would set. */
|
||||
_locked = true;
|
||||
_lock_step = 0;
|
||||
k_timer_stop(&_lock_timer);
|
||||
_render_immediate = true;
|
||||
_pending_render = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
scheduleLockTimer();
|
||||
bool consumed = false;
|
||||
if (key == KEY_BUZZ_TOGGLE) {
|
||||
|
||||
Reference in New Issue
Block a user