libfreerdp-locale: cleanup Mac OS X keycode mapping

This commit is contained in:
Marc-André Moreau 2013-03-03 19:30:01 -05:00
parent 474f0469b4
commit 7d75343e8e
6 changed files with 1113 additions and 1016 deletions

View File

@ -206,392 +206,6 @@ char* freerdp_detect_keymap_from_xkb()
return keymap;
}
#ifdef __APPLE__
#define APPLE_VK_ANSI_A 0x00
#define APPLE_VK_ANSI_S 0x01
#define APPLE_VK_ANSI_D 0x02
#define APPLE_VK_ANSI_F 0x03
#define APPLE_VK_ANSI_H 0x04
#define APPLE_VK_ANSI_G 0x05
#define APPLE_VK_ANSI_Z 0x06
#define APPLE_VK_ANSI_X 0x07
#define APPLE_VK_ANSI_C 0x08
#define APPLE_VK_ANSI_V 0x09
#define APPLE_VK_ANSI_B 0x0B
#define APPLE_VK_ANSI_Q 0x0C
#define APPLE_VK_ANSI_W 0x0D
#define APPLE_VK_ANSI_E 0x0E
#define APPLE_VK_ANSI_R 0x0F
#define APPLE_VK_ANSI_Y 0x10
#define APPLE_VK_ANSI_T 0x11
#define APPLE_VK_ANSI_1 0x12
#define APPLE_VK_ANSI_2 0x13
#define APPLE_VK_ANSI_3 0x14
#define APPLE_VK_ANSI_4 0x15
#define APPLE_VK_ANSI_6 0x16
#define APPLE_VK_ANSI_5 0x17
#define APPLE_VK_ANSI_Equal 0x18
#define APPLE_VK_ANSI_9 0x19
#define APPLE_VK_ANSI_7 0x1A
#define APPLE_VK_ANSI_Minus 0x1B
#define APPLE_VK_ANSI_8 0x1C
#define APPLE_VK_ANSI_0 0x1D
#define APPLE_VK_ANSI_RightBracket 0x1E
#define APPLE_VK_ANSI_O 0x1F
#define APPLE_VK_ANSI_U 0x20
#define APPLE_VK_ANSI_LeftBracket 0x21
#define APPLE_VK_ANSI_I 0x22
#define APPLE_VK_ANSI_P 0x23
#define APPLE_VK_ANSI_L 0x25
#define APPLE_VK_ANSI_J 0x26
#define APPLE_VK_ANSI_Quote 0x27
#define APPLE_VK_ANSI_K 0x28
#define APPLE_VK_ANSI_Semicolon 0x29
#define APPLE_VK_ANSI_Backslash 0x2A
#define APPLE_VK_ANSI_Comma 0x2B
#define APPLE_VK_ANSI_Slash 0x2C
#define APPLE_VK_ANSI_N 0x2D
#define APPLE_VK_ANSI_M 0x2E
#define APPLE_VK_ANSI_Period 0x2F
#define APPLE_VK_ANSI_Grave 0x32
#define APPLE_VK_ANSI_KeypadDecimal 0x41
#define APPLE_VK_ANSI_KeypadMultiply 0x43
#define APPLE_VK_ANSI_KeypadPlus 0x45
#define APPLE_VK_ANSI_KeypadClear 0x47
#define APPLE_VK_ANSI_KeypadDivide 0x4B
#define APPLE_VK_ANSI_KeypadEnter 0x4C
#define APPLE_VK_ANSI_KeypadMinus 0x4E
#define APPLE_VK_ANSI_KeypadEquals 0x51
#define APPLE_VK_ANSI_Keypad0 0x52
#define APPLE_VK_ANSI_Keypad1 0x53
#define APPLE_VK_ANSI_Keypad2 0x54
#define APPLE_VK_ANSI_Keypad3 0x55
#define APPLE_VK_ANSI_Keypad4 0x56
#define APPLE_VK_ANSI_Keypad5 0x57
#define APPLE_VK_ANSI_Keypad6 0x58
#define APPLE_VK_ANSI_Keypad7 0x59
#define APPLE_VK_ANSI_Keypad8 0x5B
#define APPLE_VK_ANSI_Keypad9 0x5C
#define APPLE_VK_Return 0x24
#define APPLE_VK_Tab 0x30
#define APPLE_VK_Space 0x31
#define APPLE_VK_Delete 0x33
#define APPLE_VK_Escape 0x35
#define APPLE_VK_Command 0x37
#define APPLE_VK_Shift 0x38
#define APPLE_VK_CapsLock 0x39
#define APPLE_VK_Option 0x3A
#define APPLE_VK_Control 0x3B
#define APPLE_VK_RightShift 0x3C
#define APPLE_VK_RightOption 0x3D
#define APPLE_VK_RightControl 0x3E
#define APPLE_VK_Function 0x3F
#define APPLE_VK_F17 0x40
#define APPLE_VK_VolumeUp 0x48
#define APPLE_VK_VolumeDown 0x49
#define APPLE_VK_Mute 0x4A
#define APPLE_VK_F18 0x4F
#define APPLE_VK_F19 0x50
#define APPLE_VK_F20 0x5A
#define APPLE_VK_F5 0x60
#define APPLE_VK_F6 0x61
#define APPLE_VK_F7 0x62
#define APPLE_VK_F3 0x63
#define APPLE_VK_F8 0x64
#define APPLE_VK_F9 0x65
#define APPLE_VK_F11 0x67
#define APPLE_VK_F13 0x69
#define APPLE_VK_F16 0x6A
#define APPLE_VK_F14 0x6B
#define APPLE_VK_F10 0x6D
#define APPLE_VK_F12 0x6F
#define APPLE_VK_F15 0x71
#define APPLE_VK_Help 0x72
#define APPLE_VK_Home 0x73
#define APPLE_VK_PageUp 0x74
#define APPLE_VK_ForwardDelete 0x75
#define APPLE_VK_F4 0x76
#define APPLE_VK_End 0x77
#define APPLE_VK_F2 0x78
#define APPLE_VK_PageDown 0x79
#define APPLE_VK_F1 0x7A
#define APPLE_VK_LeftArrow 0x7B
#define APPLE_VK_RightArrow 0x7C
#define APPLE_VK_DownArrow 0x7D
#define APPLE_VK_UpArrow 0x7E
#define APPLE_VK_ISO_Section 0x0A
#define APPLE_VK_JIS_Yen 0x5D
#define APPLE_VK_JIS_Underscore 0x5E
#define APPLE_VK_JIS_KeypadComma 0x5F
#define APPLE_VK_JIS_Eisu 0x66
#define APPLE_VK_JIS_Kana 0x68
const DWORD KEYCODE_TO_VKCODE_MACOSX[256] =
{
0, /* 0 */
0, /* 1 */
0, /* 2 */
0, /* 3 */
0, /* 4 */
0, /* 5 */
0, /* 6 */
0, /* 7 */
VK_KEY_A, /* 8 */
VK_KEY_S, /* 9 */
VK_KEY_D, /* 10 */
VK_KEY_F, /* 11 */
VK_KEY_H, /* 12 */
VK_KEY_G, /* 13 */
VK_KEY_Z, /* 14 */
VK_KEY_X, /* 15 */
VK_KEY_C, /* 16 */
VK_KEY_V, /* 17 */
VK_OEM_102, /* 18 */
VK_KEY_B, /* 19 */
VK_KEY_Q, /* 20 */
VK_KEY_W, /* 21 */
VK_KEY_E, /* 22 */
VK_KEY_R, /* 23 */
VK_KEY_Y, /* 24 */
VK_KEY_T, /* 25 */
VK_KEY_1, /* 26 */
VK_KEY_2, /* 27 */
VK_KEY_3, /* 28 */
VK_KEY_4, /* 29 */
VK_KEY_6, /* 30 */
VK_KEY_5, /* 31 */
VK_OEM_PLUS, /* 32 */
VK_KEY_9, /* 33 */
VK_KEY_7, /* 34 */
VK_OEM_MINUS, /* 35 */
VK_KEY_8, /* 36 */
VK_KEY_0, /* 37 */
VK_OEM_6, /* 38 */
VK_KEY_O, /* 39 */
VK_KEY_U, /* 40 */
VK_OEM_4, /* 41 */
VK_KEY_I, /* 42 */
VK_KEY_P, /* 43 */
VK_RETURN, /* 44 */
VK_KEY_L, /* 45 */
VK_KEY_J, /* 46 */
VK_OEM_7, /* 47 */
VK_KEY_K, /* 48 */
VK_OEM_1, /* 49 */
VK_OEM_5, /* 50 */
VK_OEM_COMMA, /* 51 */
VK_OEM_2, /* 52 */
VK_KEY_N, /* 53 */
VK_KEY_M, /* 54 */
VK_OEM_PERIOD, /* 55 */
VK_TAB, /* 56 */
VK_SPACE, /* 57 */
VK_OEM_3, /* 58 */
VK_BACK, /* 59 */
0, /* 60 */
VK_ESCAPE, /* 61 */
0, /* 62 */
VK_LWIN, /* 63 */
VK_LSHIFT, /* 64 */
VK_CAPITAL, /* 65 */
VK_LMENU, /* 66 */
VK_LCONTROL, /* 67 */
VK_RSHIFT, /* 68 */
VK_RMENU, /* 69 */
0, /* 70 */
VK_RWIN, /* 71 */
0, /* 72 */
VK_DECIMAL, /* 73 */
0, /* 74 */
VK_MULTIPLY, /* 75 */
0, /* 76 */
VK_ADD, /* 77 */
0, /* 78 */
VK_NUMLOCK, /* 79 */
0, /* 80 */
0, /* 81 */
0, /* 82 */
VK_DIVIDE, /* 83 */
VK_RETURN, /* 84 */
0, /* 85 */
VK_SUBTRACT, /* 86 */
0, /* 87 */
0, /* 88 */
0, /* 89 */
VK_NUMPAD0, /* 90 */
VK_NUMPAD1, /* 91 */
VK_NUMPAD2, /* 92 */
VK_NUMPAD3, /* 93 */
VK_NUMPAD4, /* 94 */
VK_NUMPAD5, /* 95 */
VK_NUMPAD6, /* 96 */
VK_NUMPAD7, /* 97 */
0, /* 98 */
VK_NUMPAD8, /* 99 */
VK_NUMPAD9, /* 100 */
0, /* 101 */
0, /* 102 */
0, /* 103 */
VK_F5, /* 104 */
VK_F6, /* 105 */
VK_F7, /* 106 */
VK_F3, /* 107 */
VK_F8, /* 108 */
VK_F9, /* 109 */
0, /* 110 */
VK_F11, /* 111 */
0, /* 112 */
VK_SNAPSHOT, /* 113 */
0, /* 114 */
VK_SCROLL, /* 115 */
0, /* 116 */
VK_F10, /* 117 */
0, /* 118 */
VK_F12, /* 119 */
0, /* 120 */
VK_PAUSE, /* 121 */
VK_INSERT, /* 122 */
VK_HOME, /* 123 */
VK_PRIOR, /* 124 */
VK_DELETE, /* 125 */
VK_F4, /* 126 */
VK_END, /* 127 */
VK_F2, /* 128 */
VK_NEXT, /* 129 */
VK_F1, /* 130 */
VK_LEFT, /* 131 */
VK_RIGHT, /* 132 */
VK_DOWN, /* 133 */
VK_UP, /* 134 */
0, /* 135 */
0, /* 136 */
0, /* 137 */
0, /* 138 */
0, /* 139 */
0, /* 140 */
0, /* 141 */
0, /* 142 */
0, /* 143 */
0, /* 144 */
0, /* 145 */
0, /* 146 */
0, /* 147 */
0, /* 148 */
0, /* 149 */
0, /* 150 */
0, /* 151 */
0, /* 152 */
0, /* 153 */
0, /* 154 */
0, /* 155 */
0, /* 156 */
0, /* 157 */
0, /* 158 */
0, /* 159 */
0, /* 160 */
0, /* 161 */
0, /* 162 */
0, /* 163 */
0, /* 164 */
0, /* 165 */
0, /* 166 */
0, /* 167 */
0, /* 168 */
0, /* 169 */
0, /* 170 */
0, /* 171 */
0, /* 172 */
0, /* 173 */
0, /* 174 */
0, /* 175 */
0, /* 176 */
0, /* 177 */
0, /* 178 */
0, /* 179 */
0, /* 180 */
0, /* 181 */
0, /* 182 */
0, /* 183 */
0, /* 184 */
0, /* 185 */
0, /* 186 */
0, /* 187 */
0, /* 188 */
0, /* 189 */
0, /* 190 */
0, /* 191 */
0, /* 192 */
0, /* 193 */
0, /* 194 */
0, /* 195 */
0, /* 196 */
0, /* 197 */
0, /* 198 */
0, /* 199 */
0, /* 200 */
0, /* 201 */
0, /* 202 */
0, /* 203 */
0, /* 204 */
0, /* 205 */
0, /* 206 */
0, /* 207 */
0, /* 208 */
0, /* 209 */
0, /* 210 */
0, /* 211 */
0, /* 212 */
0, /* 213 */
0, /* 214 */
0, /* 215 */
0, /* 216 */
0, /* 217 */
0, /* 218 */
0, /* 219 */
0, /* 220 */
0, /* 221 */
0, /* 222 */
0, /* 223 */
0, /* 224 */
0, /* 225 */
0, /* 226 */
0, /* 227 */
0, /* 228 */
0, /* 229 */
0, /* 230 */
0, /* 231 */
0, /* 232 */
0, /* 233 */
0, /* 234 */
0, /* 235 */
0, /* 236 */
0, /* 237 */
0, /* 238 */
0, /* 239 */
0, /* 240 */
0, /* 241 */
0, /* 242 */
0, /* 243 */
0, /* 244 */
0, /* 245 */
0, /* 246 */
0, /* 247 */
0, /* 248 */
0, /* 249 */
0, /* 250 */
0, /* 251 */
0, /* 252 */
0, /* 253 */
0, /* 254 */
0 /* 255 */
};
#endif
UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keycode_to_rdp_scancode[256])
{
DWORD vkcode;
@ -602,9 +216,11 @@ UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keyco
ZeroMemory(x11_keycode_to_rdp_scancode, sizeof(RDP_SCANCODE) * 256);
#ifdef __APPLE__
/* Apple X11 breaks XKB detection */
CopyMemory(keycode_to_vkcode, KEYCODE_TO_VKCODE_MACOSX, sizeof(keycode_to_vkcode));
for (keycode = 0; keycode < 256; keycode++)
{
keycode_to_vkcode[keycode] = GetVirtualKeyCodeFromKeycode(keycode, KEYCODE_TYPE_APPLE);
}
#elif defined(WITH_SUN)
{

View File

@ -342,7 +342,7 @@
#define VK_DBE_HIRAGANA 0xFF
/*
* Keyboard Scan Codes
* Virtual Scan Codes
*/
/**
@ -701,6 +701,142 @@
#define KBD7_Y1D VK_PAUSE
/**
* X11 Keycodes
*/
/**
* Mac OS X
*/
#define APPLE_VK_ANSI_A 0x00
#define APPLE_VK_ANSI_S 0x01
#define APPLE_VK_ANSI_D 0x02
#define APPLE_VK_ANSI_F 0x03
#define APPLE_VK_ANSI_H 0x04
#define APPLE_VK_ANSI_G 0x05
#define APPLE_VK_ANSI_Z 0x06
#define APPLE_VK_ANSI_X 0x07
#define APPLE_VK_ANSI_C 0x08
#define APPLE_VK_ANSI_V 0x09
#define APPLE_VK_ISO_Section 0x0A
#define APPLE_VK_ANSI_B 0x0B
#define APPLE_VK_ANSI_Q 0x0C
#define APPLE_VK_ANSI_W 0x0D
#define APPLE_VK_ANSI_E 0x0E
#define APPLE_VK_ANSI_R 0x0F
#define APPLE_VK_ANSI_Y 0x10
#define APPLE_VK_ANSI_T 0x11
#define APPLE_VK_ANSI_1 0x12
#define APPLE_VK_ANSI_2 0x13
#define APPLE_VK_ANSI_3 0x14
#define APPLE_VK_ANSI_4 0x15
#define APPLE_VK_ANSI_6 0x16
#define APPLE_VK_ANSI_5 0x17
#define APPLE_VK_ANSI_Equal 0x18
#define APPLE_VK_ANSI_9 0x19
#define APPLE_VK_ANSI_7 0x1A
#define APPLE_VK_ANSI_Minus 0x1B
#define APPLE_VK_ANSI_8 0x1C
#define APPLE_VK_ANSI_0 0x1D
#define APPLE_VK_ANSI_RightBracket 0x1E
#define APPLE_VK_ANSI_O 0x1F
#define APPLE_VK_ANSI_U 0x20
#define APPLE_VK_ANSI_LeftBracket 0x21
#define APPLE_VK_ANSI_I 0x22
#define APPLE_VK_ANSI_P 0x23
#define APPLE_VK_Return 0x24
#define APPLE_VK_ANSI_L 0x25
#define APPLE_VK_ANSI_J 0x26
#define APPLE_VK_ANSI_Quote 0x27
#define APPLE_VK_ANSI_K 0x28
#define APPLE_VK_ANSI_Semicolon 0x29
#define APPLE_VK_ANSI_Backslash 0x2A
#define APPLE_VK_ANSI_Comma 0x2B
#define APPLE_VK_ANSI_Slash 0x2C
#define APPLE_VK_ANSI_N 0x2D
#define APPLE_VK_ANSI_M 0x2E
#define APPLE_VK_ANSI_Period 0x2F
#define APPLE_VK_Tab 0x30
#define APPLE_VK_Space 0x31
#define APPLE_VK_ANSI_Grave 0x32
#define APPLE_VK_Delete 0x33
#define APPLE_VK_0x34 0x34
#define APPLE_VK_Escape 0x35
#define APPLE_VK_0x36 0x36
#define APPLE_VK_Command 0x37
#define APPLE_VK_Shift 0x38
#define APPLE_VK_CapsLock 0x39
#define APPLE_VK_Option 0x3A
#define APPLE_VK_Control 0x3B
#define APPLE_VK_RightShift 0x3C
#define APPLE_VK_RightOption 0x3D
#define APPLE_VK_RightControl 0x3E
#define APPLE_VK_Function 0x3F
#define APPLE_VK_F17 0x40
#define APPLE_VK_ANSI_KeypadDecimal 0x41
#define APPLE_VK_0x42 0x42
#define APPLE_VK_ANSI_KeypadMultiply 0x43
#define APPLE_VK_0x44 0x44
#define APPLE_VK_ANSI_KeypadPlus 0x45
#define APPLE_VK_0x46 0x46
#define APPLE_VK_ANSI_KeypadClear 0x47
#define APPLE_VK_VolumeUp 0x48
#define APPLE_VK_VolumeDown 0x49
#define APPLE_VK_Mute 0x4A
#define APPLE_VK_ANSI_KeypadDivide 0x4B
#define APPLE_VK_ANSI_KeypadEnter 0x4C
#define APPLE_VK_0x4D 0x4D
#define APPLE_VK_ANSI_KeypadMinus 0x4E
#define APPLE_VK_F18 0x4F
#define APPLE_VK_F19 0x50
#define APPLE_VK_ANSI_KeypadEquals 0x51
#define APPLE_VK_ANSI_Keypad0 0x52
#define APPLE_VK_ANSI_Keypad1 0x53
#define APPLE_VK_ANSI_Keypad2 0x54
#define APPLE_VK_ANSI_Keypad3 0x55
#define APPLE_VK_ANSI_Keypad4 0x56
#define APPLE_VK_ANSI_Keypad5 0x57
#define APPLE_VK_ANSI_Keypad6 0x58
#define APPLE_VK_ANSI_Keypad7 0x59
#define APPLE_VK_F20 0x5A
#define APPLE_VK_ANSI_Keypad8 0x5B
#define APPLE_VK_ANSI_Keypad9 0x5C
#define APPLE_VK_JIS_Yen 0x5D
#define APPLE_VK_JIS_Underscore 0x5E
#define APPLE_VK_JIS_KeypadComma 0x5F
#define APPLE_VK_F5 0x60
#define APPLE_VK_F6 0x61
#define APPLE_VK_F7 0x62
#define APPLE_VK_F3 0x63
#define APPLE_VK_F8 0x64
#define APPLE_VK_F9 0x65
#define APPLE_VK_JIS_Eisu 0x66
#define APPLE_VK_F11 0x67
#define APPLE_VK_JIS_Kana 0x68
#define APPLE_VK_F13 0x69
#define APPLE_VK_F16 0x6A
#define APPLE_VK_F14 0x6B
#define APPLE_VK_F10 0x6D
#define APPLE_VK_0x6C 0x6C
#define APPLE_VK_0x6E 0x6E
#define APPLE_VK_F12 0x6F
#define APPLE_VK_0x70 0x70
#define APPLE_VK_F15 0x71
#define APPLE_VK_Help 0x72
#define APPLE_VK_Home 0x73
#define APPLE_VK_PageUp 0x74
#define APPLE_VK_ForwardDelete 0x75
#define APPLE_VK_F4 0x76
#define APPLE_VK_End 0x77
#define APPLE_VK_F2 0x78
#define APPLE_VK_PageDown 0x79
#define APPLE_VK_F1 0x7A
#define APPLE_VK_LeftArrow 0x7B
#define APPLE_VK_RightArrow 0x7C
#define APPLE_VK_DownArrow 0x7D
#define APPLE_VK_UpArrow 0x7E
/**
* Functions
*/
@ -711,4 +847,8 @@ WINPR_API DWORD GetVirtualKeyCodeFromName(const char* vkname);
WINPR_API DWORD GetVirtualKeyCodeFromVirtualScanCode(DWORD scancode, DWORD dwKeyboardType);
WINPR_API DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeyboardType);
#define KEYCODE_TYPE_APPLE 0x00000001
WINPR_API DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, DWORD dwFlags);
#endif /* WINPR_INPUT_H */

