Fix power button screen toggle instantly turning back on

Power button events were setting any_activity before the power handler's
continue, causing the generic wake logic to immediately re-enable the screen.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Michael Smith 2026-02-13 23:18:42 +01:00
parent f9fcb9f121
commit 1ea1490e60
2 changed files with 6 additions and 2 deletions

View File

@ -43,6 +43,10 @@ This document specifies the functional requirements for an SDL2 based media play
## 6. Changelog
### 2026-02-13 — Fix power button screen toggle regression
- **Power button screen off stays off**: Fixed regression from fbd32d7 where short-pressing the power button to turn off the screen would instantly turn it back on. The generic wake logic (`any_activity`) was being triggered by power button events themselves. Moved `any_activity = True` below the power button handler's `continue` so power events are handled exclusively by the power button handler and don't trigger the wake path.
### 2026-02-13 — Screen wake fixes and idle auto-shutdown
- **D-pad wakes screen**: The screen monitor now wakes on any input event type (EV_ABS, EV_KEY, etc.), not just EV_KEY. This fixes d-pad presses (which generate EV_ABS hat events) not waking the screen.

View File

@ -198,8 +198,6 @@ def main():
if ev_type == EV_SYN:
continue
any_activity = True
# Power button handling (EV_KEY only)
if ev_type == EV_KEY and ev_code == KEY_POWER:
if ev_value == 1: # press
@ -220,6 +218,8 @@ def main():
# Between SHORT and LONG threshold: ignore (release before 3s)
continue
any_activity = True
# Any input activity resets idle shutdown timer
if any_activity:
last_active_time = time.monotonic()