Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old January 10, 2012, 22:09   #1
Tobias
Adept
 
Tobias's Avatar
 
Join Date: Dec 2009
Posts: 172
Tobias is on a distinguished road
Fix for the Non-English keyboard layouts bug

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.
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;
__________________
My Angband videos : http://www.youtube.com/view_play_lis...385E85F31166B2
Tobias is offline   Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Favorite Angbanding keyboard? Max Stats Idle chatter 23 August 6, 2013 06:33
Oangband bug fix bron Variants 5 July 19, 2011 11:19
QUERTZ keyboard bug Antoine Development 7 May 25, 2011 18:38
Scandinavian Keyboard Layouts chris Development 3 November 12, 2010 03:06
[All] Keyboard interface and keymaps Remuz Vanilla 12 April 18, 2008 00:24


All times are GMT +1. The time now is 07:50.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.