The keycode in key events is the base, unmodified, keycode for the current keyboard layout

This commit is contained in:
Sam Lantinga 2024-06-30 19:58:48 -07:00
parent 5755bde3b8
commit d9dc4b320a
15 changed files with 125 additions and 160 deletions

View file

@ -226,25 +226,27 @@ static void loop(void *arg)
break;
case SDL_EVENT_KEY_DOWN:
switch (event.key.key) {
case SDLK_L:
num_lines = 0;
break;
case SDLK_l:
add_line(
(float)SDL_rand(640),
(float)SDL_rand(480),
(float)SDL_rand(640),
(float)SDL_rand(480));
break;
case SDLK_R:
num_rects = 0;
if (event.key.mod & SDL_KMOD_SHIFT) {
num_lines = 0;
} else {
add_line(
(float)SDL_rand(640),
(float)SDL_rand(480),
(float)SDL_rand(640),
(float)SDL_rand(480));
}
break;
case SDLK_r:
add_rect(
(float)SDL_rand(640),
(float)SDL_rand(480),
(float)SDL_rand(640),
(float)SDL_rand(480));
if (event.key.mod & SDL_KMOD_SHIFT) {
num_rects = 0;
} else {
add_rect(
(float)SDL_rand(640),
(float)SDL_rand(480),
(float)SDL_rand(640),
(float)SDL_rand(480));
}
break;
default:
break;