News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

Android Back key is incorrectly mapped to Delete

Started by victor_18993, July 17, 2026, 01:18:57 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

victor_18993

The Android Back key is currently mapped to
SIM_KEYCODE_DELETE in the SDL2 backend.
This normally goes unnoticed because both Escape and Delete close the top window when the event is not consumed first. However, a text input consumes Delete and removes the character under the cursor.
As a result, pressing Android Back while editing text deletes a character instead of following the existing Escape behaviour.
The attached patch maps
SDLK_AC_BACK to
SIM_KEYCODE_ESCAPE, while leaving the real Delete key unchanged.
The functional change is only:
- case SDLK_ESCAPE:     code = SIM_KEYCODE_ESCAPE;                break;
- case SDLK_AC_BACK:
+ case SDLK_AC_BACK:
+ case SDLK_ESCAPE:     code = SIM_KEYCODE_ESCAPE;                break;
  case SDLK_DELETE:     code = SIM_KEYCODE_DELETE;                break;

I checked the complete event path:
  • SDLK_AC_BACK is only mapped at this location.
  • No Android-specific code intercepts it beforehand.
  • Delete is consumed by text inputs and deletes a character.
  • Escape leaves the text input without deleting text.
  • When neither event is consumed, both already reach the existing top-window closing path.
Validation:
  • Built successfully with the SDL2 backend on Windows 11 using MinGW-w64.
  • git diff --check is clean.
  • Escape and the real Delete key remain unchanged.
I could not test the result on a physical Android device or a working emulator, so Android runtime testing remains pending.
Patch attached.
En la vida todo son vivencias y cada una de ellas nos hace mas grandes,¿Como de grande eres tu? :)

prissi

Delete closes all windows though. But maybe only closing the top window is even a better choice.