src/video/win32/SDL_win32keyboard.c
author Daniel Wyatt <Daniel.Wyatt@gmail.com>
Sun, 28 Nov 2010 22:30:16 -0500
changeset 4916 3617cec7f0ee
parent 4914 cc7ac6aaac5d
permissions -rw-r--r--
Better horizontal candidate list rendering. Added horzcandspacing constant to add space between horizontal candidates.
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 <imm.h>
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
    30
#include <oleauto.h>
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
    31
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
    32
static void IME_Init(SDL_VideoData *videodata, HWND hwnd);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
    33
static void IME_Enable(SDL_VideoData *videodata, HWND hwnd);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
    34
static void IME_Disable(SDL_VideoData *videodata, HWND hwnd);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
    35
static void IME_Quit(SDL_VideoData *videodata);
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
    36
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    37
#ifndef MAPVK_VK_TO_VSC
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    38
#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
    39
#endif
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    40
#ifndef MAPVK_VSC_TO_VK
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    41
#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
    42
#endif
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    43
#ifndef MAPVK_VK_TO_CHAR
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    44
#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
    45
#endif
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    46
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    47
/* Alphabetic scancodes for PC keyboards */
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    48
BYTE alpha_scancodes[26] = {
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
    49
    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
    50
    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
    51
};
2735
204be4fc2726 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2726
diff changeset
    52
2317
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2311
diff changeset
    53
BYTE keypad_scancodes[10] = {
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2311
diff changeset
    54
    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
    55
};
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
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;
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
    93
    data->ime_threadmgr = 0;
4752
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;
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   100
    data->ime_composition[0] = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   101
    data->ime_readingstring[0] = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   102
    data->ime_cursor = 0;
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   103
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   104
    data->ime_candlist = SDL_FALSE;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   105
    SDL_memset(data->ime_candidates, 0, sizeof(data->ime_candidates));
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   106
    data->ime_candcount = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   107
    data->ime_candref = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   108
    data->ime_candsel = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   109
    data->ime_candpgsize = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   110
    data->ime_candlistindexbase = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   111
    data->ime_candvertical = SDL_TRUE;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   112
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   113
    data->ime_candtex = NULL;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   114
    data->ime_dirty = SDL_FALSE;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   115
    SDL_memset(&data->ime_rect, 0, sizeof(data->ime_rect));
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   116
    SDL_memset(&data->ime_candlistrect, 0, sizeof(data->ime_candlistrect));
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   117
    data->ime_winwidth = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   118
    data->ime_winheight = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   119
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   120
    data->ime_hkl = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   121
    data->ime_himm32 = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   122
    data->GetReadingString = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   123
    data->ShowReadingWindow = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   124
    data->ImmLockIMC = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   125
    data->ImmUnlockIMC = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   126
    data->ImmLockIMCC = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   127
    data->ImmUnlockIMCC = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   128
    data->ime_uiless = SDL_FALSE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   129
    data->ime_threadmgrex = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   130
    data->ime_uielemsinkcookie = TF_INVALID_COOKIE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   131
    data->ime_alpnsinkcookie = TF_INVALID_COOKIE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   132
    data->ime_openmodesinkcookie = TF_INVALID_COOKIE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   133
    data->ime_convmodesinkcookie = TF_INVALID_COOKIE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   134
    data->ime_uielemsink = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   135
    data->ime_ippasink = 0;
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   136
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
   137
    WIN_UpdateKeymap();
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   138
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   139
    SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu");
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   140
    SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Windows");
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   141
    SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Windows");
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   142
}
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   143
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   144
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
   145
