src/video/x11/SDL_x11keyboard.c
author Ryan C. Gordon <icculus@icculus.org>
Thu, 09 Apr 2015 22:28:37 -0400
changeset 9541 cf8fab52e33b
parent 9096 6454f71d6f15
child 9619 b94b6d0bff0f
permissions -rw-r--r--
Merged Alex Szpakowski's iOS-improvement branch to default.

Fixes Bugzilla #2798.
Fixes Bugzilla #2212.
Fixes Bugzilla #2826.
Fixes Bugzilla #2661.
Fixes Bugzilla #1885.
Fixes Bugzilla #1578.
Fixes Bugzilla #2751.

(whew!)

Notable changes, from Alex's notes:

- The SDL_WINDOW_ALLOW_HIGHDPI flag is now needed (along with SDL_GL_GetDrawableSize or SDL_GetRendererOutputSize) to use Retina / high DPI resolutions, bringing SDL’s Retina-related behavior on iOS in line with Mac OS X. Window dimensions and display modes are now in the “points” (non-high DPI) coordinate system rather than pixels, whereas SDL_GL_GetDrawableSize is in pixels.

- Reworked the custom extended launch screen code:
- It now hides after the first SDL_PumpEvents call rather than SDL_CreateWindow, and it fades out in a similar manner to the system launch screen behavior.
- It now mirrors the system launch screen behavior when deciding which image to display: it falls back to using the Launch Images dictionary in Info.plist if the iOS 8+ launch screen nib isn’t available, and if the Launch Images dictionary doesn’t exist it uses the old standard launch image names.
- The extended launch screen can now be disabled via the SDL_IPHONE_LAUNCHSCREEN define in SDL_config_iphoneos.h.

- Added support for SDL_HINT_ACCELEROMETER_AS_JOYSTICK.

- Added access to a window view's renderbuffer and framebuffer to syswm.

- Added OpenGL ES debug labels for the Renderbuffer and Framebuffer Objects created with SDL_GL_CreateContext.

- Added support for sRGB OpenGL ES contexts on iOS 7+.

- Updated OpenGL ES contexts to support native-resolution rendering (when SDL_WINDOW_ALLOW_HIGHDPI is enabled) on the iPhone 6 Plus, i.e. 1080x1920 rather than 1242x2208.

- Updated SDL_GL_CreateContext, SDL_GL_SwapWindow, SDL_GL_MakeCurrent, and SDL_GL_DeleteContext to be more robust.

- Updated SDL windows to display a UIView at all times, even when an OpenGL context is not active. This allows rotation, touch events, and other windowing-related events to work properly without an active OpenGL context. It also makes it easier to use SDL_GetWindowWMInfo after creating a SDL window.

- Updated the iOS-specific Objective-C code to use cleaner and more modern language features and APIs, including ARC instead of manual reference counting.

- Updated SDL_HINT_ORIENTATIONS to allow disabling custom orientations if the hint is set with no valid orientation names.

- Fixed several rotation and orientation bugs with windows and display modes, especially in iOS 8+.

- Fixed SDL_SetWindowFullscreen failing to update the status bar visibility on iOS 7+.

- Fixed the orientation of the offset applied to the window’s view when the onscreen keyboard is shown in iOS 8+.

- Fixed SDL_IsScreenKeyboardShown (patch by Phil Hassey.)

- Fixed several major memory leaks caused by missing autorelease pool blocks in the iOS-specific Objective-C code.

- Removed several dead code paths.

- The iOS 7 SDK (Xcode 5) or newer is now required to build SDL for iOS.
slouken@1950
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@8149
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
slouken@1950
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@1950
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@1950
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@1950
    20
*/
icculus@8093
    21
#include "../../SDL_internal.h"
slouken@1950
    22
slouken@5481
    23
#if SDL_VIDEO_DRIVER_X11
slouken@5481
    24
slouken@1950
    25
#include "SDL_x11video.h"
slouken@1950
    26
slouken@1950
    27
#include "../../events/SDL_keyboard_c.h"
slouken@2305
    28
#include "../../events/scancodes_darwin.h"
slouken@2305
    29
#include "../../events/scancodes_xfree86.h"
slouken@1950
    30
bob@2295
    31
#include <X11/keysym.h>
bob@2295
    32
bob@2295
    33
#include "imKStoUCS.h"
bob@2295
    34
