diff src/events/SDL_keyboard.c @ 2300:c97ad1abe05b

Minimal implementation of textinput events for x11. It only works for latin-1.
author Bob Pendleton <bob@pendleton.com>
date Tue, 15 Jan 2008 22:37:17 +0000
parents dbc6d1893869
children d87417504c75
line wrap: on
line diff
--- a/src/events/SDL_keyboard.c	Sat Jan 12 18:07:06 2008 +0000
+++ b/src/events/SDL_keyboard.c	Tue Jan 15 22:37:17 2008 +0000
@@ -37,8 +37,8 @@
 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 @@
             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) {