How input works
The interface · The play screen · Camp menus · The game loop
In brief
The keyboard and the mouse put their events into one queue, and each pass of the game loop takes one event from it. A key or a mouse press is offered to the buttons of the active list, in order, until one of them ends the walk; a key that no button takes goes on to the keyboard commands. Whether the game is in mouse control or keyboard control decides whether clicks count, whether a pointer is drawn and which item counts as held.
Keys and mouse presses
The keyboard and mouse handlers put each event into one queue, in the order they happen: a key press as a key number with bits for Shift, Ctrl and Alt, a press or release of either mouse button with the position of the pointer. Key releases are not queued. The grey arrows and the other grey keys give the numbers of the matching keypad keys, and keypad Enter that of Enter, so what the pages of this chapter say of a keypad key also holds for its grey key. These keys never get the Shift bit.1
Two hot keys act as the key is queued, on any screen: Alt+S switches the "Sounds" option and Alt+M the "Tunes" option.1
ANOMALY-135 — With Caps Lock on, the keyboard handler should add Shift to a
letter key, and with Num Lock on to a keypad key. It tests the key against
its table with a processor register it never sets, so whether a key gets
Shift depends on the value left in that register by the code the key press
interrupted. The text fields turn letters into capitals, so the visible
effect is unknown. A faithful reimplementation cannot reproduce the exact
value; it may treat the result as unpredictable.2
Mouse control and keyboard control
The start-up decides how the game is played. It is in keyboard control when no mouse was detected or when the setup program was told not to use one, and in mouse control otherwise. The keys of the buttons work in both.3
| Mouse control | Keyboard control | |
|---|---|---|
| Pointer | Drawn, shows the held item | Not drawn |
| Clicks | Act on the buttons under the pointer | Ignored by the buttons and the slot menus |
| Held item | The item on the pointer | The item in the selected hand or slot of the selected character |
| Keyboard commands | Do nothing | W, S, Z, A, U, D, T, G and M act |
| Highlight in menus | Follows the pointer | Moved by keys only |
The active button list
A button has a rectangle, up to two keys, the mouse buttons it answers to, a number and usually an action. The buttons of the play screen are not drawn: what the player sees there is the screen picture.4
Each pass of the game loop reads at most one event from the queue. A letter key loses its Shift bit first, so it reads the same with or without Shift; other keys keep it, which is how Shift+F1 differs from F1. The list is then walked in order, and for each button:4
- a key triggers the button when it is one of the button's two keys;
- in mouse control, a press inside the rectangle triggers the button when it answers to that mouse button. Every button answers to either one, except the name strips, which answer only to the right button;
- a triggered button runs its action at once. An action can tell whether a click or which of the two keys triggered it. When it returns 0, the walk goes on to the next button; otherwise the walk ends.
A key that triggers no button goes back to the caller; on the play screen it then reaches the keyboard commands.
The list depends on the situation:5
| Situation | Buttons, in order |
|---|---|
| Play screen | Wall in front, character boxes, camp, floor, faces, hands, names, arrows, throw |
| Character panel, inventory page | Wall in front, 27 slots, plate, page, close, next, previous, a button for F5 and F6, then camp, floor, arrows, throw |
| Character panel, character sheet | The same without the slots and the plate |
| Spell book open | Wall in front, the book's buttons, then the rest of the play screen list |
| Spell book open with the panel | Wall in front, tabs, six lines, ABORT SPELL, then the panel's list. The page arrows and the keys ,, . and Space have no button here |
| Swap or spell target | Six characters and a button that cancels |
| Menus | The buttons of the menu |
The pointer and the item it carries
In mouse control the pointer starts as item icon 0, cut from ITEMICN.CPS,
with its hot spot at the top-left corner. When an item is taken, the pointer
becomes that item's icon, with its hot spot at the centre of the 16 × 16 icon;
while the party has SPELL_EFFECT_DETECT_MAGIC, a magical item shows in other
colours. Giving up the item brings icon 0 back.6
The player carries one item at a time. What a click does with it depends on the area: see moving and equipping items, items on the floor and throwing. The game hides the pointer while it draws under it, and during text input.
Sources
Locations refer to the game executable reference; comparative sources are listed in the technical references.