src/video/win32/SDL_win32keyboard.c
author dewyatt
Mon, 12 Jul 2010 11:33:27 -0400
changeset 4752 dc7bdcf06367
parent 4751 f3908cd80b10
child 4753 11b0a6a3eb4d
permissions -rw-r--r--
Initial IMM implementation. IME input should now work fairly well.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
3697
f7b03b6838cb Fixed bug #926
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
     3
    Copyright (C) 1997-2010 Sam Lantinga
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    Lesser General Public License for more details.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free Software
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    Sam Lantinga
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    slouken@libsdl.org
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
*/
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
#include "SDL_config.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
#include "SDL_win32video.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
#include "../../events/SDL_keyboard_c.h"
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    27
#include "../../events/scancodes_win32.h"
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    29
#include <msctf.h>
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    30
#include <imm.h>
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    31
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    32
#ifndef MAPVK_VK_TO_VSC
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    33
#define MAPVK_VK_TO_VSC     0
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    34
#endif
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    35
#ifndef MAPVK_VSC_TO_VK
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    36
#define MAPVK_VSC_TO_VK     1
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    37
#endif
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    38
#ifndef MAPVK_VK_TO_CHAR
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    39
#define MAPVK_VK_TO_CHAR    2
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    40
#endif
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    41
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    42
/* Alphabetic scancodes for PC keyboards */
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    43
BYTE alpha_scancodes[26] = {
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    44
    30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24,
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    45
    25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    46
};
2735
204be4fc2726 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2726
diff changeset
    47
2317
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2311
diff changeset
    48
BYTE keypad_scancodes[10] = {
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2311
diff changeset
    49
    82, 79, 80, 81, 75, 76, 77, 71, 72, 73
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2311
diff changeset
    50
};
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    51
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    52
void IME_Disable(SDL_VideoData *videodata, HWND hwnd);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    53
void IME_Enable(SDL_VideoData *videodata, HWND hwnd);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    54
void IME_Init(SDL_VideoData *videodata, HWND hwnd);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    55
void IME_Quit(SDL_VideoData *videodata);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    56
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
WIN_InitKeyboard(_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    61
    int i;
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    62
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    63
    /* Make sure the alpha scancodes are correct.  T isn't usually remapped */
2324
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2317
diff changeset
    64
    if (MapVirtualKey('T', MAPVK_VK_TO_VSC) != alpha_scancodes['T' - 'A']) {
2724
0e2b65f32298 Added Wacom API headers.
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
    65
#if 0
2726
f23ebf1ddac4 Dynamically load wintab32.dll
Sam Lantinga <slouken@libsdl.org>
parents: 2724
diff changeset
    66
        printf
f23ebf1ddac4 Dynamically load wintab32.dll
Sam Lantinga <slouken@libsdl.org>
parents: 2724
diff changeset
    67
            ("Fixing alpha scancode map, assuming US QWERTY layout!\nPlease send the following 26 lines of output to the SDL mailing list <sdl@libsdl.org>, including a description of your keyboard hardware.\n");
2724
0e2b65f32298 Added Wacom API headers.
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
    68
#endif
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    69
        for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) {
2324
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2317
diff changeset
    70
            alpha_scancodes[i] = MapVirtualKey('A' + i, MAPVK_VK_TO_VSC);
2724
0e2b65f32298 Added Wacom API headers.
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
    71
#if 0
2324
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2317
diff changeset
    72
            printf("%d = %d\n", i, alpha_scancodes[i]);
2724
0e2b65f32298 Added Wacom API headers.
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
    73
#endif
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    74
        }
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    75
    }
2317
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2311
diff changeset
    76
    if (MapVirtualKey(VK_NUMPAD0, MAPVK_VK_TO_VSC) != keypad_scancodes[0]) {
2724
0e2b65f32298 Added Wacom API headers.
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
    77
#if 0
2726
f23ebf1ddac4 Dynamically load wintab32.dll
Sam Lantinga <slouken@libsdl.org>
parents: 2724
diff changeset
    78
        printf
f23ebf1ddac4 Dynamically load wintab32.dll
Sam Lantinga <slouken@libsdl.org>
parents: 2724
diff changeset
    79
            ("Fixing keypad scancode map!\nPlease send the following 10 lines of output to the SDL mailing list <sdl@libsdl.org>, including a description of your keyboard hardware.\n");
2724
0e2b65f32298 Added Wacom API headers.
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
    80
#endif
2317
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2311
diff changeset
    81
        for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
2324
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2317
diff changeset
    82
            keypad_scancodes[i] =
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2317
diff changeset
    83
                MapVirtualKey(VK_NUMPAD0 + i, MAPVK_VK_TO_VSC);
2724
0e2b65f32298 Added Wacom API headers.
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
    84
#if 0
2324
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2317
diff changeset
    85
            printf("%d = %d\n", i, keypad_scancodes[i]);
2724
0e2b65f32298 Added Wacom API headers.
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
    86
#endif
2317
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2311
diff changeset
    87
        }
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2311
diff changeset
    88
    }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    90
    data->key_layout = win32_scancode_table;
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    91
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    92
    data->ime_com_initialized = SDL_FALSE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    93
    data->ime_thread_mgr = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    94
    data->ime_initialized = SDL_FALSE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    95
    data->ime_enabled = SDL_FALSE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    96
    data->ime_available = SDL_FALSE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    97
    data->ime_hwnd_main = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    98
    data->ime_hwnd_current = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    99
    data->ime_himc = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   100
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
   101
    WIN_UpdateKeymap();
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   102
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   103
    SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu");
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   104
    SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Windows");
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   105
    SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Windows");
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   106
}
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   107
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   108
void
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
   109