slouken@3001
    35
/* *INDENT-OFF* */
slouken@3162
    36
static const struct {
slouken@3001
    37
    KeySym keysym;
slouken@7580
    38
    SDL_Scancode scancode;
slouken@7580
    39
} KeySymToSDLScancode[] = {
slouken@7580
    40
    { XK_Return, SDL_SCANCODE_RETURN },
slouken@7580
    41
    { XK_Escape, SDL_SCANCODE_ESCAPE },
slouken@7580
    42
    { XK_BackSpace, SDL_SCANCODE_BACKSPACE },
slouken@7580
    43
    { XK_Tab, SDL_SCANCODE_TAB },
slouken@7580
    44
    { XK_Caps_Lock, SDL_SCANCODE_CAPSLOCK },
slouken@7580
    45
    { XK_F1, SDL_SCANCODE_F1 },
slouken@7580
    46
    { XK_F2, SDL_SCANCODE_F2 },
slouken@7580
    47
    { XK_F3, SDL_SCANCODE_F3 },
slouken@7580
    48
    { XK_F4, SDL_SCANCODE_F4 },
slouken@7580
    49
    { XK_F5, SDL_SCANCODE_F5 },
slouken@7580
    50
    { XK_F6, SDL_SCANCODE_F6 },
slouken@7580
    51
    { XK_F7, SDL_SCANCODE_F7 },
slouken@7580
    52
    { XK_F8, SDL_SCANCODE_F8 },
slouken@7580
    53
    { XK_F9, SDL_SCANCODE_F9 },
slouken@7580
    54
    { XK_F10, SDL_SCANCODE_F10 },
slouken@7580
    55
    { XK_F11, SDL_SCANCODE_F11 },
slouken@7580
    56
    { XK_F12, SDL_SCANCODE_F12 },
slouken@7580
    57
    { XK_Print, SDL_SCANCODE_PRINTSCREEN },
slouken@7580
    58
    { XK_Scroll_Lock, SDL_SCANCODE_SCROLLLOCK },
slouken@7580
    59
    { XK_Pause, SDL_SCANCODE_PAUSE },
slouken@7580
    60
    { XK_Insert, SDL_SCANCODE_INSERT },
slouken@7580
    61
    { XK_Home, SDL_SCANCODE_HOME },
slouken@7580
    62
    { XK_Prior, SDL_SCANCODE_PAGEUP },
slouken@7580
    63
    { XK_Delete, SDL_SCANCODE_DELETE },
slouken@7580
    64
    { XK_End, SDL_SCANCODE_END },
slouken@7580
    65
    { XK_Next, SDL_SCANCODE_PAGEDOWN },
slouken@7580
    66
    { XK_Right, SDL_SCANCODE_RIGHT },
slouken@7580
    67
    { XK_Left, SDL_SCANCODE_LEFT },
slouken@7580
    68
    { XK_Down, SDL_SCANCODE_DOWN },
slouken@7580
    69
    { XK_Up, SDL_SCANCODE_UP },
slouken@7580
    70
    { XK_Num_Lock, SDL_SCANCODE_NUMLOCKCLEAR },
slouken@7580
    71
    { XK_KP_Divide, SDL_SCANCODE_KP_DIVIDE },
slouken@7580
    72
    { XK_KP_Multiply, SDL_SCANCODE_KP_MULTIPLY },
slouken@7580
    73
    { XK_KP_Subtract, SDL_SCANCODE_KP_MINUS },
slouken@7580
    74
    { XK_KP_Add, SDL_SCANCODE_KP_PLUS },
slouken@7580
    75
    { XK_KP_Enter, SDL_SCANCODE_KP_ENTER },
slouken@7580
    76
    { XK_KP_Delete, SDL_SCANCODE_KP_PERIOD },
slouken@7580
    77
    { XK_KP_End, SDL_SCANCODE_KP_1 },
slouken@7580
    78
    { XK_KP_Down, SDL_SCANCODE_KP_2 },
slouken@7580
    79
    { XK_KP_Next, SDL_SCANCODE_KP_3 },
slouken@7580
    80
    { XK_KP_Left, SDL_SCANCODE_KP_4 },
slouken@7580
    81
    { XK_KP_Begin, SDL_SCANCODE_KP_5 },
slouken@7580
    82
    { XK_KP_Right, SDL_SCANCODE_KP_6 },
slouken@7580
    83
    { XK_KP_Home, SDL_SCANCODE_KP_7 },
slouken@7580
    84
    { XK_KP_Up, SDL_SCANCODE_KP_8 },
slouken@7580
    85
    { XK_KP_Prior, SDL_SCANCODE_KP_9 },
slouken@7580
    86
    { XK_KP_Insert, SDL_SCANCODE_KP_0 },
slouken@7580
    87
    { XK_KP_Decimal, SDL_SCANCODE_KP_PERIOD },
slouken@7580
    88
    { XK_KP_1, SDL_SCANCODE_KP_1 },
slouken@7580
    89
    { XK_KP_2, SDL_SCANCODE_KP_2 },
slouken@7580
    90
    { XK_KP_3, SDL_SCANCODE_KP_3 },
slouken@7580
    91
    { XK_KP_4, SDL_SCANCODE_KP_4 },
slouken@7580
    92
    { XK_KP_5, SDL_SCANCODE_KP_5 },
slouken@7580
    93
    { XK_KP_6, SDL_SCANCODE_KP_6 },
slouken@7580
    94
    { XK_KP_7, SDL_SCANCODE_KP_7 },
slouken@7580
    95
    { XK_KP_8, SDL_SCANCODE_KP_8 },
slouken@7580
    96
    { XK_KP_9, SDL_SCANCODE_KP_9 },
slouken@7580
    97
    { XK_KP_0, SDL_SCANCODE_KP_0 },
slouken@7580
    98
    { XK_KP_Decimal, SDL_SCANCODE_KP_PERIOD },
slouken@7580
    99
    { XK_Hyper_R, SDL_SCANCODE_APPLICATION },
slouken@7580
   100
    { XK_KP_Equal, SDL_SCANCODE_KP_EQUALS },
slouken@7580
   101
    { XK_F13, SDL_SCANCODE_F13 },
slouken@7580
   102
    { XK_F14, SDL_SCANCODE_F14 },
slouken@7580
   103
    { XK_F15, SDL_SCANCODE_F15 },
slouken@7580
   104
    { XK_F16, SDL_SCANCODE_F16 },
slouken@7580
   105
    { XK_F17, SDL_SCANCODE_F17 },
slouken@7580
   106
    { XK_F18, SDL_SCANCODE_F18 },
slouken@7580
   107
    { XK_F19, SDL_SCANCODE_F19 },
slouken@7580
   108
    { XK_F20, SDL_SCANCODE_F20 },
slouken@7580
   109
    { XK_F21, SDL_SCANCODE_F21 },
slouken@7580
   110
    { XK_F22, SDL_SCANCODE_F22 },
slouken@7580
   111
    { XK_F23, SDL_SCANCODE_F23 },
slouken@7580
   112
    { XK_F24, SDL_SCANCODE_F24 },
slouken@7580
   113
    { XK_Execute, SDL_SCANCODE_EXECUTE },
slouken@7580
   114
    { XK_Help, SDL_SCANCODE_HELP },
slouken@7580
   115
    { XK_Menu, SDL_SCANCODE_MENU },
slouken@7580
   116
    { XK_Select, SDL_SCANCODE_SELECT },
slouken@7580
   117
    { XK_Cancel, SDL_SCANCODE_STOP },
slouken@7580
   118
    { XK_Redo, SDL_SCANCODE_AGAIN },
slouken@7580
   119
    { XK_Undo, SDL_SCANCODE_UNDO },
slouken@7580
   120
    { XK_Find, SDL_SCANCODE_FIND },
slouken@7580
   121
    { XK_KP_Separator, SDL_SCANCODE_KP_COMMA },
slouken@7580
   122
    { XK_Sys_Req, SDL_SCANCODE_SYSREQ },
slouken@7580
   123
    { XK_Control_L, SDL_SCANCODE_LCTRL },
slouken@7580
   124
    { XK_Shift_L, SDL_SCANCODE_LSHIFT },
slouken@7580
   125
    { XK_Alt_L, SDL_SCANCODE_LALT },
slouken@7580
   126
    { XK_Meta_L, SDL_SCANCODE_LGUI },
slouken@7580
   127
    { XK_Super_L, SDL_SCANCODE_LGUI },
slouken@7580
   128
    { XK_Control_R, SDL_SCANCODE_RCTRL },
slouken@7580
   129
    { XK_Shift_R, SDL_SCANCODE_RSHIFT },
slouken@7580
   130
    { XK_Alt_R, SDL_SCANCODE_RALT },
slouken@7580
   131
    { XK_Meta_R, SDL_SCANCODE_RGUI },
slouken@7580
   132
    { XK_Super_R, SDL_SCANCODE_RGUI },
slouken@7580
   133
    { XK_Mode_switch, SDL_SCANCODE_MODE },
bob@2295
   134
};
bob@2295
   135