View File

@ -19,7 +19,9 @@ set(MODULE_NAME "winpr-input")
set(MODULE_PREFIX "WINPR_INPUT")
set(${MODULE_PREFIX}_SRCS
keyboard.c)
virtualkey.c
scancode.c
keycode.c)
add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT"
MONOLITHIC ${MONOLITHIC_BUILD}

View File

@ -0,0 +1,312 @@
/**
* WinPR: Windows Portable Runtime
* Keyboard Input
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <winpr/crt.h>
#include <winpr/input.h>
/**
* X11 Keycodes
*/
/**
* Mac OS X
*/
DWORD KEYCODE_TO_VKCODE_APPLE[256] =
{
0, /* 0 */
0, /* 1 */
0, /* 2 */
0, /* 3 */
0, /* 4 */
0, /* 5 */
0, /* 6 */
0, /* 7 */
VK_KEY_A, /* APPLE_VK_ANSI_A (0x00) */
VK_KEY_S, /* APPLE_VK_ANSI_S (0x01) */
VK_KEY_D, /* APPLE_VK_ANSI_D (0x02) */
VK_KEY_F, /* APPLE_VK_ANSI_F (0x03) */
VK_KEY_H, /* APPLE_VK_ANSI_H (0x04) */
VK_KEY_G, /* APPLE_VK_ANSI_G (0x05) */
VK_KEY_Z, /* APPLE_VK_ANSI_Z (0x06) */
VK_KEY_X, /* APPLE_VK_ANSI_X (0x07) */
VK_KEY_C, /* APPLE_VK_ANSI_C (0x08) */
VK_KEY_V, /* APPLE_VK_ANSI_V (0x09) */
VK_OEM_102, /* APPLE_VK_ISO_Section (0x0A) */
VK_KEY_B, /* APPLE_VK_ANSI_B (0x0B) */
VK_KEY_Q, /* APPLE_VK_ANSI_Q (0x0C) */
VK_KEY_W, /* APPLE_VK_ANSI_W (0x0D) */
VK_KEY_E, /* APPLE_VK_ANSI_E (0x0E) */
VK_KEY_R, /* APPLE_VK_ANSI_R (0x0F) */
VK_KEY_Y, /* APPLE_VK_ANSI_Y (0x10) */
VK_KEY_T, /* APPLE_VK_ANSI_T (0x11) */
VK_KEY_1, /* APPLE_VK_ANSI_1 (0x12) */
VK_KEY_2, /* APPLE_VK_ANSI_2 (0x13) */
VK_KEY_3, /* APPLE_VK_ANSI_3 (0x14) */
VK_KEY_4, /* APPLE_VK_ANSI_4 (0x15) */
VK_KEY_6, /* APPLE_VK_ANSI_6 (0x16) */
VK_KEY_5, /* APPLE_VK_ANSI_5 (0x17) */
VK_OEM_PLUS, /* APPLE_VK_ANSI_Equal (0x18) */
VK_KEY_9, /* APPLE_VK_ANSI_9 (0x19) */
VK_KEY_7, /* APPLE_VK_ANSI_7 (0x1A) */
VK_OEM_MINUS, /* APPLE_VK_ANSI_Minus (0x1B) */
VK_KEY_8, /* APPLE_VK_ANSI_8 (0x1C) */
VK_KEY_0, /* APPLE_VK_ANSI_0 (0x1D) */
VK_OEM_6, /* APPLE_VK_ANSI_RightBracket (0x1E) */
VK_KEY_O, /* APPLE_VK_ANSI_O (0x1F) */
VK_KEY_U, /* APPLE_VK_ANSI_U (0x20) */
VK_OEM_4, /* APPLE_VK_ANSI_LeftBracket (0x21) */
VK_KEY_I, /* APPLE_VK_ANSI_I (0x22) */
VK_KEY_P, /* APPLE_VK_ANSI_P (0x23) */
VK_RETURN, /* APPLE_VK_Return (0x24) */
VK_KEY_L, /* APPLE_VK_ANSI_L (0x25) */
VK_KEY_J, /* APPLE_VK_ANSI_J (0x26) */
VK_OEM_7, /* APPLE_VK_ANSI_Quote (0x27) */
VK_KEY_K, /* APPLE_VK_ANSI_K (0x28) */
VK_OEM_1, /* APPLE_VK_ANSI_Semicolon (0x29) */
VK_OEM_5, /* APPLE_VK_ANSI_Backslash (0x2A) */
VK_OEM_COMMA, /* APPLE_VK_ANSI_Comma (0x2B) */
VK_OEM_2, /* APPLE_VK_ANSI_Slash (0x2C) */
VK_KEY_N, /* APPLE_VK_ANSI_N (0x2D) */
VK_KEY_M, /* APPLE_VK_ANSI_M (0x2E) */
VK_OEM_PERIOD, /* APPLE_VK_ANSI_Period (0x2F) */
VK_TAB, /* APPLE_VK_Tab (0x30) */
VK_SPACE, /* APPLE_VK_Space (0x31) */
VK_OEM_3, /* APPLE_VK_ANSI_Grave (0x32) */
VK_BACK, /* APPLE_VK_Delete (0x33) */
0, /* APPLE_VK_0x34 (0x34) */
VK_ESCAPE, /* APPLE_VK_Escape (0x35) */
0, /* APPLE_VK_0x36 (0x36) */
VK_LWIN, /* APPLE_VK_Command (0x37) */
VK_LSHIFT, /* APPLE_VK_Shift (0x38) */
VK_CAPITAL, /* APPLE_VK_CapsLock (0x39) */
VK_LMENU, /* APPLE_VK_Option (0x3A) */
VK_LCONTROL, /* APPLE_VK_Control (0x3B) */
VK_RSHIFT, /* APPLE_VK_RightShift (0x3C) */
VK_RMENU, /* APPLE_VK_RightOption (0x3D) */
0, /* APPLE_VK_RightControl (0x3E) */
VK_RWIN, /* APPLE_VK_Function (0x3F) */
0, /* APPLE_VK_F17 (0x40) */
VK_DECIMAL, /* APPLE_VK_ANSI_KeypadDecimal (0x41) */
0, /* APPLE_VK_0x42 (0x42) */
VK_MULTIPLY, /* APPLE_VK_ANSI_KeypadMultiply (0x43) */
0, /* APPLE_VK_0x44 (0x44) */
VK_ADD, /* APPLE_VK_ANSI_KeypadPlus (0x45) */
0, /* APPLE_VK_0x46 (0x46) */
VK_NUMLOCK, /* APPLE_VK_ANSI_KeypadClear (0x47) */
0, /* APPLE_VK_VolumeUp (0x48) */
0, /* APPLE_VK_VolumeDown (0x49) */
0, /* APPLE_VK_Mute (0x4A) */
VK_DIVIDE, /* APPLE_VK_ANSI_KeypadDivide (0x4B) */
VK_RETURN, /* APPLE_VK_ANSI_KeypadEnter (0x4C) */
0, /* APPLE_VK_0x4D (0x4D) */
VK_SUBTRACT, /* APPLE_VK_ANSI_KeypadMinus (0x4E) */
0, /* APPLE_VK_F18 (0x4F) */
0, /* APPLE_VK_F19 (0x50) */
0, /* APPLE_VK_ANSI_KeypadEquals (0x51) */
VK_NUMPAD0, /* APPLE_VK_ANSI_Keypad0 (0x52) */
VK_NUMPAD1, /* APPLE_VK_ANSI_Keypad1 (0x53) */
VK_NUMPAD2, /* APPLE_VK_ANSI_Keypad2 (0x54) */
VK_NUMPAD3, /* APPLE_VK_ANSI_Keypad3 (0x55) */
VK_NUMPAD4, /* APPLE_VK_ANSI_Keypad4 (0x56) */
VK_NUMPAD5, /* APPLE_VK_ANSI_Keypad5 (0x57) */
VK_NUMPAD6, /* APPLE_VK_ANSI_Keypad6 (0x58) */
VK_NUMPAD7, /* APPLE_VK_ANSI_Keypad7 (0x59) */
0, /* APPLE_VK_F20 (0x5A) */
VK_NUMPAD8, /* APPLE_VK_ANSI_Keypad8 (0x5B) */
VK_NUMPAD9, /* APPLE_VK_ANSI_Keypad9 (0x5C) */
0, /* APPLE_VK_JIS_Yen (0x5D) */
0, /* APPLE_VK_JIS_Underscore (0x5E) */
0, /* APPLE_VK_JIS_KeypadComma (0x5F) */
VK_F5, /* APPLE_VK_F5 (0x60) */
VK_F6, /* APPLE_VK_F6 (0x61) */
VK_F7, /* APPLE_VK_F7 (0x62) */
VK_F3, /* APPLE_VK_F3 (0x63) */
VK_F8, /* APPLE_VK_F8 (0x64) */
VK_F9, /* APPLE_VK_F9 (0x65) */
0, /* APPLE_VK_JIS_Eisu (0x66) */
VK_F11, /* APPLE_VK_F11 (0x67) */
0, /* APPLE_VK_JIS_Kana (0x68) */
VK_SNAPSHOT, /* APPLE_VK_F13 (0x69) */
0, /* APPLE_VK_F16 (0x6A) */
VK_SCROLL, /* APPLE_VK_F14 (0x6B) */
0, /* APPLE_VK_0x6C (0x6C) */
VK_F10, /* APPLE_VK_F10 (0x6D) */
0, /* APPLE_VK_0x6E (0x6E) */
VK_F12, /* APPLE_VK_F12 (0x6F) */
0, /* APPLE_VK_0x70 (0x70) */
VK_PAUSE, /* APPLE_VK_F15 (0x71) */
VK_INSERT, /* APPLE_VK_Help (0x72) */
VK_HOME, /* APPLE_VK_Home (0x73) */
VK_PRIOR, /* APPLE_VK_PageUp (0x74) */
VK_DELETE, /* APPLE_VK_ForwardDelete (0x75) */
VK_F4, /* APPLE_VK_F4 (0x76) */
VK_END, /* APPLE_VK_End (0x77) */
VK_F2, /* APPLE_VK_F2 (0x78) */
VK_NEXT, /* APPLE_VK_PageDown (0x79) */
VK_F1, /* APPLE_VK_F1 (0x7A) */
VK_LEFT, /* APPLE_VK_LeftArrow (0x7B) */
VK_RIGHT, /* APPLE_VK_RightArrow (0x7C) */
VK_DOWN, /* APPLE_VK_DownArrow (0x7D) */
VK_UP, /* APPLE_VK_UpArrow (0x7E) */
0, /* 135 */
0, /* 136 */
0, /* 137 */
0, /* 138 */
0, /* 139 */
0, /* 140 */
0, /* 141 */
0, /* 142 */
0, /* 143 */
0, /* 144 */
0, /* 145 */
0, /* 146 */
0, /* 147 */
0, /* 148 */
0, /* 149 */
0, /* 150 */
0, /* 151 */
0, /* 152 */
0, /* 153 */
0, /* 154 */
0, /* 155 */
0, /* 156 */
0, /* 157 */
0, /* 158 */
0, /* 159 */
0, /* 160 */
0, /* 161 */
0, /* 162 */
0, /* 163 */
0, /* 164 */
0, /* 165 */
0, /* 166 */
0, /* 167 */
0, /* 168 */
0, /* 169 */
0, /* 170 */
0, /* 171 */
0, /* 172 */
0, /* 173 */
0, /* 174 */
0, /* 175 */
0, /* 176 */
0, /* 177 */
0, /* 178 */
0, /* 179 */
0, /* 180 */
0, /* 181 */
0, /* 182 */
0, /* 183 */
0, /* 184 */
0, /* 185 */
0, /* 186 */
0, /* 187 */
0, /* 188 */
0, /* 189 */
0, /* 190 */
0, /* 191 */
0, /* 192 */
0, /* 193 */
0, /* 194 */
0, /* 195 */
0, /* 196 */
0, /* 197 */
0, /* 198 */
0, /* 199 */
0, /* 200 */
0, /* 201 */
0, /* 202 */
0, /* 203 */
0, /* 204 */
0, /* 205 */
0, /* 206 */
0, /* 207 */
0, /* 208 */
0, /* 209 */
0, /* 210 */
0, /* 211 */
0, /* 212 */
0, /* 213 */
0, /* 214 */
0, /* 215 */
0, /* 216 */
0, /* 217 */
0, /* 218 */
0, /* 219 */
0, /* 220 */
0, /* 221 */
0, /* 222 */
0, /* 223 */
0, /* 224 */
0, /* 225 */
0, /* 226 */
0, /* 227 */
0, /* 228 */
0, /* 229 */
0, /* 230 */
0, /* 231 */
0, /* 232 */
0, /* 233 */
0, /* 234 */
0, /* 235 */
0, /* 236 */
0, /* 237 */
0, /* 238 */
0, /* 239 */
0, /* 240 */
0, /* 241 */
0, /* 242 */
0, /* 243 */
0, /* 244 */
0, /* 245 */
0, /* 246 */
0, /* 247 */
0, /* 248 */
0, /* 249 */
0, /* 250 */
0, /* 251 */
0, /* 252 */
0, /* 253 */
0, /* 254 */
0 /* 255 */
};
DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, DWORD dwFlags)
{
DWORD vkcode;
vkcode = VK_NONE;
if (dwFlags & KEYCODE_TYPE_APPLE)
{
if (keycode < 0xFF)
vkcode = KEYCODE_TO_VKCODE_APPLE[keycode & 0xFF];
}
if (!vkcode)
vkcode = VK_NONE;
return vkcode;
}

