Skip to content

Input hints: Display logical keys#2347

Draft
wjt wants to merge 1 commit into
mainfrom
wjt/rewrite-input-hud-again
Draft

Input hints: Display logical keys#2347
wjt wants to merge 1 commit into
mainfrom
wjt/rewrite-input-hud-again

Conversation

@wjt

@wjt wjt commented Jun 10, 2026

Copy link
Copy Markdown
Member

Our keybindings are, correctly, configured to use the physical location
of keys on the keyboard. This is because WASD are chosen to be the same
shape as the arrow keys, not because "W" means up; and so other bindings
such as Z and X must also be physical to avoid clashing.

However this means the labels are wrong for QWERTZ and AZERTY keyboards:

Action QWERTY QWERTZ AZERTY
Up W W Z
Left A A Q
Down S S S
Right D D D
Throw X X X
Repel Z Y C

We don't actually show WASD in the UI, but we do show X for Throw and Z
for Repel.

Rather than hardcoding that the glyph for Repel is Z on a keyboard and
L1 on a gamepad, instead look these up dynamically.

Change the resources to be based on the Key / JoyButton / etc. enums.
Rewrite the importer accordingly to generate just one resource per
device type (which contains all the necessary AtlasTextures) rather than
hundreds of separate AtlasTexture resources. (It was my idea to do the
latter; I was wrong!)

Update to Kenney Input Prompts 1.5; among other things this introduces a
glyph for the "Pause" key on a keyboard, which we do actually have a
binding for. But only check in the four sheets that we actually use.

Then in the input hint controls, determine which key/button the event is
bound to, and display that.

There are some annoying edge cases to handle, including:

  • R2 is analogue so is represented in Godot as an axis that can never be
    negative, but we present it as a button;
  • The arrow keys want to be treated like a joystick in the UI;
  • We show mouse + keyboard controls for some actions;
  • Sony helpfully relabelled the Start/Select buttons from PS3 (and
    older) to something else in PS4 and something else again in PS5.

Resolves #2185

@wjt

wjt commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

Needs rebase; conflicts due to #2331.

Also needs testing on the web platform.

@wjt wjt changed the title Input hints: Display logical keys [1/1] Input hints: Display logical keys Jun 10, 2026
@wjt wjt force-pushed the wjt/rewrite-input-hud-again branch 2 times, most recently from e6b4629 to f59fb44 Compare June 10, 2026 21:27
@wjt wjt changed the title [1/1] Input hints: Display logical keys Input hints: Display logical keys Jun 10, 2026
@github-actions

Copy link
Copy Markdown

Play this branch at https://play.threadbare.game/branches/endlessm/wjt/rewrite-input-hud-again/.

(This launches the game from the start, not directly at the change(s) in this pull request.)

@wjt wjt force-pushed the wjt/rewrite-input-hud-again branch from f59fb44 to f26ff0e Compare June 10, 2026 21:30
push_warning("Primary keyboard binding for %s not a key: %s" % [action_name, event])
return

var logical_keycode := DisplayServer.keyboard_get_keycode_from_physical(event.physical_keycode)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: keyboard_get_keycode_from_physical is not supported on the web platform

index.js:467 ERROR: Not supported by this display server.
onPrintError @ index.js:467
index.js:467 at: keyboard_get_keycode_from_physical (servers/display/display_server.cpp:1211)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Physical bindings work on the web but that's because at the time the keyboard event is delivered, both the physical and logical codes are provided:

https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#instance_properties

There is an API to do the lookup, but only in Chromium:

https://developer.mozilla.org/en-US/docs/Web/API/Keyboard/getLayoutMap

I wonder if there is a widely used workaround.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in the worst case we can just make this call conditional on "is not the web", and fall back to the current behaviour.

Our keybindings are, correctly, configured to use the physical location
of keys on the keyboard. This is because WASD are chosen to be the same
shape as the arrow keys, not because "W" means up; and so other bindings
such as Z and X must also be physical to avoid clashing.

However this means the labels are wrong for QWERTZ and AZERTY keyboards:

| Action | QWERTY | QWERTZ | AZERTY |
| ------ | ------ | ------ | ------ |
| Up     | W      | W      | Z      |
| Left   | A      | A      | Q      |
| Down   | S      | S      | S      |
| Right  | D      | D      | D      |
| Throw  | X      | X      | X      |
| Repel  | Z      | Y      | C      |

We don't actually show WASD in the UI, but we do show X for Throw and Z
for Repel.

Rather than hardcoding that the glyph for Repel is Z on a keyboard and
L1 on a gamepad, instead look these up dynamically.

Change the resources to be based on the Key / JoyButton / etc. enums.
Rewrite the importer accordingly to generate just one resource per
device type (which contains all the necessary AtlasTextures) rather than
hundreds of separate AtlasTexture resources. (It was my idea to do the
latter; I was wrong!)

Update to Kenney Input Prompts 1.5; among other things this introduces a
glyph for the "Pause" key on a keyboard, which we do actually have a
binding for. But only check in the four sheets that we actually use.

Then in the input hint controls, determine which key/button the event is
bound to, and display that.

There are some annoying edge cases to handle, including:

- R2 is analogue so is represented in Godot as an axis that can never be
  negative, but we present it as a button;
- The arrow keys want to be treated like a joystick in the UI;
- We show mouse + keyboard controls for some actions;
- Sony helpfully relabelled the Start/Select buttons from PS3 (and
  older) to something else in PS4 and something else again in PS5.

Resolves #2185
@wjt wjt force-pushed the wjt/rewrite-input-hud-again branch from f26ff0e to 694c8a5 Compare June 10, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show logical labels for keyboard keys

1 participant