slouken@3162
   136
static const struct
bob@2295
   137
{
slouken@7882
   138
    SDL_Scancode const *table;
slouken@2305
   139
    int table_size;
slouken@2305
   140
} scancode_set[] = {
slouken@2308
   141
    { darwin_scancode_table, SDL_arraysize(darwin_scancode_table) },
slouken@2308
   142
    { xfree86_scancode_table, SDL_arraysize(xfree86_scancode_table) },
slouken@2825
   143
    { xfree86_scancode_table2, SDL_arraysize(xfree86_scancode_table2) },
slouken@2308
   144
};
slouken@2308
   145
/* *INDENT-OFF* */
bob@2295
   146
slouken@7580
   147
/* This function only works for keyboards in US QWERTY layout */
slouken@7580
   148
static SDL_Scancode
slouken@7580
   149
X11_KeyCodeToSDLScancode(Display *display, KeyCode keycode)
slouken@3001
   150
{
slouken@3001
   151
    KeySym keysym;
slouken@3001
   152
    int i;
slouken@3001
   153
dimitris@6318
   154
#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
icculus@7827
   155
    keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0);
dimitris@6318
   156
#else
slouken@3001
   157
    keysym = XKeycodeToKeysym(display, keycode, 0);
dimitris@6318
   158
