Windowed platform layer hard-codes quit keys ('q' and Esc force-quit the window) #88

Closed
opened 2026-09-02 06:17:25 +02:00 by orkun · 1 comment
Owner

runtime/native/cocoa.ll win_poll treats Escape (keycode 53) and the character 'q' as quit: it stores W_running = 0 and the game exits immediately. That is a dev-loop convenience, but it means any shipped windowed game dies the moment a player presses Esc (a universal pause key) or types 'q'.

Applied locally (2026-09-02): Escape is now delivered as key 27 and left to the game; 'q' is an ordinary key. The headless driver (rt_poll in core.ludic) keeps its own 'q' = quit, which is fine for scripted tests.

Proposal: make platform quit keys opt-in (e.g. a --dev-keys build flag or Window.dev_quit_keys(true)), default OFF for windowed builds. Games should own Esc/pause and quit via quit() or the window close button.

`runtime/native/cocoa.ll` `win_poll` treats Escape (keycode 53) and the character 'q' as *quit*: it stores `W_running = 0` and the game exits immediately. That is a dev-loop convenience, but it means any shipped windowed game dies the moment a player presses Esc (a universal pause key) or types 'q'. Applied locally (2026-09-02): Escape is now delivered as key 27 and left to the game; 'q' is an ordinary key. The headless driver (`rt_poll` in core.ludic) keeps its own 'q' = quit, which is fine for scripted tests. Proposal: make platform quit keys opt-in (e.g. a `--dev-keys` build flag or `Window.dev_quit_keys(true)`), default OFF for windowed builds. Games should own Esc/pause and quit via `quit()` or the window close button.
Author
Owner

Fixed in bdf1a97.

win_poll no longer treats Escape (keycode 53) or 'q' as quit for windowed builds:

  • Escape is delivered to the game as key 27 and left to the game (pause menus etc.) — it no longer stores W_running = 0.
  • 'q' is an ordinary key — no force-quit on a typo.
  • Made it consistent across both input paths: the single per-frame @W_key and the #50 held-key set. ev_keyval (which feeds win_held_bit) mapped Escape→113('q'); it now maps Escape→27, so Input.key_down/held state matches @W_key (previously holding Esc would have set the 'q' bit).
  • A shipped windowed game now owns Esc/pause and shuts down via quit() or the window close button (which still ends the run at closed:).

The headless driver (rt_poll in core.ludic) keeps its own 'q' = quit for scripted/golden tests, so nothing headless changes. Also stopped forwarding consumed key events to -sendEvent: (it was ringing AppKit's system 'funk' beep on every keystroke).

On the opt-in dev-quit-keys proposal: I removed the quit keys by default (which is what 'default OFF for windowed builds' asks for) rather than gating them behind a flag — Cmd-Q, the window close button, and quit() already cover shutdown, and the headless 'q' covers scripted dev runs, so a windowed dev-quit-key flag would add compiler plumbing for little gain. Happy to add --dev-quit-keys / Window.dev_quit_keys() as a follow-up if you want the convenience back. This is windowed-only behavior (not in the headless golden suite); verified a windowed build assembles + links cleanly.

Fixed in bdf1a97. `win_poll` no longer treats Escape (keycode 53) or 'q' as quit for windowed builds: - **Escape is delivered to the game as key 27** and left to the game (pause menus etc.) — it no longer stores `W_running = 0`. - **'q' is an ordinary key** — no force-quit on a typo. - Made it **consistent across both input paths**: the single per-frame `@W_key` *and* the #50 held-key set. `ev_keyval` (which feeds `win_held_bit`) mapped Escape→113('q'); it now maps Escape→27, so `Input.key_down`/held state matches `@W_key` (previously holding Esc would have set the 'q' bit). - A shipped windowed game now owns Esc/pause and shuts down via `quit()` or the **window close button** (which still ends the run at `closed:`). The headless driver (`rt_poll` in core.ludic) keeps its own `'q'` = quit for scripted/golden tests, so nothing headless changes. Also stopped forwarding consumed key events to `-sendEvent:` (it was ringing AppKit's system 'funk' beep on every keystroke). On the opt-in dev-quit-keys proposal: I removed the quit keys by default (which is what 'default OFF for windowed builds' asks for) rather than gating them behind a flag — Cmd-Q, the window close button, and `quit()` already cover shutdown, and the headless `'q'` covers scripted dev runs, so a windowed dev-quit-key flag would add compiler plumbing for little gain. Happy to add `--dev-quit-keys` / `Window.dev_quit_keys()` as a follow-up if you want the convenience back. This is windowed-only behavior (not in the headless golden suite); verified a windowed build assembles + links cleanly.
orkun closed this issue 2026-09-02 06:23:26 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: workshopsoft/ludic#88
No description provided.