mojira.dev
MC-311035

`KEY_STOP` points to `SDL_SCANCODE_CANCEL`, rather than `SDL_SCANCODE_STOP`

evdev key 223 (KEY_CANCEL) correctly points to SDL_SCANCODE_CANCEL, as is explicitly specified in the Linux-to-SDL key code mappings file (https://github.com/libsdl-org/SDL/blob/855cbec702f246661ff00a0bce9e0683012840c2/src/events/scancodes_linux.h ).

However, for some strange, strange reason, evdev key 128 (KEY_STOP) also points to SDL_SCANCODE_CANCEL, despite the above document explicitly stating it should instead point to SDL_SCANCODE_STOP.

The number associated with SDL_SCANCODE_CANCEL is 155 (see https://wiki.libsdl.org/SDL3/SDL_Scancode), hence both controls showing up as key.keyboard.155 in-game. In reality, the STOP key should be showing up as key.keyboard.120 in-game (which would then be converted to “Stop”), but we do not see this happen.

To reproduce, just have a keyboard with a stop button and a cancel button, and go into the Key Binds menu and try setting a control to use this button like any other key. If you do not have such a keyboard, a Python script for Linux is attached that can be used to simulate a key press event for both of these.

  • Download the attached script file

  • Open a command window in the same folder you placed the script

  • Go into the Minecraft key binds menu

  • In your command window, paste this and run it: ./simulate-keys 'sleep 2' 'press 128' 'sleep 0.1' 'release 128'

  • Go back into Minecraft within that two second window, then press one of the rebinding buttons

  • Repeat, but with this command on a different control: ./simulate-keys 'sleep 2' 'press 223' 'sleep 0.1' 'release 223'

  • Observe

Expected results: as the SDL key code list explicitly indicates, KEY_STOP should show up as key.keyboard.120 (or Stop), and KEY_CANCEL should show up as key.keyboard.155

Actual results: both show up as key.keyboard.155, despite being obviously distinct keys

Linked issues

Attachments

Comments 3

Thank you for helping us improve Minecraft! We saved your files:

[media][media][media][media][media][media]

Could you clarify if this is a bug in SDL or the game? If it’s an SDL bug then it should be reported to them rather than us.

I've reported it to both but am still yet to recieve any word back from them in the case that it’s an issue in their end. A basic input handling program similar to xev or wev but specifically using SDL codes would make this a lot easier to figure out, but I don't believe one exists yet.

muzikbike

(Unassigned)

Plausible

Platform HC

Low

Input

26.3 Snapshot 8

Retrieved