#endif
slouken@3001
   159
    if (keysym == NoSymbol) {
slouken@7580
   160
        return SDL_SCANCODE_UNKNOWN;
slouken@3001
   161
    }
slouken@3001
   162
slouken@7580
   163
    if (keysym >= XK_A && keysym <= XK_Z) {
slouken@7580
   164
        return SDL_SCANCODE_A + (keysym - XK_A);
slouken@3001
   165
    }
slouken@3001
   166
slouken@7580
   167
    if (keysym >= XK_0 && keysym <= XK_9) {
slouken@7580
   168
        return SDL_SCANCODE_0 + (keysym - XK_0);
slouken@7580
   169
    }
slouken@7580
   170
slouken@7580
   171
    for (i = 0; i < SDL_arraysize(KeySymToSDLScancode); ++i) {
slouken@7580
   172
        if (keysym == KeySymToSDLScancode[i].keysym) {
slouken@7580
   173
            return KeySymToSDLScancode[i].scancode;
slouken@3001
   174
        }
slouken@3001
   175
    }
slouken@7580
   176
    return SDL_SCANCODE_UNKNOWN;
slouken@7580
   177
}
slouken@7580
   178
slouken@7580
   179
static Uint32
slouken@7580
   180
X11_KeyCodeToUcs4(Display *display, KeyCode keycode)
slouken@7580
   181
{
slouken@7580
   182
    KeySym keysym;
slouken@7580
   183
slouken@7580
   184
#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
icculus@7827
   185
    keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0);
slouken@7580
   186
#else
slouken@7580
   187
    keysym = XKeycodeToKeysym(display, keycode, 0);
slouken@7580
   188
#endif
slouken@7580
   189
    if (keysym == NoSymbol) {
slouken@7580
   190
        return 0;
slouken@7580
   191
    }
slouken@7580
   192
slouken@7580
   193
    return X11_KeySymToUcs4(keysym);
slouken@3001
   194
}
slouken@3001
   195
bob@2295
   196
int
slouken@1950
   197
