luv

Workshop wiki

input.lisp

luvcraft/clim/input.lisp

system luvcraft · 2 definitions · on GitHub

in-package#:luvcraft.clim

Keyboard dispatch.

This is the method that used to live in LUVCRAFT/RENDER.LISP as a ladder of WHEN ... RETURN-FROM guards, one per global key, each of which had to be placed above or below the focus dispatch by hand. What is left after the verbs became commands is the part that was never really about verbs: a keystroke lookup, the focus's claim on everything else, and the held-key state the player controller reads every physics step.

It runs on the canvas thread, and so does every command it executes: EXECUTE-FRAME-COMMAND applies a command directly while the frame has no process of its own. That is what makes it safe for a command to touch the session and the world at all.

defmethodluv:handle-canvas-event

An auto-repeat is one keystroke still held down, not another one: a verb fires once, while a movement key wants every repeat it can get.

unless
luv:canvas-key-event-repeat-pevent
alexandria:when-let
command
execute-frame-commandcommand

The release matching a focus-changing Tab is swallowed below, so a shell that has just been focused does not read a stray Tab-up.

when
eq:tab
luv:canvas-key-event-key-nameevent
setf
luvcraft:luvcraft-session-focus-toggle-tab-down-psession
t

Whatever no layer claimed belongs to the focus, and if nothing is focused it belongs to nobody: the player controller reads an intent now, not a record of which keys happened to be down.

nil
defmethodluv:handle-canvas-event
when
and
eq:tab
luv:canvas-key-event-key-nameevent
luvcraft:luvcraft-session-focus-toggle-tab-down-psession
setf
luvcraft:luvcraft-session-focus-toggle-tab-down-psession
nil
alexandria:when-let
command
execute-frame-commandcommand
nil