Implemented US-qwerty shift characters, when Unicode is disabled

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@815 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2009-05-22 19:24:03 +00:00
parent 8f5fc2c923
commit 9e4866e34c
2 changed files with 47 additions and 11 deletions

View File

@ -340,8 +340,8 @@
; that follows it isn't space or a vowel (the ones that make it a valid ; that follows it isn't space or a vowel (the ones that make it a valid
; combination : ^âêîôû) ; combination : ^âêîôû)
; If this problem concerns you, disable unicode below, and it will never ; If this problem concerns you, disable unicode below, and it will never
; crash. This won't affect keyboard shortcuts, but in text fields you will be ; crash. This won't affect keyboard shortcuts, but in text fields you'll be
; unable to type many punctuation characters. ; typing in US-QWERTY mode.
Use_unicode = yes ; (Default 'yes') Use_unicode = yes ; (Default 'yes')
; end of configuration ; end of configuration

View File

@ -543,21 +543,57 @@ word Keysym_to_ANSI(SDL_keysym keysym)
#if !(defined(__macosx__) || defined(__FreeBSD__)) #if !(defined(__macosx__) || defined(__FreeBSD__))
if ( keysym.unicode == 0) if ( keysym.unicode == 0)
{ {
// Converty lowercase to uppercase if SHIFT is on. byte shift;
if (keysym.sym >= 'a' && keysym.sym <= 'z' && (SDL_GetModState() & (KMOD_SHIFT|KMOD_CAPS)))
return ('A' - 'a') + keysym.sym; shift = (SDL_GetModState() & (KMOD_SHIFT|KMOD_CAPS)) != 0;
// Convert keypad to numbers // Convert keypad to numbers
if (keysym.sym >= SDLK_KP0 && keysym.sym <= SDLK_KP9) if (keysym.sym >= SDLK_KP0 && keysym.sym <= SDLK_KP9)
return ('0' - SDLK_KP0) + keysym.sym; return ('0' - SDLK_KP0) + keysym.sym;
// Conversion with shift on
if (shift)
{
// Lowercase to uppercase.
if (keysym.sym >= 'a' && keysym.sym <= 'z' && shift)
return ('A' - 'a') + keysym.sym;
// Some shifts of QWERTY-US keys
switch (keysym.sym)
{
case '`': return '~';
case '1': return '!';
case '2': return '@';
case '3': return '#';
case '4': return '$';
case '5': return '%';
case '6': return '^';
case '7': return '&';
case '8': return '*';
case '9': return '(';
case '0': return ')';
case '-': return '_';
case '=': return '+';
case '\\': return '|';
case '[': return '{';
case ']': return '}';
case ';': return ':';
case '\'': return '"';
case ',': return '<';
case '.': return '>';
case '/': return '?';
default:
return keysym.sym;
}
}
// More conversions // More conversions
switch (keysym.sym) switch (keysym.sym)
{ {
case SDLK_KP_PERIOD: return '.'; case SDLK_KP_PERIOD: return '.';
case SDLK_KP_DIVIDE: return '/'; case SDLK_KP_DIVIDE: return '/';
case SDLK_KP_MINUS: return '-'; case SDLK_KP_MINUS: return '-';
case SDLK_KP_PLUS: return '+'; case SDLK_KP_MULTIPLY: return '*';
case SDLK_KP_ENTER: return '\r'; case SDLK_KP_PLUS: return '+';
case SDLK_KP_EQUALS: return '='; case SDLK_KP_ENTER: return '\r';
case SDLK_KP_EQUALS: return '=';
default: default:
return keysym.sym; return keysym.sym;
} }