WIN_UpdateKeymap()
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   110
{
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   111
    int i;
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   112
    SDL_scancode scancode;
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   113
    SDLKey keymap[SDL_NUM_SCANCODES];
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   114
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   115
    SDL_GetDefaultKeymap(keymap);
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   116
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   117
    for (i = 0; i < SDL_arraysize(win32_scancode_table); i++) {
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   118
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   119
        /* Make sure this scancode is a valid character scancode */
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   120
        scancode = win32_scancode_table[i];
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   121
        if (scancode == SDL_SCANCODE_UNKNOWN ||
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   122
            (keymap[scancode] & SDLK_SCANCODE_MASK)) {
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   123
            continue;
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   124
        }
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
   125
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
   126
        /* Alphabetic keys are handled specially, since Windows remaps them */
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
   127
        if (i >= 'A' && i <= 'Z') {
2324
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2317
diff changeset
   128
            BYTE vsc = alpha_scancodes[i - 'A'];
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
   129
            keymap[scancode] = MapVirtualKey(vsc, MAPVK_VSC_TO_VK) + 0x20;
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
   130
        } else {
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
   131
            keymap[scancode] = (MapVirtualKey(i, MAPVK_VK_TO_CHAR) & 0x7FFF);
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
   132
        }
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   133
    }
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
   134
    SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
WIN_QuitKeyboard(_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
{
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   140
    IME_Quit((SDL_VideoData *)_this->driverdata);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
4747
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   143
void
4750
22aa6a631d34 Changed StartTextInput to take an SDL_Window parameter.
dewyatt
parents: 4748
diff changeset
   144
WIN_StartTextInput(_THIS, SDL_Window *window)
4747
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   145
{
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   146
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   147
    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   148
    IME_Init(videodata, hwnd);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   149
    IME_Enable(videodata, hwnd);
4747
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   150
}
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   151
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   152
void
4751
f3908cd80b10 Changed StopTextInput to take an SDL_Window parameter.
dewyatt
parents: 4750
diff changeset
   153
WIN_StopTextInput(_THIS, SDL_Window *window)
4747
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   154
{
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   155
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   156
    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   157
    IME_Init(videodata, hwnd);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   158
    IME_Disable(videodata, hwnd);
4747
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   159
}
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   160
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   161
void
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   162
WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   163
{
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   164
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   165
}
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   166
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   167
void
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   168
IME_Disable(SDL_VideoData *videodata, HWND hwnd)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   169
{
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   170
    if (!videodata->ime_initialized || !videodata->ime_hwnd_current)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   171
        return;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   172
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   173
    if (videodata->ime_hwnd_current == videodata->ime_hwnd_main)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   174
        ImmAssociateContext(videodata->ime_hwnd_current, NULL);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   175
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   176
    videodata->ime_enabled = SDL_FALSE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   177
}
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   178
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   179
void
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   180
IME_Enable(SDL_VideoData *videodata, HWND hwnd)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   181
{
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   182
    if (!videodata->ime_initialized || !videodata->ime_hwnd_current)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   183
        return;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   184
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   185
    if (!videodata->ime_available) {
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   186
        IME_Disable(videodata, hwnd);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   187
        return;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   188
    }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   189
    if (videodata->ime_hwnd_current == videodata->ime_hwnd_main)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   190
        ImmAssociateContext(videodata->ime_hwnd_current, videodata->ime_himc);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   191
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   192
    videodata->ime_enabled = SDL_TRUE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   193
}
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   194
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   195
void
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   196
IME_Init(SDL_VideoData *videodata, HWND hwnd)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   197
{
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   198
    if (videodata->ime_initialized)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   199
        return;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   200
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   201
    videodata->ime_hwnd_main = hwnd;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   202
    if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) {
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   203
        videodata->ime_com_initialized = SDL_TRUE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   204
        CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgr, &videodata->ime_thread_mgr);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   205
    }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   206
    videodata->ime_initialized = SDL_TRUE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   207
    videodata->ime_hwnd_current = videodata->ime_hwnd_main;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   208
    if (videodata->ime_thread_mgr) {
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   209
        struct ITfDocumentMgr *document_mgr = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   210
        if (SUCCEEDED(videodata->ime_thread_mgr->lpVtbl->AssociateFocus(videodata->ime_thread_mgr, hwnd, NULL, &document_mgr))) {
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   211
            if (document_mgr)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   212
                document_mgr->lpVtbl->Release(document_mgr);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   213
        }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   214
    }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   215
    videodata->ime_himc = ImmGetContext(hwnd);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   216
    ImmReleaseContext(hwnd, videodata->ime_himc);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   217
    if (!videodata->ime_himc) {
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   218
        videodata->ime_available = SDL_FALSE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   219
        IME_Disable(videodata, hwnd);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   220
        return;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   221
    }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   222
    videodata->ime_available = SDL_TRUE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   223
    IME_Disable(videodata, hwnd);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   224
}
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   225
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   226
void
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   227
IME_Quit(SDL_VideoData *videodata)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   228
{
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   229
    if (!videodata->ime_initialized)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   230
        return;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   231
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   232
    if (videodata->ime_hwnd_main)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   233
        ImmAssociateContext(videodata->ime_hwnd_main, videodata->ime_himc);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   234
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   235
    videodata->ime_hwnd_main = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   236
    videodata->ime_himc = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   237
    if (videodata->ime_thread_mgr)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   238
    {
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   239
        videodata->ime_thread_mgr->lpVtbl->Release(videodata->ime_thread_mgr);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   240
        videodata->ime_thread_mgr = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   241
    }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   242
    if (videodata->ime_com_initialized)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   243
    {
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   244
        CoUninitialize();
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   245
        videodata->ime_com_initialized = SDL_FALSE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   246
    }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   247
    videodata->ime_initialized = SDL_FALSE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   248
}
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   249
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   250
SDL_bool
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   251
IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoData *videodata)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   252
{
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   253
    SDL_bool trap = SDL_FALSE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   254
    HIMC himc = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   255
    WCHAR Buffer[SDL_TEXTINPUTEVENT_TEXT_SIZE / 2];
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   256
    if (!videodata->ime_initialized || !videodata->ime_available || !videodata->ime_enabled)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   257
        return SDL_FALSE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   258
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   259
    switch (msg)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   260
    {
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   261
    case WM_INPUTLANGCHANGE:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   262
        break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   263
    case WM_IME_SETCONTEXT:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   264
        *lParam = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   265
        break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   266
    case WM_IME_STARTCOMPOSITION:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   267
        trap = SDL_TRUE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   268
        break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   269
    case WM_IME_COMPOSITION:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   270
        trap = SDL_TRUE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   271
        himc = ImmGetContext(hwnd);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   272
        if (*lParam & GCS_RESULTSTR)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   273
        {
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   274
            LONG Length = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   275
            char *s = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   276
            Length = ImmGetCompositionStringW(himc, GCS_RESULTSTR, Buffer, sizeof(Buffer) * sizeof(Buffer[0]));
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   277
            Buffer[Length / sizeof(Buffer[0])] = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   278
            s = WIN_StringToUTF8(Buffer);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   279
            SDL_SendKeyboardText(s);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   280
            SDL_free(s);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   281
        }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   282
        if (*lParam & GCS_COMPSTR)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   283
        {
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   284
            LONG Length = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   285
            DWORD Cursor = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   286
            char *s = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   287
            Length = ImmGetCompositionStringW(himc, GCS_COMPSTR, Buffer, sizeof(Buffer) * sizeof(Buffer[0]));
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   288
            Buffer[Length / sizeof(Buffer[0])] = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   289
            s = WIN_StringToUTF8(Buffer);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   290
            Cursor = LOWORD(ImmGetCompositionStringW(himc, GCS_CURSORPOS, 0, 0));
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   291
            SDL_SendEditingText(s, Cursor, 0);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   292
            SDL_free(s);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   293
        }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   294
        ImmReleaseContext(hwnd, himc);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   295
        break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   296
    case WM_IME_ENDCOMPOSITION:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   297
        SDL_SendKeyboardText("");
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   298
        break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   299
    case WM_IME_NOTIFY:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   300
        switch (wParam)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   301
        {
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   302
        case IMN_SETCONVERSIONMODE:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   303
            break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   304
        case IMN_SETOPENSTATUS:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   305
            break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   306
        case IMN_OPENCANDIDATE:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   307
        case IMN_CHANGECANDIDATE:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   308
            trap = SDL_TRUE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   309
            break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   310
        case IMN_CLOSECANDIDATE:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   311
            trap = SDL_TRUE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   312
            break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   313
        case IMN_PRIVATE:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   314
            break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   315
        default:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   316
            trap = SDL_TRUE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   317
            break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   318
        }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   319
        break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   320
    }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   321
    return trap;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   322
}
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   323
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   324
/* vi: set ts=4 sw=4 expandtab: */