View File

@ -0,0 +1,653 @@
/**
* WinPR: Windows Portable Runtime
* Keyboard Input
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <winpr/crt.h>
#include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KBD4_T67,
KBD4_T68,
KBD4_T69,
KBD4_T6A,
KBD4_T6B,
KBD4_T6C,
KBD4_T6D,
KBD4_T6E,
KBD4_T6F,
KBD4_T70,
KBD4_T71,
KBD4_T72,
KBD4_T73,
KBD4_T74,
KBD4_T75,
KBD4_T76,
KBD4_T77,
KBD4_T78,
KBD4_T79,
KBD4_T7A,
KBD4_T7B,
KBD4_T7C,
KBD4_T7D,
KBD4_T7E,
KBD4_T7F
};
DWORD KBD4X[128] =
{
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD4_X10,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD4_X19,
VK_NONE,
VK_NONE,
KBD4_X1C,
KBD4_X1D,
VK_NONE,
VK_NONE,
KBD4_X20,
KBD4_X21,
KBD4_X22,
VK_NONE,
KBD4_X24,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD4_X2E,
VK_NONE,
KBD4_X30,
VK_NONE,
KBD4_X32,
VK_NONE,
VK_NONE,
KBD4_X35,
VK_NONE,
KBD4_X37,
KBD4_X38,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD4_X46,
KBD4_X47,
KBD4_X48,
KBD4_X49,
VK_NONE,
KBD4_X4B,
VK_NONE,
KBD4_X4D,
VK_NONE,
KBD4_X4F,
KBD4_X50,
KBD4_X51,
KBD4_X52,
KBD4_X53,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD4_X5B,
K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
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD7_X42,
KBD7_X43,
KBD7_X44,
VK_NONE,
KBD7_X46,
KBD7_X47,
KBD7_X48,
KBD7_X49,
VK_NONE,
KBD7_X4B,
VK_NONE,
KBD7_X4D,
VK_NONE,
KBD7_X4F,
KBD7_X50,
KBD7_X51,
KBD7_X52,
KBD7_X53,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD7_X5B,
KBD7_X5C,
KBD7_X5D,
KBD7_X5E,
KBD7_X5F,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD7_X65,
KBD7_X66,
KBD7_X67,
KBD7_X68,
KBD7_X69,
KBD7_X6A,
KBD7_X6B,
KBD7_X6C,
KBD7_X6D,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE
};
DWORD GetVirtualKeyCodeFromVirtualScanCode(DWORD scancode, DWORD dwKeyboardType)
{
DWORD vkcode;
vkcode = VK_NONE;
if ((dwKeyboardType != 4) && (dwKeyboardType != 7))
dwKeyboardType = 4;
if (dwKeyboardType == 4)
{
if (scancode & KBDEXT)
vkcode = KBD4X[scancode & 0x7F];
else
vkcode = KBD4T[scancode & 0x7F];
}
else if (dwKeyboardType == 7)
{
if (scancode & KBDEXT)
vkcode = KBD7X[scancode & 0x7F];
else
vkcode = KBD7T[scancode & 0x7F];
}
return vkcode;
}
DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeyboardType)
{
int i;
DWORD scancode;
scancode = 0;
if ((dwKeyboardType != 4) && (dwKeyboardType != 7))
dwKeyboardType = 4;
if (dwKeyboardType == 4)
{
for (i = 0; i < 128; i++)
{
if (KBD4T[i] == vkcode)
{
scancode = i;
break;
}
}
if (!scancode)
{
for (i = 0; i < 128; i++)
{
if (KBD4X[i] == vkcode)
{
scancode = i;
break;
}
}
}
}
else if (dwKeyboardType == 7)
{
for (i = 0; i < 128; i++)
{
if (KBD7T[i] == vkcode)
{
scancode = i;
break;
}
}
if (!scancode)
{
for (i = 0; i < 128; i++)
{
if (KBD7X[i] == vkcode)
{
scancode = i;
break;
}
}
}
}
return scancode;
}

View File

@ -324,629 +324,3 @@ DWORD GetVirtualKeyCodeFromName(const char* vkname)
return VK_NONE;
}
/**
* Virtual Scan Codes
*/
/**
* Keyboard Type 4
*/
DWORD KBD4T[128] =
{
KBD4_T00,
KBD4_T01,
KBD4_T02,
KBD4_T03,
KBD4_T04,
KBD4_T05,
KBD4_T06,
KBD4_T07,
KBD4_T08,
KBD4_T09,
KBD4_T0A,
KBD4_T0B,
KBD4_T0C,
KBD4_T0D,
KBD4_T0E,
KBD4_T0F,
KBD4_T10,
KBD4_T11,
KBD4_T12,
KBD4_T13,
KBD4_T14,
KBD4_T15,
KBD4_T16,
KBD4_T17,
KBD4_T18,
KBD4_T19,
KBD4_T1A,
KBD4_T1B,
KBD4_T1C,
KBD4_T1D,
KBD4_T1E,
KBD4_T1F,
KBD4_T20,
KBD4_T21,
KBD4_T22,
KBD4_T23,
KBD4_T24,
KBD4_T25,
KBD4_T26,
KBD4_T27,
KBD4_T28,
KBD4_T29,
KBD4_T2A,
KBD4_T2B,
KBD4_T2C,
KBD4_T2D,
KBD4_T2E,
KBD4_T2F,
KBD4_T30,
KBD4_T31,
KBD4_T32,
KBD4_T33,
KBD4_T34,
KBD4_T35,
KBD4_T36,
KBD4_T37,
KBD4_T38,
KBD4_T39,
KBD4_T3A,
KBD4_T3B,
KBD4_T3C,
KBD4_T3D,
KBD4_T3E,
KBD4_T3F,
KBD4_T40,
KBD4_T41,
KBD4_T42,
KBD4_T43,
KBD4_T44,
KBD4_T45,
KBD4_T46,
KBD4_T47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ONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD4_X46,
KBD4_X47,
KBD4_X48,
KBD4_X49,
VK_NONE,
KBD4_X4B,
VK_NONE,
KBD4_X4D,
VK_NONE,
KBD4_X4F,
KBD4_X50,
KBD4_X51,
KBD4_X52,
KBD4_X53,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD4_X5B,
KBD4_X5C,
KBD4_X5D,
KBD4_X5E,
KBD4_X5F,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD4_X65,
KBD4_X66,
KBD4_X67,
KBD4_X68,
KBD4_X69,
KBD4_X6A,
KBD4_X6B,
KBD4_X6C,
KBD4_X6D,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE
};
/**
* Keyboard Type 7
*/
DWORD KBD7T[128] =
{
KBD7_T00,
KBD7_T01,
KBD7_T02,
KBD7_T03,
KBD7_T04,
KBD7_T05,
KBD7_T06,
KBD7_T07,
KBD7_T08,
KBD7_T09,
KBD7_T0A,
KBD7_T0B,
KBD7_T0C,
KBD7_T0D,
KBD7_T0E,
KBD7_T0F,
KBD7_T10,
KBD7_T11,
KBD7_T12,
KBD7_T13,
KBD7_T14,
KBD7_T15,
KBD7_T16,
KBD7_T17,
KBD7_T18,
KBD7_T19,
KBD7_T1A,
KBD7_T1B,
KBD7_T1C,
KBD7_T1D,
KBD7_T1E,
KBD7_T1F,
KBD7_T20,
KBD7_T21,
KBD7_T22,
KBD7_T23,
KBD7_T24,
KBD7_T25,
KBD7_T26,
KBD7_T27,
KBD7_T28,
KBD7_T29,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NONE,
KBD7_X19,
VK_NONE,
VK_NONE,
KBD7_X1C,
KBD7_X1D,
VK_NONE,
VK_NONE,
KBD7_X20,
KBD7_X21,
KBD7_X22,
VK_NONE,
KBD7_X24,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD7_X2E,
VK_NONE,
KBD7_X30,
VK_NONE,
KBD7_X32,
KBD7_X33,
VK_NONE,
KBD7_X35,
VK_NONE,
KBD7_X37,
KBD7_X38,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD7_X42,
KBD7_X43,
KBD7_X44,
VK_NONE,
KBD7_X46,
KBD7_X47,
KBD7_X48,
KBD7_X49,
VK_NONE,
KBD7_X4B,
VK_NONE,
KBD7_X4D,
VK_NONE,
KBD7_X4F,
KBD7_X50,
KBD7_X51,
KBD7_X52,
KBD7_X53,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD7_X5B,
KBD7_X5C,
KBD7_X5D,
KBD7_X5E,
KBD7_X5F,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
KBD7_X65,
KBD7_X66,
KBD7_X67,
KBD7_X68,
KBD7_X69,
KBD7_X6A,
KBD7_X6B,
KBD7_X6C,
KBD7_X6D,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE,
VK_NONE
};
DWORD GetVirtualKeyCodeFromVirtualScanCode(DWORD scancode, DWORD dwKeyboardType)
{
DWORD vkcode;
vkcode = VK_NONE;
if ((dwKeyboardType != 4) && (dwKeyboardType != 7))
dwKeyboardType = 4;
if (dwKeyboardType == 4)
{
if (scancode & KBDEXT)
vkcode = KBD4X[scancode & 0x7F];
else
vkcode = KBD4T[scancode & 0x7F];
}
else if (dwKeyboardType == 7)
{
if (scancode & KBDEXT)
vkcode = KBD7X[scancode & 0x7F];
else
vkcode = KBD7T[scancode & 0x7F];
}
return vkcode;
}
DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeyboardType)
{
int i;
DWORD scancode;
scancode = 0;
if ((dwKeyboardType != 4) && (dwKeyboardType != 7))
dwKeyboardType = 4;
if (dwKeyboardType == 4)
{
for (i = 0; i < 128; i++)
{
if (KBD4T[i] == vkcode)
{
scancode = i;
break;
}
}
if (!scancode)
{
for (i = 0; i < 128; i++)
{
if (KBD4X[i] == vkcode)
{
scancode = i;
break;
}
}
}
}
else if (dwKeyboardType == 7)
{
for (i = 0; i < 128; i++)
{
if (KBD7T[i] == vkcode)
{
scancode = i;
break;
}
}
if (!scancode)
{
for (i = 0; i < 128; i++)
{
if (KBD7X[i] == vkcode)
{
scancode = i;
break;
}
}
}
}
return scancode;
}