Minimal implementation of textinput events for x11. It only works for latin-1.
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402709
This commit is contained in:
parent
05ad8bbf51
commit
79041b0a87
6 changed files with 38 additions and 11 deletions
|
@ -37,8 +37,8 @@ static int SDL_current_keyboard;
|
|||
static SDL_Keyboard **SDL_keyboards;
|
||||
|
||||
/* Taken from SDL_iconv() */
|
||||
static char *
|
||||
encodeUtf8(Uint32 ch, char *dst)
|
||||
char *
|
||||
SDL_Ucs4ToUtf8(Uint32 ch, char *dst)
|
||||
{
|
||||
Uint8 *p = (Uint8 *) dst;
|
||||
if (ch <= 0x7F) {
|
||||
|
@ -266,17 +266,21 @@ SDL_GetKeyName(SDLKey layoutKey)
|
|||
keyname = _this->GetSpecialKeyName(_this, layoutKey);
|
||||
}
|
||||
} else if ((layoutKey & SDL_KEY_CAN_BE_PHYSICAL_BIT) == 0) {
|
||||
/* SDLK_INDEX(layoutKey) is the unicode code point of the character generated by the key */
|
||||
/* SDLK_INDEX(layoutKey) is the unicode code point of the
|
||||
character generated by the key */
|
||||
static char buffer[9]; /* 6 (maximal UTF-8 char length) + 2 ([] for keypad) + 1 (null teminator) */
|
||||
char *bufferPtr = &buffer[1];
|
||||
Uint32 codepoint = SDLK_INDEX(layoutKey);
|
||||
|
||||
/* Unaccented letter keys on latin keyboards are normally labeled in upper case (and probably on others like Greek or Cyrillic too, so if you happen to know for sure, please adapt this). */
|
||||
/* Unaccented letter keys on latin keyboards are normally
|
||||
labeled in upper case (and probably on others like Greek or
|
||||
Cyrillic too, so if you happen to know for sure, please
|
||||
adapt this). */
|
||||
if (codepoint >= 'a' && codepoint <= 'z') {
|
||||
codepoint -= 32;
|
||||
}
|
||||
|
||||
bufferPtr = encodeUtf8(codepoint, bufferPtr);
|
||||
bufferPtr = SDL_Ucs4ToUtf8(codepoint, bufferPtr);
|
||||
*bufferPtr = '\0';
|
||||
|
||||
if ((layoutKey & SDL_KEY_KEYPAD_BIT) != 0) {
|
||||
|
|
|
@ -48,6 +48,9 @@ struct SDL_Keyboard
|
|||
#endif
|
||||
extern int SDL_TranslateUNICODE;
|
||||
|
||||
/* convert UCS4 to utf8 */
|
||||
extern char *SDL_Ucs4ToUtf8(Uint32 ch, char *dst);
|
||||
|
||||
/* Initialize the keyboard subsystem */
|
||||
extern int SDL_KeyboardInit(void);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue