From 741668ab12a8f3471e34fbc9c025aa7d5b84877a Mon Sep 17 00:00:00 2001
From: Cameron Cawley <[EMAIL REDACTED]>
Date: Mon, 17 Aug 2026 22:10:54 +0100
Subject: [PATCH] examples/woodeneye: Use position independant key codes for
keyboard input
---
.../demo/02-woodeneye-008/woodeneye-008.c | 26 +++++++++----------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/examples/demo/02-woodeneye-008/woodeneye-008.c b/examples/demo/02-woodeneye-008/woodeneye-008.c
index 9a53323d940f1..a256767c7a62f 100644
--- a/examples/demo/02-woodeneye-008/woodeneye-008.c
+++ b/examples/demo/02-woodeneye-008/woodeneye-008.c
@@ -411,15 +411,15 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
break;
}
case SDL_EVENT_KEY_DOWN: {
- SDL_Keycode sym = event->key.key;
+ SDL_Scancode scancode = event->key.scancode;
SDL_KeyboardID id = event->key.which;
int index = whoseKeyboard(id, players, player_count);
if (index >= 0) {
- if (sym == SDLK_W) players[index].wasd |= 1;
- if (sym == SDLK_A) players[index].wasd |= 2;
- if (sym == SDLK_S) players[index].wasd |= 4;
- if (sym == SDLK_D) players[index].wasd |= 8;
- if (sym == SDLK_SPACE) players[index].wasd |= 16;
+ if (scancode == SDL_SCANCODE_W) players[index].wasd |= 1;
+ if (scancode == SDL_SCANCODE_A) players[index].wasd |= 2;
+ if (scancode == SDL_SCANCODE_S) players[index].wasd |= 4;
+ if (scancode == SDL_SCANCODE_D) players[index].wasd |= 8;
+ if (scancode == SDL_SCANCODE_SPACE) players[index].wasd |= 16;
} else if (id) {
for (i = 0; i < MAX_PLAYER_COUNT; i++) {
if (players[i].keyboard == 0) {
@@ -432,16 +432,16 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
break;
}
case SDL_EVENT_KEY_UP: {
- SDL_Keycode sym = event->key.key;
+ SDL_Scancode scancode = event->key.scancode;
SDL_KeyboardID id = event->key.which;
- if (sym == SDLK_ESCAPE) return SDL_APP_SUCCESS;
+ if (scancode == SDL_SCANCODE_ESCAPE) return SDL_APP_SUCCESS;
int index = whoseKeyboard(id, players, player_count);
if (index >= 0) {
- if (sym == SDLK_W) players[index].wasd &= 30;
- if (sym == SDLK_A) players[index].wasd &= 29;
- if (sym == SDLK_S) players[index].wasd &= 27;
- if (sym == SDLK_D) players[index].wasd &= 23;
- if (sym == SDLK_SPACE) players[index].wasd &= 15;
+ if (scancode == SDL_SCANCODE_W) players[index].wasd &= 30;
+ if (scancode == SDL_SCANCODE_A) players[index].wasd &= 29;
+ if (scancode == SDL_SCANCODE_S) players[index].wasd &= 27;
+ if (scancode == SDL_SCANCODE_D) players[index].wasd &= 23;
+ if (scancode == SDL_SCANCODE_SPACE) players[index].wasd &= 15;
}
break;
}