Bug http://trac.rephial.org/ticket/1460 has been getting on my nerves again. I think I found the problem.
The problem is that SDL seems to use the Keycode of the pressed key instead of the modified key, when the modifier is Alt-Gr (SDL calls it Mode).
So here key_code still contains the correct symbol (which is why it sometimes works).
key_sym does contain the wrong key.
Angband uses key_sym instead of key_code for some keys (no idea why).
I added a conditional to skip use of key_sym for the number keys if Alt-Gr is pressed.
It might be better to skip the whole case-block if Alt-Gr is pressed. But I have no idea if this might break something else.
The diff is vs. V4 from last week btw.
The problem is that SDL seems to use the Keycode of the pressed key instead of the modified key, when the modifier is Alt-Gr (SDL calls it Mode).
So here key_code still contains the correct symbol (which is why it sometimes works).
key_sym does contain the wrong key.
Angband uses key_sym instead of key_code for some keys (no idea why).
I added a conditional to skip use of key_sym for the number keys if Alt-Gr is pressed.
It might be better to skip the whole case-block if Alt-Gr is pressed. But I have no idea if this might break something else.
The diff is vs. V4 from last week btw.
Code:
diff --git a/src/main-sdl.c b/src/main-sdl.c index 74ddc9e..c9b9378 100644 --- a/src/main-sdl.c +++ b/src/main-sdl.c @@ -2386,6 +2386,7 @@ static void sdl_keypress(SDL_keysym keysym) bool ms = (keysym.mod & KMOD_SHIFT) > 0; bool ma = (keysym.mod & KMOD_ALT) > 0; bool mm = (keysym.mod & KMOD_META) > 0; + bool mg = (keysym.mod & KMOD_MODE) > 0; bool kp = FALSE; byte mods = (ma ? KC_MOD_ALT : 0) | (mm ? KC_MOD_META : 0); @@ -2415,16 +2416,16 @@ static void sdl_keypress(SDL_keysym keysym) case SDLK_KP_EQUALS: ch = '='; kp = TRUE; break; /* have have these to get consistent ctrl-shift behaviour */ - case SDLK_0: if (!ms || mc || ma) ch = '0'; break; - case SDLK_1: if (!ms || mc || ma) ch = '1'; break; - case SDLK_2: if (!ms || mc || ma) ch = '2'; break; - case SDLK_3: if (!ms || mc || ma) ch = '3'; break; - case SDLK_4: if (!ms || mc || ma) ch = '4'; break; - case SDLK_5: if (!ms || mc || ma) ch = '5'; break; - case SDLK_6: if (!ms || mc || ma) ch = '6'; break; - case SDLK_7: if (!ms || mc || ma) ch = '7'; break; - case SDLK_8: if (!ms || mc || ma) ch = '8'; break; - case SDLK_9: if (!ms || mc || ma) ch = '9'; break; + case SDLK_0: if ((!ms || mc || ma) && !mg) ch = '0'; break; + case SDLK_1: if ((!ms || mc || ma) && !mg) ch = '1'; break; + case SDLK_2: if ((!ms || mc || ma) && !mg) ch = '2'; break; + case SDLK_3: if ((!ms || mc || ma) && !mg) ch = '3'; break; + case SDLK_4: if ((!ms || mc || ma) && !mg) ch = '4'; break; + case SDLK_5: if ((!ms || mc || ma) && !mg) ch = '5'; break; + case SDLK_6: if ((!ms || mc || ma) && !mg) ch = '6'; break; + case SDLK_7: if ((!ms || mc || ma) && !mg) ch = '7'; break; + case SDLK_8: if ((!ms || mc || ma) && !mg) ch = '8'; break; + case SDLK_9: if ((!ms || mc || ma) && !mg) ch = '9'; break; case SDLK_UP: ch = ARROW_UP; break; case SDLK_DOWN: ch = ARROW_DOWN; break;
Comment