X11_InitKeyboard(_THIS)
slouken@1950
   198
{
slouken@1950
   199
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
icculus@7672
   200
    int i = 0;
icculus@7672
   201
    int j = 0;
slouken@2305
   202
    int min_keycode, max_keycode;
slouken@3001
   203
    struct {
slouken@5218
   204
        SDL_Scancode scancode;
slouken@3001
   205
        KeySym keysym;
slouken@3001
   206
        int value;
slouken@3001
   207
    } fingerprint[] = {
slouken@3001
   208
        { SDL_SCANCODE_HOME, XK_Home, 0 },
slouken@3001
   209
        { SDL_SCANCODE_PAGEUP, XK_Prior, 0 },
slouken@8667
   210
        { SDL_SCANCODE_UP, XK_Up, 0 },
slouken@8667
   211
        { SDL_SCANCODE_LEFT, XK_Left, 0 },
slouken@8667
   212
        { SDL_SCANCODE_DELETE, XK_Delete, 0 },
slouken@8667
   213
        { SDL_SCANCODE_KP_ENTER, XK_KP_Enter, 0 },
slouken@2305
   214
    };
slouken@8667
   215
    int best_distance;
slouken@8667
   216
    int best_index;
slouken@8667
   217
    int distance;
bob@2295
   218
icculus@7827
   219
    X11_XAutoRepeatOn(data->display);
bob@2299
   220
slouken@2305
   221
    /* Try to determine which scancodes are being used based on fingerprint */
slouken@8667
   222
    best_distance = SDL_arraysize(fingerprint) + 1;
slouken@8667
   223
    best_index = -1;
icculus@7827
   224
    X11_XDisplayKeycodes(data->display, &min_keycode, &max_keycode);
slouken@3001
   225
    for (i = 0; i < SDL_arraysize(fingerprint); ++i) {
slouken@3001
   226
        fingerprint[i].value =
icculus@7827
   227
            X11_XKeysymToKeycode(data->display, fingerprint[i].keysym) -
slouken@2305
   228
            min_keycode;
slouken@2305
   229
    }
slouken@2305
   230
    for (i = 0; i < SDL_arraysize(scancode_set); ++i) {
slouken@2305
   231
        /* Make sure the scancode set isn't too big */
slouken@2305
   232
        if ((max_keycode - min_keycode + 1) <= scancode_set[i].table_size) {
slouken@2305
   233
            continue;
slouken@2305
   234
        }
slouken@8667
   235
        distance = 0;
slouken@2305
   236
        for (j = 0; j < SDL_arraysize(fingerprint); ++j) {
slouken@3001
   237
            if (fingerprint[j].value < 0
slouken@3001
   238
                || fingerprint[j].value >= scancode_set[i].table_size) {
slouken@8667
   239
                distance += 1;
slouken@8667
   240
            } else if (scancode_set[i].table[fingerprint[j].value] != fingerprint[j].scancode) {
slouken@8667
   241
                distance += 1;
slouken@2305
   242
            }
slouken@2305
   243
        }
slouken@8667
   244
        if (distance < best_distance) {
slouken@8667
   245
            best_distance = distance;
slouken@8667
   246
            best_index = i;
slouken@2305
   247
        }
slouken@2305
   248
    }
slouken@8667
   249
    if (best_index >= 0 && best_distance <= 2) {
slouken@8667
   250
#ifdef DEBUG_KEYBOARD
slouken@8667
   251
        printf("Using scancode set %d, min_keycode = %d, max_keycode = %d, table_size = %d\n", best_index, min_keycode, max_keycode, scancode_set[best_index].table_size);
slouken@8667
   252
#endif
slouken@8667
   253
        SDL_memcpy(&data->key_layout[min_keycode], scancode_set[best_index].table,
slouken@8667
   254
                   sizeof(SDL_Scancode) * scancode_set[best_index].table_size);
slouken@8667
   255
    }
slouken@8667
   256
    else {
slouken@5220
   257
        SDL_Keycode keymap[SDL_NUM_SCANCODES];
slouken@3001
   258
slouken@2305
   259
        printf
slouken@2305
   260
            ("Keyboard layout unknown, please send the following to the SDL mailing list (sdl@libsdl.org):\n");
slouken@2305
   261
slouken@2305
   262
        /* Determine key_layout - only works on US QWERTY layout */
slouken@3001
   263
        SDL_GetDefaultKeymap(keymap);
slouken@2305
   264
        for (i = min_keycode; i <= max_keycode; ++i) {
slouken@2305
   265
            KeySym sym;
dimitris@6318
   266
#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
icculus@7827
   267
            sym = X11_XkbKeycodeToKeysym(data->display, i, 0, 0);
dimitris@6318
   268
#else
slouken@2305
   269
            sym = XKeycodeToKeysym(data->display, i, 0);
dimitris@6318
   270
#endif
slouken@3001
   271
            if (sym != NoSymbol) {
slouken@7580
   272
                SDL_Scancode scancode;
icculus@3667
   273
                printf("code = %d, sym = 0x%X (%s) ", i - min_keycode,
icculus@7827
   274
                       (unsigned int) sym, X11_XKeysymToString(sym));
slouken@7580
   275
                scancode = X11_KeyCodeToSDLScancode(data->display, i);
slouken@7580
   276
                data->key_layout[i] = scancode;
slouken@7580
   277
                if (scancode == SDL_SCANCODE_UNKNOWN) {
slouken@2305
   278
                    printf("scancode not found\n");
slouken@2305
   279
                } else {
slouken@7824
   280
                    printf("scancode = %d (%s)\n", scancode, SDL_GetScancodeName(scancode));
slouken@2305
   281
                }
slouken@2305
   282
            }
slouken@2305
   283
        }
slouken@2305
   284
    }
slouken@1950
   285
slouken@2306
   286
    X11_UpdateKeymap(_this);
bob@2295
   287
slouken@2305
   288
    SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu");
bob@2295
   289
alex@8889
   290
#ifdef SDL_USE_IBUS
alex@8889
   291
    SDL_IBus_Init();
alex@8889
   292
#endif
alex@8889
   293
bob@2295
   294
    return 0;
bob@2295
   295
}
bob@2295
   296