WIN_UpdateKeymap()
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   146
{
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   147
    int i;
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   148
    SDL_scancode scancode;
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   149
    SDLKey keymap[SDL_NUM_SCANCODES];
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   150
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   151
    SDL_GetDefaultKeymap(keymap);
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   152
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   153
    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
   154
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   155
        /* Make sure this scancode is a valid character scancode */
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   156
        scancode = win32_scancode_table[i];
4561
e4b2b7207f79 Fixed remapping the Delete key and detecting the keypad Delete key.
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   157
        if (scancode == SDL_SCANCODE_UNKNOWN || keymap[scancode] >= 127) {
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   158
            continue;
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   159
        }
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
   160
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
   161
        /* 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
   162
        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
   163
            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
   164
            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
   165
        } else {
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
   166
            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
   167
        }
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   168
    }
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
   169
    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
   170
}
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
   171
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
   172
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
   173
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
   174
{
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   175
    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
   176
}
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
   177
4747
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   178
void
4753
11b0a6a3eb4d Changed Start/StopTextInput back to not take any parameters.
dewyatt
parents: 4752
diff changeset
   179
WIN_StartTextInput(_THIS)
4747
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   180
{
4753
11b0a6a3eb4d Changed Start/StopTextInput back to not take any parameters.
dewyatt
parents: 4752
diff changeset
   181
    SDL_Window *window = SDL_GetKeyboardFocus();
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   182
    if (window) {
4753
11b0a6a3eb4d Changed Start/StopTextInput back to not take any parameters.
dewyatt
parents: 4752
diff changeset
   183
        HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
11b0a6a3eb4d Changed Start/StopTextInput back to not take any parameters.
dewyatt
parents: 4752
diff changeset
   184
        SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   185
        SDL_GetWindowSize(window, &videodata->ime_winwidth, &videodata->ime_winheight);
4753
11b0a6a3eb4d Changed Start/StopTextInput back to not take any parameters.
dewyatt
parents: 4752
diff changeset
   186
        IME_Init(videodata, hwnd);
11b0a6a3eb4d Changed Start/StopTextInput back to not take any parameters.
dewyatt
parents: 4752
diff changeset
   187
        IME_Enable(videodata, hwnd);
11b0a6a3eb4d Changed Start/StopTextInput back to not take any parameters.
dewyatt
parents: 4752
diff changeset
   188
    }
4747
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   189
}
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   190
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   191
void
4753
11b0a6a3eb4d Changed Start/StopTextInput back to not take any parameters.
dewyatt
parents: 4752
diff changeset
   192
WIN_StopTextInput(_THIS)
4747
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   193
{
4753
11b0a6a3eb4d Changed Start/StopTextInput back to not take any parameters.
dewyatt
parents: 4752
diff changeset
   194
    SDL_Window *window = SDL_GetKeyboardFocus();
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   195
    if (window) {
4753
11b0a6a3eb4d Changed Start/StopTextInput back to not take any parameters.
dewyatt
parents: 4752
diff changeset
   196
        HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
11b0a6a3eb4d Changed Start/StopTextInput back to not take any parameters.
dewyatt
parents: 4752
diff changeset
   197
        SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
11b0a6a3eb4d Changed Start/StopTextInput back to not take any parameters.
dewyatt
parents: 4752
diff changeset
   198
        IME_Init(videodata, hwnd);
11b0a6a3eb4d Changed Start/StopTextInput back to not take any parameters.
dewyatt
parents: 4752
diff changeset
   199
        IME_Disable(videodata, hwnd);
11b0a6a3eb4d Changed Start/StopTextInput back to not take any parameters.
dewyatt
parents: 4752
diff changeset
   200
    }
4747
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   201
}
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   202
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   203
void
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   204
WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   205
{
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   206
    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   207
    videodata->ime_rect = *rect;
4747
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   208
}
5284a3b3217a Added empty text input functions for win32.
dewyatt
parents: 4465
diff changeset
   209
4893
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   210
#ifdef __GNUC__
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   211
#undef DEFINE_GUID
4894
ac19d74e2a47 Fixed compiling with mingw32/64
Sam Lantinga <slouken@libsdl.org>
parents: 4893
diff changeset
   212
#define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) static const GUID n = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
4893
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   213
DEFINE_GUID(IID_ITfInputProcessorProfileActivationSink,        0x71C6E74E,0x0F28,0x11D8,0xA8,0x2A,0x00,0x06,0x5B,0x84,0x43,0x5C);
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   214
DEFINE_GUID(IID_ITfUIElementSink,                              0xEA1EA136,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C);
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   215
DEFINE_GUID(GUID_TFCAT_TIP_KEYBOARD,                           0x34745C63,0xB2F0,0x4784,0x8B,0x67,0x5E,0x12,0xC8,0x70,0x1A,0x31);
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   216
DEFINE_GUID(IID_ITfSource,                                     0x4EA48A35,0x60AE,0x446F,0x8F,0xD6,0xE6,0xA8,0xD8,0x24,0x59,0xF7);
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   217
DEFINE_GUID(IID_ITfUIElementMgr,                               0xEA1EA135,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C);
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   218
DEFINE_GUID(IID_ITfCandidateListUIElement,                     0xEA1EA138,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C);
4893
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   219
DEFINE_GUID(IID_ITfReadingInformationUIElement,                0xEA1EA139,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C);
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   220
DEFINE_GUID(IID_ITfThreadMgr,                                  0xAA80E801,0x2021,0x11D2,0x93,0xE0,0x00,0x60,0xB0,0x67,0xB8,0x6E);
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   221
DEFINE_GUID(CLSID_TF_ThreadMgr,                                0x529A9E6B,0x6587,0x4F23,0xAB,0x9E,0x9C,0x7D,0x68,0x3E,0x3C,0x50);
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   222
DEFINE_GUID(IID_ITfThreadMgrEx,                                0x3E90ADE3,0x7594,0x4CB0,0xBB,0x58,0x69,0x62,0x8F,0x5F,0x45,0x8C);
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   223
#endif
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   224
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   225
#define LANG_CHT MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   226
#define LANG_CHS MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   227
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   228
#define MAKEIMEVERSION(major,minor) ((DWORD) (((BYTE)(major) << 24) | ((BYTE)(minor) << 16) ))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   229
#define IMEID_VER(id) ((id) & 0xffff0000)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   230
#define IMEID_LANG(id) ((id) & 0x0000ffff)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   231
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   232
#define CHT_HKL_DAYI            ((HKL)0xE0060404)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   233
#define CHT_HKL_NEW_PHONETIC    ((HKL)0xE0080404)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   234
#define CHT_HKL_NEW_CHANG_JIE   ((HKL)0xE0090404)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   235
#define CHT_HKL_NEW_QUICK       ((HKL)0xE00A0404)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   236
#define CHT_HKL_HK_CANTONESE    ((HKL)0xE00B0404)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   237
#define CHT_IMEFILENAME1        "TINTLGNT.IME"
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   238
#define CHT_IMEFILENAME2        "CINTLGNT.IME"
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   239
#define CHT_IMEFILENAME3        "MSTCIPHA.IME"
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   240
#define IMEID_CHT_VER42         (LANG_CHT | MAKEIMEVERSION(4, 2))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   241
#define IMEID_CHT_VER43         (LANG_CHT | MAKEIMEVERSION(4, 3))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   242
#define IMEID_CHT_VER44         (LANG_CHT | MAKEIMEVERSION(4, 4))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   243
#define IMEID_CHT_VER50         (LANG_CHT | MAKEIMEVERSION(5, 0))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   244
#define IMEID_CHT_VER51         (LANG_CHT | MAKEIMEVERSION(5, 1))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   245
#define IMEID_CHT_VER52         (LANG_CHT | MAKEIMEVERSION(5, 2))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   246
#define IMEID_CHT_VER60         (LANG_CHT | MAKEIMEVERSION(6, 0))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   247
#define IMEID_CHT_VER_VISTA     (LANG_CHT | MAKEIMEVERSION(7, 0))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   248
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   249
#define CHS_HKL                 ((HKL)0xE00E0804)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   250
#define CHS_IMEFILENAME1        "PINTLGNT.IME"
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   251
#define CHS_IMEFILENAME2        "MSSCIPYA.IME"
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   252
#define IMEID_CHS_VER41         (LANG_CHS | MAKEIMEVERSION(4, 1))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   253
#define IMEID_CHS_VER42         (LANG_CHS | MAKEIMEVERSION(4, 2))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   254
#define IMEID_CHS_VER53         (LANG_CHS | MAKEIMEVERSION(5, 3))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   255
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   256
#define LANG() LOWORD((videodata->ime_hkl))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   257
#define PRIMLANG() ((WORD)PRIMARYLANGID(LANG()))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   258
#define SUBLANG() SUBLANGID(LANG())
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   259
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   260
static void IME_UpdateInputLocale(SDL_VideoData *videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   261
static void IME_ClearComposition(SDL_VideoData *videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   262
static void IME_SetWindow(SDL_VideoData* videodata, HWND hwnd);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   263
static void IME_SetupAPI(SDL_VideoData *videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   264
static DWORD IME_GetId(SDL_VideoData *videodata, UINT uIndex);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   265
static void IME_SendEditingEvent(SDL_VideoData *videodata);
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   266
static void IME_DestroyTextures(SDL_VideoData *videodata);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   267
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   268
#define SDL_IsEqualIID(riid1, riid2) SDL_IsEqualGUID(riid1, riid2)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   269
#define SDL_IsEqualGUID(rguid1, rguid2) (!SDL_memcmp(rguid1, rguid2, sizeof(GUID)))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   270
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   271
static SDL_bool UILess_SetupSinks(SDL_VideoData *videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   272
static void UILess_ReleaseSinks(SDL_VideoData *videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   273
static void UILess_EnableUIUpdates(SDL_VideoData *videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   274
static void UILess_DisableUIUpdates(SDL_VideoData *videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   275
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   276
static void
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   277
IME_Init(SDL_VideoData *videodata, HWND hwnd)
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   278
{
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   279
    if (videodata->ime_initialized)
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   280
        return;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   281
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   282
    videodata->ime_hwnd_main = hwnd;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   283
    if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) {
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   284
        videodata->ime_com_initialized = SDL_TRUE;
4893
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   285
        CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgr, (LPVOID *)&videodata->ime_threadmgr);
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   286
    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   287
    videodata->ime_initialized = SDL_TRUE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   288
    videodata->ime_himm32 = LoadLibraryA("imm32.dll");
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   289
    if (!videodata->ime_himm32) {
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   290
        videodata->ime_available = SDL_FALSE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   291
        return;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   292
    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   293
    videodata->ImmLockIMC = (LPINPUTCONTEXT2 (WINAPI *)(HIMC))GetProcAddress(videodata->ime_himm32, "ImmLockIMC");
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   294
    videodata->ImmUnlockIMC = (BOOL (WINAPI *)(HIMC))GetProcAddress(videodata->ime_himm32, "ImmUnlockIMC");
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   295
    videodata->ImmLockIMCC = (LPVOID (WINAPI *)(HIMCC))GetProcAddress(videodata->ime_himm32, "ImmLockIMCC");
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   296
    videodata->ImmUnlockIMCC = (BOOL (WINAPI *)(HIMCC))GetProcAddress(videodata->ime_himm32, "ImmUnlockIMCC");
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   297
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   298
    IME_SetWindow(videodata, hwnd);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   299
    videodata->ime_himc = ImmGetContext(hwnd);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   300
    ImmReleaseContext(hwnd, videodata->ime_himc);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   301
    if (!videodata->ime_himc) {
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   302
        videodata->ime_available = SDL_FALSE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   303
        IME_Disable(videodata, hwnd);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   304
        return;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   305
    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   306
    videodata->ime_available = SDL_TRUE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   307
    IME_UpdateInputLocale(videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   308
    IME_SetupAPI(videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   309
    videodata->ime_uiless = UILess_SetupSinks(videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   310
    IME_UpdateInputLocale(videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   311
    IME_Disable(videodata, hwnd);
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   312
}
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   313
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   314
static void
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   315
IME_Enable(SDL_VideoData *videodata, HWND hwnd)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   316
{
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   317
    if (!videodata->ime_initialized || !videodata->ime_hwnd_current)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   318
        return;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   319
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   320
    if (!videodata->ime_available) {
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   321
        IME_Disable(videodata, hwnd);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   322
        return;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   323
    }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   324
    if (videodata->ime_hwnd_current == videodata->ime_hwnd_main)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   325
        ImmAssociateContext(videodata->ime_hwnd_current, videodata->ime_himc);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   326
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   327
    videodata->ime_enabled = SDL_TRUE;
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   328
    IME_UpdateInputLocale(videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   329
    UILess_EnableUIUpdates(videodata);
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   330
}
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   331
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   332
static void
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   333
IME_Disable(SDL_VideoData *videodata, HWND hwnd)
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   334
{
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   335
    if (!videodata->ime_initialized || !videodata->ime_hwnd_current)
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   336
        return;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   337
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   338
    IME_ClearComposition(videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   339
    if (videodata->ime_hwnd_current == videodata->ime_hwnd_main)
4893
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   340
        ImmAssociateContext(videodata->ime_hwnd_current, (HIMC)0);
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   341
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   342
    videodata->ime_enabled = SDL_FALSE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   343
    UILess_DisableUIUpdates(videodata);
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   344
}
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   345
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   346
static void
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   347
IME_Quit(SDL_VideoData *videodata)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   348
{
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   349
    if (!videodata->ime_initialized)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   350
        return;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   351
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   352
    UILess_ReleaseSinks(videodata);
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   353
    if (videodata->ime_hwnd_main)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   354
        ImmAssociateContext(videodata->ime_hwnd_main, videodata->ime_himc);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   355
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   356
    videodata->ime_hwnd_main = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   357
    videodata->ime_himc = 0;
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   358
    if (videodata->ime_himm32) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   359
        FreeLibrary(videodata->ime_himm32);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   360
        videodata->ime_himm32 = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   361
    }
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   362
    if (videodata->ime_threadmgr) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   363
        videodata->ime_threadmgr->lpVtbl->Release(videodata->ime_threadmgr);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   364
        videodata->ime_threadmgr = 0;
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   365
    }
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   366
    if (videodata->ime_com_initialized) {
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   367
        CoUninitialize();
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   368
        videodata->ime_com_initialized = SDL_FALSE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   369
    }
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   370
    IME_DestroyTextures(videodata);
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   371
    videodata->ime_initialized = SDL_FALSE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   372
}
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   373
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   374
static void
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   375
IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   376
{
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   377
    DWORD id = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   378
    HIMC himc = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   379
    WCHAR buffer[16];
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   380
    WCHAR *s = buffer;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   381
    DWORD len = 0;
4893
b2e434e0553b Fixed all MinGW problems (except libraries not added to build yet).
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4763
diff changeset
   382
    INT err = 0;
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   383
    BOOL vertical = FALSE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   384
    UINT maxuilen = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   385
    static OSVERSIONINFOA osversion = {0};
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   386
    if (videodata->ime_uiless)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   387
        return;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   388
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   389
    videodata->ime_readingstring[0] = 0;
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   390
    if (!osversion.dwOSVersionInfoSize) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   391
        osversion.dwOSVersionInfoSize = sizeof(osversion);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   392
        GetVersionExA(&osversion);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   393
    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   394
    id = IME_GetId(videodata, 0);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   395
    if (!id)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   396
        return;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   397
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   398
    himc = ImmGetContext(hwnd);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   399
    if (!himc)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   400
        return;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   401
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   402
    if (videodata->GetReadingString) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   403
        len = videodata->GetReadingString(himc, 0, 0, &err, &vertical, &maxuilen);
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   404
        if (len) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   405
            if (len > SDL_arraysize(buffer))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   406
                len = SDL_arraysize(buffer);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   407
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   408
            len = videodata->GetReadingString(himc, len, s, &err, &vertical, &maxuilen);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   409
        }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   410
        SDL_wcslcpy(videodata->ime_readingstring, s, len);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   411
    }
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   412
    else {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   413
        LPINPUTCONTEXT2 lpimc = videodata->ImmLockIMC(himc);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   414
        LPBYTE p = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   415
        s = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   416
        switch (id)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   417
        {
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   418
        case IMEID_CHT_VER42:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   419
        case IMEID_CHT_VER43:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   420
        case IMEID_CHT_VER44:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   421
            p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + 24);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   422
            if (!p)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   423
                break;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   424
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   425
            len = *(DWORD *)(p + 7*4 + 32*4);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   426
            s = (WCHAR *)(p + 56);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   427
            break;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   428
        case IMEID_CHT_VER51:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   429
        case IMEID_CHT_VER52:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   430
        case IMEID_CHS_VER53:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   431
            p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + 4);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   432
            if (!p)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   433
                break;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   434
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   435
            p = *(LPBYTE *)((LPBYTE)p + 1*4 + 5*4);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   436
            if (!p)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   437
                break;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   438
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   439
            len = *(DWORD *)(p + 1*4 + (16*2+2*4) + 5*4 + 16*2);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   440
            s = (WCHAR *)(p + 1*4 + (16*2+2*4) + 5*4);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   441
            break;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   442
        case IMEID_CHS_VER41:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   443
            {
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   444
                int offset = (IME_GetId(videodata, 1) >= 0x00000002) ? 8 : 7;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   445
                p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + offset * 4);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   446
                if (!p)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   447
                    break;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   448
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   449
                len = *(DWORD *)(p + 7*4 + 16*2*4);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   450
                s = (WCHAR *)(p + 6*4 + 16*2*1);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   451
            }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   452
            break;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   453
        case IMEID_CHS_VER42:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   454
            if (osversion.dwPlatformId != VER_PLATFORM_WIN32_NT)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   455
                break;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   456
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   457
            p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + 1*4 + 1*4 + 6*4);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   458
            if (!p)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   459
                break;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   460
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   461
            len = *(DWORD *)(p + 1*4 + (16*2+2*4) + 5*4 + 16*2);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   462
            s = (WCHAR *)(p + 1*4 + (16*2+2*4) + 5*4);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   463
            break;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   464
        }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   465
        if (s)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   466
            SDL_wcslcpy(videodata->ime_readingstring, s, len + 1);
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   467
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   468
        videodata->ImmUnlockIMCC(lpimc->hPrivate);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   469
        videodata->ImmUnlockIMC(himc);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   470
    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   471
    ImmReleaseContext(hwnd, himc);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   472
    IME_SendEditingEvent(videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   473
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   474
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   475
static void
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   476
IME_InputLangChanged(SDL_VideoData *videodata)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   477
{
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   478
    UINT lang = PRIMLANG();
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   479
    IME_UpdateInputLocale(videodata);
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   480
    if (!videodata->ime_uiless)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   481
        videodata->ime_candlistindexbase = (videodata->ime_hkl == CHT_HKL_DAYI) ? 0 : 1;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   482
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   483
    IME_SetupAPI(videodata);
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   484
    if (lang != PRIMLANG()) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   485
        IME_ClearComposition(videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   486
    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   487
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   488
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   489
static DWORD
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   490
IME_GetId(SDL_VideoData *videodata, UINT uIndex)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   491
{
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   492
    static HKL hklprev = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   493
    static DWORD dwRet[2] = {0};
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   494
    DWORD dwVerSize = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   495
    DWORD dwVerHandle = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   496
    LPVOID lpVerBuffer = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   497
    LPVOID lpVerData = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   498
    UINT cbVerData = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   499
    char szTemp[256];
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   500
    HKL hkl = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   501
    DWORD dwLang = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   502
    if (uIndex >= sizeof(dwRet) / sizeof(dwRet[0]))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   503
        return 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   504
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   505
    hkl = videodata->ime_hkl;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   506
    if (hklprev == hkl)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   507
        return dwRet[uIndex];
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   508
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   509
    hklprev = hkl;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   510
    dwLang = ((DWORD)hkl & 0xffff);
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   511
    if (videodata->ime_uiless && LANG() == LANG_CHT) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   512
        dwRet[0] = IMEID_CHT_VER_VISTA;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   513
        dwRet[1] = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   514
        return dwRet[0];
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   515
    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   516
    if (hkl != CHT_HKL_NEW_PHONETIC
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   517
        && hkl != CHT_HKL_NEW_CHANG_JIE
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   518
        && hkl != CHT_HKL_NEW_QUICK
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   519
        && hkl != CHT_HKL_HK_CANTONESE
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   520
        && hkl != CHS_HKL) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   521
        dwRet[0] = dwRet[1] = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   522
        return dwRet[uIndex];
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   523
    }
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   524
    if (ImmGetIMEFileNameA(hkl, szTemp, sizeof(szTemp) - 1) <= 0) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   525
        dwRet[0] = dwRet[1] = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   526
        return dwRet[uIndex];
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   527
    }
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   528
    if (!videodata->GetReadingString) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   529
        #define LCID_INVARIANT MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   530
        if (CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME1, -1) != 2
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   531
            && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME2, -1) != 2
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   532
            && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME3, -1) != 2
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   533
            && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME1, -1) != 2
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   534
            && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME2, -1) != 2) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   535
            dwRet[0] = dwRet[1] = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   536
            return dwRet[uIndex];
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   537
        }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   538
        #undef LCID_INVARIANT
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   539
        dwVerSize = GetFileVersionInfoSizeA(szTemp, &dwVerHandle);
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   540
        if (dwVerSize) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   541
            lpVerBuffer = SDL_malloc(dwVerSize);
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   542
            if (lpVerBuffer) {
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   543
                if (GetFileVersionInfoA(szTemp, dwVerHandle, dwVerSize, lpVerBuffer)) {
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   544
                    if (VerQueryValueA(lpVerBuffer, "\\", &lpVerData, &cbVerData)) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   545
                        #define pVerFixedInfo   ((VS_FIXEDFILEINFO FAR*)lpVerData)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   546
                        DWORD dwVer = pVerFixedInfo->dwFileVersionMS;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   547
                        dwVer = (dwVer & 0x00ff0000) << 8 | (dwVer & 0x000000ff) << 16;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   548
                        if (videodata->GetReadingString ||
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   549
                            dwLang == LANG_CHT && (
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   550
                            dwVer == MAKEIMEVERSION(4, 2) ||
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   551
                            dwVer == MAKEIMEVERSION(4, 3) ||
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   552
                            dwVer == MAKEIMEVERSION(4, 4) ||
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   553
                            dwVer == MAKEIMEVERSION(5, 0) ||
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   554
                            dwVer == MAKEIMEVERSION(5, 1) ||
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   555
                            dwVer == MAKEIMEVERSION(5, 2) ||
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   556
                            dwVer == MAKEIMEVERSION(6, 0))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   557
                            ||
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   558
                            dwLang == LANG_CHS && (
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   559
                            dwVer == MAKEIMEVERSION(4, 1) ||
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   560
                            dwVer == MAKEIMEVERSION(4, 2) ||
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   561
                            dwVer == MAKEIMEVERSION(5, 3))) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   562
                            dwRet[0] = dwVer | dwLang;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   563
                            dwRet[1] = pVerFixedInfo->dwFileVersionLS;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   564
                            SDL_free(lpVerBuffer);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   565
                            return dwRet[0];
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   566
                        }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   567
                        #undef pVerFixedInfo
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   568
                    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   569
                }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   570
            }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   571
            SDL_free(lpVerBuffer);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   572
        }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   573
    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   574
    dwRet[0] = dwRet[1] = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   575
    return dwRet[uIndex];
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   576
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   577
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   578
static void
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   579
IME_SetupAPI(SDL_VideoData *videodata)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   580
{
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   581
    char ime_file[MAX_PATH + 1];
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   582
    HMODULE hime = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   583
    HKL hkl = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   584
    videodata->GetReadingString = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   585
    videodata->ShowReadingWindow = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   586
    if (videodata->ime_uiless)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   587
        return;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   588
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   589
    hkl = videodata->ime_hkl;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   590
    if (ImmGetIMEFileNameA(hkl, ime_file, sizeof(ime_file) - 1) <= 0)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   591
        return;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   592
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   593
    hime = LoadLibraryA(ime_file);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   594
    if (!hime)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   595
        return;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   596
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   597
    videodata->GetReadingString = (UINT (WINAPI *)(HIMC, UINT, LPWSTR, PINT, BOOL*, PUINT))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   598
        GetProcAddress(hime, "GetReadingString");
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   599
    videodata->ShowReadingWindow = (BOOL (WINAPI *)(HIMC, BOOL))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   600
        GetProcAddress(hime, "ShowReadingWindow");
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   601
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   602
    if (videodata->ShowReadingWindow) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   603
        HIMC himc = ImmGetContext(videodata->ime_hwnd_current);
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   604
        if (himc) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   605
            videodata->ShowReadingWindow(himc, FALSE);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   606
            ImmReleaseContext(videodata->ime_hwnd_current, himc);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   607
        }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   608
    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   609
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   610
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   611
static void
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   612
IME_SetWindow(SDL_VideoData* videodata, HWND hwnd)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   613
{
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   614
    videodata->ime_hwnd_current = hwnd;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   615
    if (videodata->ime_threadmgr) {
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   616
        struct ITfDocumentMgr *document_mgr = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   617
        if (SUCCEEDED(videodata->ime_threadmgr->lpVtbl->AssociateFocus(videodata->ime_threadmgr, hwnd, NULL, &document_mgr))) {
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   618
            if (document_mgr)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   619
                document_mgr->lpVtbl->Release(document_mgr);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   620
        }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   621
    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   622
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   623
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   624
static void
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   625
IME_UpdateInputLocale(SDL_VideoData *videodata)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   626
{
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   627
    static HKL hklprev = 0;
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   628
    videodata->ime_hkl = GetKeyboardLayout(0);
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   629
    if (hklprev == videodata->ime_hkl)
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   630
        return;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   631
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   632
    hklprev = videodata->ime_hkl;
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   633
    switch (PRIMLANG()) {
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   634
    case LANG_CHINESE:
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   635
        videodata->ime_candvertical = SDL_TRUE;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   636
        if (SUBLANG() == SUBLANG_CHINESE_SIMPLIFIED)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   637
            videodata->ime_candvertical = SDL_FALSE;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   638
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   639
        break;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   640
    case LANG_JAPANESE:
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   641
        videodata->ime_candvertical = SDL_TRUE;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   642
        break;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   643
    case LANG_KOREAN:
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   644
        videodata->ime_candvertical = SDL_FALSE;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   645
        break;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   646
    }
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   647
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   648
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   649
static void
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   650
IME_ClearComposition(SDL_VideoData *videodata)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   651
{
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   652
    HIMC himc = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   653
    if (!videodata->ime_initialized)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   654
        return;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   655
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   656
    himc = ImmGetContext(videodata->ime_hwnd_current);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   657
    if (!himc)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   658
        return;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   659
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   660
    ImmNotifyIME(himc, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   661
    if (videodata->ime_uiless)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   662
        ImmSetCompositionString(himc, SCS_SETSTR, TEXT(""), sizeof(TCHAR), TEXT(""), sizeof(TCHAR));
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   663
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   664
    ImmNotifyIME(himc, NI_CLOSECANDIDATE, 0, 0);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   665
    ImmReleaseContext(videodata->ime_hwnd_current, himc);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   666
    SDL_SendEditingText("", 0, 0);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   667
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   668
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   669
static void
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   670
IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   671
{
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   672
    LONG length = ImmGetCompositionStringW(himc, string, videodata->ime_composition, sizeof(videodata->ime_composition));
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   673
    if (length < 0)
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   674
        length = 0;
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   675
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   676
    length /= sizeof(videodata->ime_composition[0]);
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   677
    videodata->ime_cursor = LOWORD(ImmGetCompositionStringW(himc, GCS_CURSORPOS, 0, 0));
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   678
    if (videodata->ime_composition[videodata->ime_cursor] == 0x3000) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   679
        int i;
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   680
        for (i = videodata->ime_cursor + 1; i < length; ++i)
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   681
            videodata->ime_composition[i - 1] = videodata->ime_composition[i];
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   682
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   683
        --length;
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   684
    }
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   685
    videodata->ime_composition[length] = 0;
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   686
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   687
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   688
static void
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   689
IME_SendInputEvent(SDL_VideoData *videodata)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   690
{
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   691
    char *s = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   692
    s = WIN_StringToUTF8(videodata->ime_composition);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   693
    SDL_SendKeyboardText(s);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   694
    SDL_free(s);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   695
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   696
    videodata->ime_composition[0] = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   697
    videodata->ime_readingstring[0] = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   698
    videodata->ime_cursor = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   699
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   700
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   701
static void
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   702
IME_SendEditingEvent(SDL_VideoData *videodata)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   703
{
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   704
    char *s = 0;
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   705
    WCHAR buffer[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   706
    buffer[0] = 0;
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   707
    if (videodata->ime_readingstring[0]) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   708
        size_t len = SDL_min(SDL_wcslen(videodata->ime_composition), (size_t)videodata->ime_cursor);
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   709
        SDL_wcslcpy(buffer, videodata->ime_composition, len + 1);
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   710
        SDL_wcslcat(buffer, videodata->ime_readingstring, sizeof(buffer));
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   711
        SDL_wcslcat(buffer, &videodata->ime_composition[len], sizeof(buffer) - len);
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   712
    }
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   713
    else {
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   714
        SDL_wcslcpy(buffer, videodata->ime_composition, sizeof(videodata->ime_composition));
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   715
    }
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   716
    s = WIN_StringToUTF8(buffer);
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   717
    SDL_SendEditingText(s, videodata->ime_cursor + SDL_wcslen(videodata->ime_readingstring), 0);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   718
    SDL_free(s);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   719
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   720
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   721
static void
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   722
IME_AddCandidate(SDL_VideoData *videodata, UINT i, LPCWSTR candidate)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   723
{
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   724
    LPWSTR dst = videodata->ime_candidates[i];
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   725
    *dst++ = (WCHAR)(TEXT('0') + ((i + videodata->ime_candlistindexbase) % 10));
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   726
    if (videodata->ime_candvertical)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   727
        *dst++ = TEXT(' ');
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   728
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   729
    while (*candidate && (SDL_arraysize(videodata->ime_candidates[i]) > (dst - videodata->ime_candidates[i])))
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   730
        *dst++ = *candidate++;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   731
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   732
    *dst = (WCHAR)'\0';
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   733
}
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   734
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   735
static void
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   736
IME_GetCandidateList(HIMC himc, SDL_VideoData *videodata)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   737
{
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   738
    LPCANDIDATELIST cand_list = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   739
    DWORD size = ImmGetCandidateListW(himc, 0, 0, 0);
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   740
    if (size) {
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   741
        cand_list = (LPCANDIDATELIST)SDL_malloc(size);
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   742
        if (cand_list) {
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   743
            size = ImmGetCandidateListW(himc, 0, cand_list, size);
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   744
            if (size) {
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   745
                int i = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   746
                int j = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   747
                int page_start = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   748
                videodata->ime_candsel = cand_list->dwSelection;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   749
                videodata->ime_candcount = cand_list->dwCount;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   750
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   751
                if (LANG() == LANG_CHS && IME_GetId(videodata, 0)) {
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   752
                    const UINT maxcandchar = 18;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   753
                    UINT i = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   754
                    UINT cchars = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   755
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   756
                    for (; i < videodata->ime_candcount; ++i) {
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   757
                        UINT len = SDL_wcslen((LPWSTR)((DWORD)cand_list + cand_list->dwOffset[i])) + 1;
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   758
                        if (len + cchars > maxcandchar) {
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   759
                            if (i > cand_list->dwSelection)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   760
                                break;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   761
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   762
                            page_start = i;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   763
                            cchars = len;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   764
                        }
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   765
                        else {
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   766
                            cchars += len;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   767
                        }
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   768
                    }
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   769
                    videodata->ime_candpgsize = i - page_start;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   770
                }
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   771
                else {
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   772
                    videodata->ime_candpgsize = SDL_min(cand_list->dwPageSize, MAX_CANDLIST);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   773
                    page_start = (cand_list->dwSelection / videodata->ime_candpgsize) * videodata->ime_candpgsize;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   774
                }
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   775
                SDL_memset(&videodata->ime_candidates, 0, sizeof(videodata->ime_candidates));
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   776
                for (i = page_start, j = 0; (DWORD)i < cand_list->dwCount && j < (int)videodata->ime_candpgsize; i++, j++) {
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   777
                    LPCWSTR candidate = (LPCWSTR)((DWORD)cand_list + cand_list->dwOffset[i]);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   778
                    IME_AddCandidate(videodata, j, candidate);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   779
                }
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   780
                if (PRIMLANG() == LANG_KOREAN || (PRIMLANG() == LANG_CHT && !IME_GetId(videodata, 0)))
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   781
                    videodata->ime_candsel = -1;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   782
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   783
            }
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   784
            SDL_free(cand_list);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   785
        }
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   786
    }
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   787
}
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   788
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   789
static void
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   790
IME_ShowCandidateList(SDL_VideoData *videodata)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   791
{
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   792
    videodata->ime_dirty = SDL_TRUE;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   793
    videodata->ime_candlist = SDL_TRUE;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   794
    IME_DestroyTextures(videodata);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   795
    IME_SendEditingEvent(videodata);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   796
}
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   797
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   798
static void
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   799
IME_HideCandidateList(SDL_VideoData *videodata)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   800
{
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   801
    videodata->ime_dirty = SDL_FALSE;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   802
    videodata->ime_candlist = SDL_FALSE;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   803
    IME_DestroyTextures(videodata);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   804
    IME_SendEditingEvent(videodata);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   805
}
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   806
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   807
SDL_bool
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   808
IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoData *videodata)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   809
{
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   810
    SDL_bool trap = SDL_FALSE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   811
    HIMC himc = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   812
    if (!videodata->ime_initialized || !videodata->ime_available || !videodata->ime_enabled)
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   813
        return SDL_FALSE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   814
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   815
    switch (msg) {
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   816
    case WM_INPUTLANGCHANGE:
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   817
        IME_InputLangChanged(videodata);
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   818
        break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   819
    case WM_IME_SETCONTEXT:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   820
        *lParam = 0;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   821
        break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   822
    case WM_IME_STARTCOMPOSITION:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   823
        trap = SDL_TRUE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   824
        break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   825
    case WM_IME_COMPOSITION:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   826
        trap = SDL_TRUE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   827
        himc = ImmGetContext(hwnd);
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   828
        if (*lParam & GCS_RESULTSTR) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   829
            IME_GetCompositionString(videodata, himc, GCS_RESULTSTR);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   830
            IME_SendInputEvent(videodata);
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   831
        }
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   832
        if (*lParam & GCS_COMPSTR) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   833
            if (!videodata->ime_uiless)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   834
                videodata->ime_readingstring[0] = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   835
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   836
            IME_GetCompositionString(videodata, himc, GCS_COMPSTR);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   837
            IME_SendEditingEvent(videodata);
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   838
        }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   839
        ImmReleaseContext(hwnd, himc);
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   840
        break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   841
    case WM_IME_ENDCOMPOSITION:
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   842
        videodata->ime_composition[0] = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   843
        videodata->ime_readingstring[0] = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   844
        videodata->ime_cursor = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   845
        SDL_SendEditingText("", 0, 0);
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   846
        break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   847
    case WM_IME_NOTIFY:
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   848
        switch (wParam) {
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   849
        case IMN_SETCONVERSIONMODE:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   850
        case IMN_SETOPENSTATUS:
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   851
            IME_UpdateInputLocale(videodata);
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   852
            break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   853
        case IMN_OPENCANDIDATE:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   854
        case IMN_CHANGECANDIDATE:
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   855
            if (videodata->ime_uiless)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   856
                break;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   857
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   858
            trap = SDL_TRUE;
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   859
            IME_ShowCandidateList(videodata);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   860
            himc = ImmGetContext(hwnd);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   861
            if (!himc)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   862
                break;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   863
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   864
            IME_GetCandidateList(himc, videodata);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   865
            ImmReleaseContext(hwnd, himc);
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   866
            break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   867
        case IMN_CLOSECANDIDATE:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   868
            trap = SDL_TRUE;
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   869
            IME_HideCandidateList(videodata);
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   870
            break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   871
        case IMN_PRIVATE:
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   872
            {
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   873
                DWORD dwId = IME_GetId(videodata, 0);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   874
                IME_GetReadingString(videodata, hwnd);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   875
                switch (dwId)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   876
                {
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   877
                case IMEID_CHT_VER42:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   878
                case IMEID_CHT_VER43:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   879
                case IMEID_CHT_VER44:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   880
                case IMEID_CHS_VER41:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   881
                case IMEID_CHS_VER42:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   882
                    if (*lParam == 1 || *lParam == 2)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   883
                        trap = SDL_TRUE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   884
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   885
                    break;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   886
                case IMEID_CHT_VER50:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   887
                case IMEID_CHT_VER51:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   888
                case IMEID_CHT_VER52:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   889
                case IMEID_CHT_VER60:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   890
                case IMEID_CHS_VER53:
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   891
                    if (*lParam == 16
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   892
                        || *lParam == 17
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   893
                        || *lParam == 26
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   894
                        || *lParam == 27
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   895
                        || *lParam == 28)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   896
                        trap = SDL_TRUE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   897
                    break;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   898
                }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   899
            }
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   900
            break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   901
        default:
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   902
            trap = SDL_TRUE;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   903
            break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   904
        }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   905
        break;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   906
    }
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   907
    return trap;
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   908
}
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4751
diff changeset
   909
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   910
static void
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   911
IME_CloseCandidateList(SDL_VideoData *videodata)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   912
{
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   913
    IME_HideCandidateList(videodata);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   914
    videodata->ime_candcount = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   915
    SDL_memset(videodata->ime_candidates, 0, sizeof(videodata->ime_candidates));
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   916
}
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   917
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   918
static void
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   919
UILess_GetCandidateList(SDL_VideoData *videodata, ITfCandidateListUIElement *pcandlist)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   920
{
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   921
    UINT selection = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   922
    UINT count = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   923
    UINT page = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   924
    UINT pgcount = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   925
    DWORD pgstart = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   926
    DWORD pgsize = 0;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   927
    UINT i, j;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   928
    pcandlist->lpVtbl->GetSelection(pcandlist, &selection);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   929
    pcandlist->lpVtbl->GetCount(pcandlist, &count);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   930
    pcandlist->lpVtbl->GetCurrentPage(pcandlist, &page);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   931
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   932
    videodata->ime_candsel = selection;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   933
    videodata->ime_candcount = count;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   934
    IME_ShowCandidateList(videodata);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   935
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   936
    pcandlist->lpVtbl->GetPageIndex(pcandlist, 0, 0, &pgcount);
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   937
    if (pgcount > 0) {
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   938
        UINT *idxlist = SDL_malloc(sizeof(UINT) * pgcount);
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   939
        if (idxlist) {
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   940
            pcandlist->lpVtbl->GetPageIndex(pcandlist, idxlist, pgcount, &pgcount);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   941
            pgstart = idxlist[page];
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   942
            if (page < pgcount - 1)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   943
                pgsize = SDL_min(count, idxlist[page + 1]) - pgstart;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   944
            else
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   945
                pgsize = count - pgstart;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   946
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   947
            SDL_free(idxlist);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   948
        }
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   949
    }
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   950
    videodata->ime_candpgsize = SDL_min(pgsize, MAX_CANDLIST);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   951
    videodata->ime_candsel = videodata->ime_candsel - pgstart;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   952
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   953
    SDL_memset(videodata->ime_candidates, 0, sizeof(videodata->ime_candidates));
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   954
    for (i = pgstart, j = 0; (DWORD)i < count && j < videodata->ime_candpgsize; i++, j++) {
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   955
        BSTR bstr;
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   956
        if (SUCCEEDED(pcandlist->lpVtbl->GetString(pcandlist, i, &bstr))) {
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   957
            if (bstr) {
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   958
                IME_AddCandidate(videodata, j, bstr);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   959
                SysFreeString(bstr);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   960
            }
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   961
        }
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   962
    }
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   963
    if (PRIMLANG() == LANG_KOREAN)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   964
        videodata->ime_candsel = -1;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   965
}
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
   966
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   967
STDMETHODIMP_(ULONG) TSFSink_AddRef(TSFSink *sink)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   968
{
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   969
    return ++sink->refcount;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   970
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   971
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   972
STDMETHODIMP_(ULONG)TSFSink_Release(TSFSink *sink)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   973
{
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   974
    --sink->refcount;
4914
cc7ac6aaac5d Code style updates.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4913
diff changeset
   975
    if (sink->refcount == 0) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   976
        SDL_free(sink);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   977
        return 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   978
    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   979
    return sink->refcount;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   980
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   981
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   982
STDMETHODIMP UIElementSink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   983
{
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   984
    if (!ppv)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   985
        return E_INVALIDARG;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   986
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   987
    *ppv = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   988
    if (SDL_IsEqualIID(riid, &IID_IUnknown))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   989
        *ppv = (IUnknown *)sink;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   990
    else if (SDL_IsEqualIID(riid, &IID_ITfUIElementSink))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   991
        *ppv = (ITfUIElementSink *)sink;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   992
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
   993
    if (*ppv) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   994
        TSFSink_AddRef(sink);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   995
        return S_OK;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   996
    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   997
    return E_NOINTERFACE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   998
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
   999
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1000
ITfUIElement *UILess_GetUIElement(SDL_VideoData *videodata, DWORD dwUIElementId)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1001
{
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1002
    ITfUIElementMgr *puiem = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1003
    ITfUIElement *pelem = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1004
    ITfThreadMgrEx *threadmgrex = videodata->ime_threadmgrex;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1005
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
  1006
    if (SUCCEEDED(threadmgrex->lpVtbl->QueryInterface(threadmgrex, &IID_ITfUIElementMgr, (LPVOID *)&puiem))) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1007
        puiem->lpVtbl->GetUIElement(puiem, dwUIElementId, &pelem);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1008
        puiem->lpVtbl->Release(puiem);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1009
    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1010
    return pelem;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1011
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1012
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1013
STDMETHODIMP UIElementSink_BeginUIElement(TSFSink *sink, DWORD dwUIElementId, BOOL *pbShow)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1014
{
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
  1015
    ITfUIElement *element = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId);
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1016
    ITfReadingInformationUIElement *preading = 0;
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1017
    ITfCandidateListUIElement *pcandlist = 0;
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1018
    SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
  1019
    if (!element)
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1020
        return E_INVALIDARG;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1021
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1022
    *pbShow = FALSE;
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
  1023
    if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfReadingInformationUIElement, (LPVOID *)&preading))) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1024
        BSTR bstr;
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
  1025
        if (SUCCEEDED(preading->lpVtbl->GetString(preading, &bstr)) && bstr) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1026
            WCHAR *s = (WCHAR *)bstr;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1027
            SysFreeString(bstr);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1028
        }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1029
        preading->lpVtbl->Release(preading);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1030
    }
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1031
    else if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfCandidateListUIElement, (LPVOID *)&pcandlist)))	{
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1032
        videodata->ime_candref++;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1033
        UILess_GetCandidateList(videodata, pcandlist);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1034
        pcandlist->lpVtbl->Release(pcandlist);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1035
    }
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1036
    return S_OK;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1037
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1038
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1039
STDMETHODIMP UIElementSink_UpdateUIElement(TSFSink *sink, DWORD dwUIElementId)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1040
{
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
  1041
    ITfUIElement *element = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId);
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1042
    ITfReadingInformationUIElement *preading = 0;
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1043
    ITfCandidateListUIElement *pcandlist = 0;
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1044
    SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
  1045
    if (!element)
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1046
        return E_INVALIDARG;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1047
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
  1048
    if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfReadingInformationUIElement, (LPVOID *)&preading))) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1049
        BSTR bstr;
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
  1050
        if (SUCCEEDED(preading->lpVtbl->GetString(preading, &bstr)) && bstr) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1051
            WCHAR *s = (WCHAR *)bstr;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1052
            SDL_wcslcpy(videodata->ime_readingstring, s, sizeof(videodata->ime_readingstring));
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1053
            IME_SendEditingEvent(videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1054
            SysFreeString(bstr);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1055
        }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1056
        preading->lpVtbl->Release(preading);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1057
    }
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1058
    else if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfCandidateListUIElement, (LPVOID *)&pcandlist)))	{
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1059
        UILess_GetCandidateList(videodata, pcandlist);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1060
        pcandlist->lpVtbl->Release(pcandlist);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1061
    }
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1062
    return S_OK;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1063
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1064
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1065
STDMETHODIMP UIElementSink_EndUIElement(TSFSink *sink, DWORD dwUIElementId)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1066
{
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
  1067
    ITfUIElement *element = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId);
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1068
    ITfReadingInformationUIElement *preading = 0;
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1069
    ITfCandidateListUIElement *pcandlist = 0;
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1070
    SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
  1071
    if (!element)
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1072
        return E_INVALIDARG;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1073
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
  1074
    if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfReadingInformationUIElement, (LPVOID *)&preading))) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1075
        videodata->ime_readingstring[0] = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1076
        IME_SendEditingEvent(videodata);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1077
        preading->lpVtbl->Release(preading);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1078
    }
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1079
    if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfCandidateListUIElement, (LPVOID *)&pcandlist))) {
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1080
        videodata->ime_candref--;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1081
        if (videodata->ime_candref == 0)
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1082
            IME_CloseCandidateList(videodata);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1083
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1084
        pcandlist->lpVtbl->Release(pcandlist);
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1085
    }
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1086
    return S_OK;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1087
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1088
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1089
STDMETHODIMP IPPASink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1090
{
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1091
    if (!ppv)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1092
        return E_INVALIDARG;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1093
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1094
    *ppv = 0;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1095
    if (SDL_IsEqualIID(riid, &IID_IUnknown))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1096
        *ppv = (IUnknown *)sink;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1097
    else if (SDL_IsEqualIID(riid, &IID_ITfInputProcessorProfileActivationSink))
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1098
        *ppv = (ITfInputProcessorProfileActivationSink *)sink;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1099
4760
c40027ee6d47 Updated to fit SDL style a little more.
dewyatt
parents: 4759
diff changeset
  1100
    if (*ppv) {
4759
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1101
        TSFSink_AddRef(sink);
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1102
        return S_OK;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1103
    }
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1104
    return E_NOINTERFACE;
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1105
}
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1106
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1107
STDMETHODIMP IPPASink_OnActivated(TSFSink *sink, DWORD dwProfileType, LANGID langid, REFCLSID clsid, REFGUID catid, REFGUID guidProfile, HKL hkl, DWORD dwFlags)
863ba7d1f029 Large commit with initial reading string support, TSF UILess code, etc.
dewyatt
parents: 4753
diff changeset
  1108
{
4913
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1109
    static GUID TF_PROFILE_DAYI = {0x037B2C25, 0x480C, 0x4D7F, 0xB0, 0x27, 0xD6, 0xCA, 0x6B, 0x69, 0x78, 0x8A};
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Daniel.Wyatt@gmail.com>
parents: 4894
diff changeset
  1110
    SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
6b89d83b0b5a Windows candidate list support.
Daniel Wyatt <Danie