src/video/windows/SDL_windowskeyboard.c
changeset 6922 91d157d9f283
parent 6885 700f1b25f77f
child 6925 59fedfb8faaf
     1.1 --- a/src/video/windows/SDL_windowskeyboard.c	Mon Feb 25 08:05:26 2013 -0800
     1.2 +++ b/src/video/windows/SDL_windowskeyboard.c	Mon Feb 25 16:52:42 2013 -0800
     1.3 @@ -90,6 +90,7 @@
     1.4          }
     1.5      }
     1.6  
     1.7 +	// windows scancode to SDL scancode table
     1.8      data->key_layout = windows_scancode_table;
     1.9  
    1.10      data->ime_com_initialized = SDL_FALSE;
    1.11 @@ -150,24 +151,28 @@
    1.12      SDL_Scancode scancode;
    1.13      SDL_Keycode keymap[SDL_NUM_SCANCODES];
    1.14  
    1.15 -    SDL_GetDefaultKeymap(keymap);
    1.16 +	for (i = 0; i < SDL_arraysize(keymap); ++i)
    1.17 +	{
    1.18 +		keymap[i] = SDL_SCANCODE_TO_KEYCODE( i );
    1.19 +	}
    1.20  
    1.21      for (i = 0; i < SDL_arraysize(windows_scancode_table); i++) {
    1.22 -
    1.23 +		int vk;
    1.24          /* Make sure this scancode is a valid character scancode */
    1.25          scancode = windows_scancode_table[i];
    1.26 -        if (scancode == SDL_SCANCODE_UNKNOWN || keymap[scancode] >= 127) {
    1.27 +        if (scancode == SDL_SCANCODE_UNKNOWN ) {
    1.28              continue;
    1.29          }
    1.30  
    1.31 -        /* Alphabetic keys are handled specially, since Windows remaps them */
    1.32 -        if (i >= 'A' && i <= 'Z') {
    1.33 -            BYTE vsc = alpha_scancodes[i - 'A'];
    1.34 -            keymap[scancode] = MapVirtualKey(vsc, MAPVK_VSC_TO_VK) + 0x20;
    1.35 -        } else {
    1.36 -            keymap[scancode] = (MapVirtualKey(i, MAPVK_VK_TO_CHAR) & 0x7FFF);
    1.37 -        }
    1.38 +		vk =  MapVirtualKey(i, MAPVK_VSC_TO_VK);
    1.39 +		if ( vk ) {
    1.40 +			int ch;
    1.41 +			ch = (MapVirtualKey( vk, MAPVK_VK_TO_CHAR ) & 0x7FFF);
    1.42 +			 if ( ch )
    1.43 +				 keymap[scancode] = ch;
    1.44 +		}
    1.45      }
    1.46 +
    1.47      SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
    1.48  }
    1.49