slouken@2305
   297
void
slouken@2305
   298
X11_UpdateKeymap(_THIS)
bob@2295
   299
{
bob@2295
   300
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
slouken@2305
   301
    int i;
slouken@5218
   302
    SDL_Scancode scancode;
slouken@5220
   303
    SDL_Keycode keymap[SDL_NUM_SCANCODES];
bob@2295
   304
slouken@7580
   305
    SDL_GetDefaultKeymap(keymap);
slouken@2305
   306
    for (i = 0; i < SDL_arraysize(data->key_layout); i++) {
slouken@7580
   307
        Uint32 key;
slouken@2305
   308
slouken@3001
   309
        /* Make sure this is a valid scancode */
slouken@2305
   310
        scancode = data->key_layout[i];
slouken@3001
   311
        if (scancode == SDL_SCANCODE_UNKNOWN) {
slouken@2305
   312
            continue;
slouken@2305
   313
        }
slouken@2305
   314
slouken@7580
   315
        /* See if there is a UCS keycode for this scancode */
slouken@7580
   316
        key = X11_KeyCodeToUcs4(data->display, (KeyCode)i);
slouken@7580
   317
        if (key) {
slouken@7580
   318
            keymap[scancode] = key;
slouken@7580
   319
        }
bob@2295
   320
    }
slouken@4465
   321
    SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
slouken@1950
   322
}
slouken@1950
   323
slouken@1950
   324
void
slouken@1950
   325
X11_QuitKeyboard(_THIS)
slouken@1950
   326
{
alex@8889
   327
#ifdef SDL_USE_IBUS
alex@8889
   328
    SDL_IBus_Quit();
alex@8889
   329
#endif
alex@8889
   330
}
alex@8889
   331
alex@8889
   332
void
alex@8889
   333
X11_StartTextInput(_THIS)
alex@8889
   334
{
alex@9096
   335
alex@8889
   336
}
alex@8889
   337
alex@8889
   338
void
alex@8889
   339
X11_StopTextInput(_THIS)
alex@8889
   340
{
alex@8889
   341
#ifdef SDL_USE_IBUS
alex@8889
   342
    SDL_IBus_Reset();
alex@8889
   343
#endif
alex@8889
   344
}
alex@8889
   345
alex@8889
   346
void
alex@8889
   347
X11_SetTextInputRect(_THIS, SDL_Rect *rect)
alex@8889
   348
{
alex@8889
   349
    if (!rect) {
alex@8889
   350
        SDL_InvalidParamError("rect");
alex@8889
   351
        return;
alex@8889
   352
    }
alex@8889
   353
       
alex@8889
   354
#ifdef SDL_USE_IBUS
alex@8889
   355
    SDL_IBus_UpdateTextRect(rect);
alex@8889
   356
#endif
slouken@1950
   357
}
slouken@1950
   358
slouken@5481
   359
#endif /* SDL_VIDEO_DRIVER_X11 */
slouken@5481
   360
slouken@1950
   361
/* vi: set ts=4 sw=4 expandtab: */