Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * USER Input processing |
| 3 | * |
| 4 | * Copyright 1993 Bob Amstadt |
| 5 | * Copyright 1996 Albrecht Kleine |
| 6 | * Copyright 1997 David Faure |
| 7 | * Copyright 1998 Morten Welinder |
| 8 | * Copyright 1998 Ulrich Weigand |
| 9 | * |
| 10 | */ |
| 11 | |
| 12 | #include <stdlib.h> |
| 13 | #include <string.h> |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 14 | #include <stdio.h> |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 15 | #include <ctype.h> |
| 16 | #include <assert.h> |
| 17 | |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 18 | #include "windef.h" |
| 19 | #include "wingdi.h" |
Marcus Meissner | 61afa33 | 1999-02-22 10:16:00 +0000 | [diff] [blame] | 20 | #include "winuser.h" |
| 21 | #include "wine/winbase16.h" |
| 22 | #include "wine/winuser16.h" |
Marcus Meissner | 219cfd8 | 1999-02-24 13:05:13 +0000 | [diff] [blame] | 23 | #include "wine/keyboard16.h" |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 24 | #include "win.h" |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 25 | #include "heap.h" |
| 26 | #include "input.h" |
| 27 | #include "keyboard.h" |
| 28 | #include "mouse.h" |
| 29 | #include "message.h" |
Patrik Stridvall | 6cc47d4 | 2000-03-08 18:26:56 +0000 | [diff] [blame] | 30 | #include "queue.h" |
Ulrich Weigand | 24dd5d9 | 1999-09-20 18:49:02 +0000 | [diff] [blame] | 31 | #include "module.h" |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 32 | #include "debugtools.h" |
| 33 | #include "struct32.h" |
| 34 | #include "winerror.h" |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 35 | #include "task.h" |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 36 | |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 37 | DECLARE_DEBUG_CHANNEL(accel); |
| 38 | DECLARE_DEBUG_CHANNEL(event); |
| 39 | DECLARE_DEBUG_CHANNEL(key); |
| 40 | DECLARE_DEBUG_CHANNEL(keyboard); |
| 41 | DECLARE_DEBUG_CHANNEL(win); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 42 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 43 | static BOOL InputEnabled = TRUE; |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 44 | BOOL SwappedButtons = FALSE; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 45 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 46 | BOOL MouseButtonsStates[3]; |
| 47 | BOOL AsyncMouseButtonsStates[3]; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 48 | BYTE InputKeyStateTable[256]; |
| 49 | BYTE QueueKeyStateTable[256]; |
| 50 | BYTE AsyncKeyStateTable[256]; |
| 51 | |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 52 | /* Storage for the USER-maintained mouse positions */ |
| 53 | DWORD PosX, PosY; |
| 54 | |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 55 | typedef union |
| 56 | { |
| 57 | struct |
| 58 | { |
| 59 | unsigned long count : 16; |
| 60 | unsigned long code : 8; |
| 61 | unsigned long extended : 1; |
| 62 | unsigned long unused : 2; |
| 63 | unsigned long win_internal : 2; |
| 64 | unsigned long context : 1; |
| 65 | unsigned long previous : 1; |
| 66 | unsigned long transition : 1; |
| 67 | } lp1; |
| 68 | unsigned long lp2; |
| 69 | } KEYLP; |
| 70 | |
| 71 | /*********************************************************************** |
| 72 | * keybd_event (USER32.583) |
| 73 | */ |
| 74 | void WINAPI keybd_event( BYTE bVk, BYTE bScan, |
| 75 | DWORD dwFlags, DWORD dwExtraInfo ) |
| 76 | { |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 77 | DWORD time, extra; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 78 | WORD message; |
| 79 | KEYLP keylp; |
| 80 | keylp.lp2 = 0; |
| 81 | |
| 82 | if (!InputEnabled) return; |
| 83 | |
| 84 | /* |
| 85 | * If we are called by the Wine keyboard driver, use the additional |
| 86 | * info pointed to by the dwExtraInfo argument. |
| 87 | * Otherwise, we need to determine that info ourselves (probably |
| 88 | * less accurate, but we can't help that ...). |
| 89 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 90 | if ( !IsBadReadPtr( (LPVOID)dwExtraInfo, sizeof(WINE_KEYBDEVENT) ) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 91 | && ((WINE_KEYBDEVENT *)dwExtraInfo)->magic == WINE_KEYBDEVENT_MAGIC ) |
| 92 | { |
| 93 | WINE_KEYBDEVENT *wke = (WINE_KEYBDEVENT *)dwExtraInfo; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 94 | time = wke->time; |
| 95 | extra = 0; |
| 96 | } |
| 97 | else |
| 98 | { |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 99 | time = GetTickCount(); |
| 100 | extra = dwExtraInfo; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | |
| 104 | keylp.lp1.count = 1; |
| 105 | keylp.lp1.code = bScan; |
| 106 | keylp.lp1.extended = (dwFlags & KEYEVENTF_EXTENDEDKEY) != 0; |
| 107 | keylp.lp1.win_internal = 0; /* this has something to do with dialogs, |
| 108 | * don't remember where I read it - AK */ |
| 109 | /* it's '1' under windows, when a dialog box appears |
| 110 | * and you press one of the underlined keys - DF*/ |
| 111 | |
| 112 | if ( dwFlags & KEYEVENTF_KEYUP ) |
| 113 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 114 | BOOL sysKey = (InputKeyStateTable[VK_MENU] & 0x80) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 115 | && !(InputKeyStateTable[VK_CONTROL] & 0x80) |
| 116 | && !(dwFlags & KEYEVENTF_WINE_FORCEEXTENDED); /* for Alt from AltGr */ |
| 117 | |
| 118 | InputKeyStateTable[bVk] &= ~0x80; |
| 119 | keylp.lp1.previous = 1; |
| 120 | keylp.lp1.transition = 1; |
| 121 | message = sysKey ? WM_SYSKEYUP : WM_KEYUP; |
| 122 | } |
| 123 | else |
| 124 | { |
| 125 | keylp.lp1.previous = (InputKeyStateTable[bVk] & 0x80) != 0; |
| 126 | keylp.lp1.transition = 0; |
| 127 | |
| 128 | if (!(InputKeyStateTable[bVk] & 0x80)) |
| 129 | InputKeyStateTable[bVk] ^= 0x01; |
| 130 | InputKeyStateTable[bVk] |= 0x80; |
| 131 | |
| 132 | message = (InputKeyStateTable[VK_MENU] & 0x80) |
| 133 | && !(InputKeyStateTable[VK_CONTROL] & 0x80) |
| 134 | ? WM_SYSKEYDOWN : WM_KEYDOWN; |
| 135 | } |
| 136 | |
| 137 | if ( message == WM_SYSKEYDOWN || message == WM_SYSKEYUP ) |
| 138 | keylp.lp1.context = (InputKeyStateTable[VK_MENU] & 0x80) != 0; /* 1 if alt */ |
| 139 | |
| 140 | |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 141 | TRACE_(key)(" wParam=%04X, lParam=%08lX\n", bVk, keylp.lp2 ); |
| 142 | TRACE_(key)(" InputKeyState=%X\n", InputKeyStateTable[bVk] ); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 143 | |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 144 | hardware_event( message, bVk, keylp.lp2, PosX, PosY, time, extra ); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | /*********************************************************************** |
Ulrich Weigand | 24dd5d9 | 1999-09-20 18:49:02 +0000 | [diff] [blame] | 148 | * WIN16_keybd_event (USER.289) |
| 149 | */ |
| 150 | void WINAPI WIN16_keybd_event( CONTEXT86 *context ) |
| 151 | { |
| 152 | DWORD dwFlags = 0; |
| 153 | |
| 154 | if (AH_reg(context) & 0x80) dwFlags |= KEYEVENTF_KEYUP; |
| 155 | if (BH_reg(context) & 1 ) dwFlags |= KEYEVENTF_EXTENDEDKEY; |
| 156 | |
| 157 | keybd_event( AL_reg(context), BL_reg(context), |
| 158 | dwFlags, MAKELONG(SI_reg(context), DI_reg(context)) ); |
| 159 | } |
| 160 | |
| 161 | /*********************************************************************** |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 162 | * mouse_event (USER32.584) |
| 163 | */ |
| 164 | void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy, |
| 165 | DWORD cButtons, DWORD dwExtraInfo ) |
| 166 | { |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 167 | DWORD time, extra; |
| 168 | DWORD keyState; |
| 169 | |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 170 | if (!InputEnabled) return; |
| 171 | |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 172 | if ( dwFlags & MOUSEEVENTF_MOVE ) |
| 173 | { |
| 174 | if ( dwFlags & MOUSEEVENTF_ABSOLUTE ) |
| 175 | { |
| 176 | PosX = (dx * GetSystemMetrics(SM_CXSCREEN)) >> 16; |
| 177 | PosY = (dy * GetSystemMetrics(SM_CYSCREEN)) >> 16; |
| 178 | } |
| 179 | else |
| 180 | { |
| 181 | int width = GetSystemMetrics(SM_CXSCREEN); |
| 182 | int height = GetSystemMetrics(SM_CYSCREEN); |
| 183 | long posX = (long) PosX, posY = (long) PosY; |
| 184 | |
| 185 | /* dx and dy can be negative numbers for relative movements */ |
| 186 | posX += (long) dx; |
| 187 | posY += (long) dy; |
| 188 | |
| 189 | /* Clip to the current screen size */ |
| 190 | if (posX < 0) PosX = 0; |
| 191 | else if (posX >= width) PosX = width - 1; |
| 192 | else PosX = posX; |
| 193 | |
| 194 | if (posY < 0) PosY = 0; |
| 195 | else if (posY >= height) PosY = height - 1; |
| 196 | else PosY = posY; |
| 197 | } |
| 198 | } |
| 199 | |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 200 | /* |
| 201 | * If we are called by the Wine mouse driver, use the additional |
| 202 | * info pointed to by the dwExtraInfo argument. |
| 203 | * Otherwise, we need to determine that info ourselves (probably |
| 204 | * less accurate, but we can't help that ...). |
| 205 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 206 | if ( !IsBadReadPtr( (LPVOID)dwExtraInfo, sizeof(WINE_MOUSEEVENT) ) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 207 | && ((WINE_MOUSEEVENT *)dwExtraInfo)->magic == WINE_MOUSEEVENT_MAGIC ) |
| 208 | { |
| 209 | WINE_MOUSEEVENT *wme = (WINE_MOUSEEVENT *)dwExtraInfo; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 210 | time = wme->time; |
| 211 | extra = (DWORD)wme->hWnd; |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 212 | keyState = wme->keyState; |
| 213 | |
| 214 | if (keyState != GET_KEYSTATE()) { |
| 215 | /* We need to update the keystate with what X provides us */ |
| 216 | MouseButtonsStates[SwappedButtons ? 2 : 0] = (keyState & MK_LBUTTON ? TRUE : FALSE); |
| 217 | MouseButtonsStates[SwappedButtons ? 0 : 2] = (keyState & MK_RBUTTON ? TRUE : FALSE); |
| 218 | MouseButtonsStates[1] = (keyState & MK_MBUTTON ? TRUE : FALSE); |
| 219 | InputKeyStateTable[VK_SHIFT] = (keyState & MK_SHIFT ? 0x80 : 0); |
| 220 | InputKeyStateTable[VK_CONTROL] = (keyState & MK_CONTROL ? 0x80 : 0); |
| 221 | } |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 222 | } |
| 223 | else |
| 224 | { |
| 225 | time = GetTickCount(); |
| 226 | extra = dwExtraInfo; |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 227 | keyState = GET_KEYSTATE(); |
| 228 | |
| 229 | if ( dwFlags & MOUSEEVENTF_MOVE ) |
| 230 | { |
| 231 | /* We have to actually move the cursor */ |
| 232 | SetCursorPos( PosX, PosY ); |
| 233 | } |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 234 | } |
| 235 | |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 236 | |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 237 | if ( dwFlags & MOUSEEVENTF_MOVE ) |
| 238 | { |
| 239 | hardware_event( WM_MOUSEMOVE, |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 240 | keyState, 0L, PosX, PosY, time, extra ); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 241 | } |
| 242 | if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_RIGHTDOWN) ) |
| 243 | { |
| 244 | MouseButtonsStates[0] = AsyncMouseButtonsStates[0] = TRUE; |
| 245 | hardware_event( WM_LBUTTONDOWN, |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 246 | keyState, 0L, PosX, PosY, time, extra ); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 247 | } |
| 248 | if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_RIGHTUP) ) |
| 249 | { |
| 250 | MouseButtonsStates[0] = FALSE; |
| 251 | hardware_event( WM_LBUTTONUP, |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 252 | keyState, 0L, PosX, PosY, time, extra ); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 253 | } |
| 254 | if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_LEFTDOWN) ) |
| 255 | { |
| 256 | MouseButtonsStates[2] = AsyncMouseButtonsStates[2] = TRUE; |
| 257 | hardware_event( WM_RBUTTONDOWN, |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 258 | keyState, 0L, PosX, PosY, time, extra ); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 259 | } |
| 260 | if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_RIGHTUP : MOUSEEVENTF_LEFTUP) ) |
| 261 | { |
| 262 | MouseButtonsStates[2] = FALSE; |
| 263 | hardware_event( WM_RBUTTONUP, |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 264 | keyState, 0L, PosX, PosY, time, extra ); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 265 | } |
| 266 | if ( dwFlags & MOUSEEVENTF_MIDDLEDOWN ) |
| 267 | { |
| 268 | MouseButtonsStates[1] = AsyncMouseButtonsStates[1] = TRUE; |
| 269 | hardware_event( WM_MBUTTONDOWN, |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 270 | keyState, 0L, PosX, PosY, time, extra ); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 271 | } |
| 272 | if ( dwFlags & MOUSEEVENTF_MIDDLEUP ) |
| 273 | { |
| 274 | MouseButtonsStates[1] = FALSE; |
| 275 | hardware_event( WM_MBUTTONUP, |
Lionel Ulmer | acc7467 | 1999-11-07 21:25:57 +0000 | [diff] [blame] | 276 | keyState, 0L, PosX, PosY, time, extra ); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 277 | } |
Stephane Lussier | 4bdf4af | 2000-04-18 11:56:33 +0000 | [diff] [blame] | 278 | if ( dwFlags & MOUSEEVENTF_WHEEL ) |
| 279 | { |
| 280 | hardware_event( WM_MOUSEWHEEL, |
| 281 | keyState, 0L, PosX, PosY, time, extra ); |
| 282 | } |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 283 | } |
| 284 | |
Ulrich Weigand | 24dd5d9 | 1999-09-20 18:49:02 +0000 | [diff] [blame] | 285 | /*********************************************************************** |
| 286 | * WIN16_mouse_event (USER.299) |
| 287 | */ |
| 288 | void WINAPI WIN16_mouse_event( CONTEXT86 *context ) |
| 289 | { |
| 290 | mouse_event( AX_reg(context), BX_reg(context), CX_reg(context), |
| 291 | DX_reg(context), MAKELONG(SI_reg(context), DI_reg(context)) ); |
| 292 | } |
| 293 | |
| 294 | /*********************************************************************** |
| 295 | * GetMouseEventProc (USER.337) |
| 296 | */ |
| 297 | FARPROC16 WINAPI GetMouseEventProc16(void) |
| 298 | { |
| 299 | HMODULE16 hmodule = GetModuleHandle16("USER"); |
| 300 | return NE_GetEntryPoint( hmodule, NE_GetOrdinal( hmodule, "mouse_event" )); |
| 301 | } |
| 302 | |
| 303 | |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 304 | /********************************************************************** |
| 305 | * EnableHardwareInput (USER.331) |
| 306 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 307 | BOOL16 WINAPI EnableHardwareInput16(BOOL16 bEnable) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 308 | { |
| 309 | BOOL16 bOldState = InputEnabled; |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 310 | FIXME_(event)("(%d) - stub\n", bEnable); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 311 | InputEnabled = bEnable; |
| 312 | return bOldState; |
| 313 | } |
| 314 | |
| 315 | |
| 316 | /*********************************************************************** |
| 317 | * SwapMouseButton16 (USER.186) |
| 318 | */ |
| 319 | BOOL16 WINAPI SwapMouseButton16( BOOL16 fSwap ) |
| 320 | { |
| 321 | BOOL16 ret = SwappedButtons; |
| 322 | SwappedButtons = fSwap; |
| 323 | return ret; |
| 324 | } |
| 325 | |
| 326 | |
| 327 | /*********************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 328 | * SwapMouseButton (USER32.537) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 329 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 330 | BOOL WINAPI SwapMouseButton( BOOL fSwap ) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 331 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 332 | BOOL ret = SwappedButtons; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 333 | SwappedButtons = fSwap; |
| 334 | return ret; |
| 335 | } |
| 336 | |
| 337 | /********************************************************************** |
| 338 | * EVENT_Capture |
| 339 | * |
| 340 | * We need this to be able to generate double click messages |
| 341 | * when menu code captures mouse in the window without CS_DBLCLK style. |
| 342 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 343 | HWND EVENT_Capture(HWND hwnd, INT16 ht) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 344 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 345 | HWND capturePrev = 0, captureWnd = 0; |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 346 | MESSAGEQUEUE *pMsgQ = 0, *pCurMsgQ = 0; |
| 347 | WND* wndPtr = 0; |
| 348 | INT16 captureHT = 0; |
| 349 | |
| 350 | /* Get the messageQ for the current thread */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 351 | if (!(pCurMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() ))) |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 352 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 353 | WARN_(win)("\tCurrent message queue not found. Exiting!\n" ); |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 354 | goto CLEANUP; |
| 355 | } |
| 356 | |
| 357 | /* Get the current capture window from the perQ data of the current message Q */ |
| 358 | capturePrev = PERQDATA_GetCaptureWnd( pCurMsgQ->pQData ); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 359 | |
| 360 | if (!hwnd) |
| 361 | { |
| 362 | captureWnd = 0L; |
| 363 | captureHT = 0; |
| 364 | } |
| 365 | else |
| 366 | { |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 367 | wndPtr = WIN_FindWndPtr( hwnd ); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 368 | if (wndPtr) |
| 369 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 370 | TRACE_(win)("(0x%04x)\n", hwnd ); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 371 | captureWnd = hwnd; |
| 372 | captureHT = ht; |
| 373 | } |
| 374 | } |
| 375 | |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 376 | /* Update the perQ capture window and send messages */ |
| 377 | if( capturePrev != captureWnd ) |
| 378 | { |
| 379 | if (wndPtr) |
| 380 | { |
| 381 | /* Retrieve the message queue associated with this window */ |
| 382 | pMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( wndPtr->hmemTaskQ ); |
| 383 | if ( !pMsgQ ) |
| 384 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 385 | WARN_(win)("\tMessage queue not found. Exiting!\n" ); |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 386 | goto CLEANUP; |
| 387 | } |
| 388 | |
| 389 | /* Make sure that message queue for the window we are setting capture to |
| 390 | * shares the same perQ data as the current threads message queue. |
| 391 | */ |
| 392 | if ( pCurMsgQ->pQData != pMsgQ->pQData ) |
| 393 | goto CLEANUP; |
| 394 | } |
| 395 | |
| 396 | PERQDATA_SetCaptureWnd( pCurMsgQ->pQData, captureWnd ); |
| 397 | PERQDATA_SetCaptureInfo( pCurMsgQ->pQData, captureHT ); |
| 398 | |
| 399 | if( capturePrev ) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 400 | { |
| 401 | WND* wndPtr = WIN_FindWndPtr( capturePrev ); |
| 402 | if( wndPtr && (wndPtr->flags & WIN_ISWIN32) ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 403 | SendMessageA( capturePrev, WM_CAPTURECHANGED, 0L, hwnd); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 404 | WIN_ReleaseWndPtr(wndPtr); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 405 | } |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | CLEANUP: |
| 409 | /* Unlock the queues before returning */ |
| 410 | if ( pMsgQ ) |
| 411 | QUEUE_Unlock( pMsgQ ); |
| 412 | if ( pCurMsgQ ) |
| 413 | QUEUE_Unlock( pCurMsgQ ); |
| 414 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 415 | WIN_ReleaseWndPtr(wndPtr); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 416 | return capturePrev; |
| 417 | } |
| 418 | |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 419 | |
| 420 | /********************************************************************** |
| 421 | * SetCapture16 (USER.18) |
| 422 | */ |
| 423 | HWND16 WINAPI SetCapture16( HWND16 hwnd ) |
| 424 | { |
| 425 | return (HWND16)EVENT_Capture( hwnd, HTCLIENT ); |
| 426 | } |
| 427 | |
| 428 | |
| 429 | /********************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 430 | * SetCapture (USER32.464) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 431 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 432 | HWND WINAPI SetCapture( HWND hwnd ) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 433 | { |
| 434 | return EVENT_Capture( hwnd, HTCLIENT ); |
| 435 | } |
| 436 | |
| 437 | |
| 438 | /********************************************************************** |
| 439 | * ReleaseCapture (USER.19) (USER32.439) |
| 440 | */ |
Zygo Blaxell | 007f133 | 1999-04-15 16:40:16 +0000 | [diff] [blame] | 441 | BOOL WINAPI ReleaseCapture(void) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 442 | { |
Zygo Blaxell | 007f133 | 1999-04-15 16:40:16 +0000 | [diff] [blame] | 443 | return (EVENT_Capture( 0, 0 ) != 0); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | |
| 447 | /********************************************************************** |
| 448 | * GetCapture16 (USER.236) |
| 449 | */ |
| 450 | HWND16 WINAPI GetCapture16(void) |
| 451 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 452 | return (HWND16)GetCapture(); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | /********************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 456 | * GetCapture (USER32.208) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 457 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 458 | HWND WINAPI GetCapture(void) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 459 | { |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 460 | MESSAGEQUEUE *pCurMsgQ = 0; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 461 | HWND hwndCapture = 0; |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 462 | |
| 463 | /* Get the messageQ for the current thread */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 464 | if (!(pCurMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() ))) |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 465 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 466 | TRACE_(win)("GetCapture32: Current message queue not found. Exiting!\n" ); |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 467 | return 0; |
| 468 | } |
| 469 | |
| 470 | /* Get the current capture window from the perQ data of the current message Q */ |
| 471 | hwndCapture = PERQDATA_GetCaptureWnd( pCurMsgQ->pQData ); |
| 472 | |
| 473 | QUEUE_Unlock( pCurMsgQ ); |
| 474 | return hwndCapture; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | /********************************************************************** |
| 478 | * GetKeyState (USER.106) |
| 479 | */ |
Uwe Bonnes | 9fdceb8 | 1998-11-08 13:12:49 +0000 | [diff] [blame] | 480 | INT16 WINAPI GetKeyState16(INT16 vkey) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 481 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 482 | return GetKeyState(vkey); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 483 | } |
| 484 | |
| 485 | /********************************************************************** |
| 486 | * GetKeyState (USER32.249) |
| 487 | * |
| 488 | * An application calls the GetKeyState function in response to a |
| 489 | * keyboard-input message. This function retrieves the state of the key |
| 490 | * at the time the input message was generated. (SDK 3.1 Vol 2. p 390) |
| 491 | */ |
Patrik Stridvall | 8276f69 | 1999-09-23 11:48:02 +0000 | [diff] [blame] | 492 | SHORT WINAPI GetKeyState(INT vkey) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 493 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 494 | INT retval; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 495 | |
| 496 | switch (vkey) |
| 497 | { |
| 498 | case VK_LBUTTON : /* VK_LBUTTON is 1 */ |
| 499 | retval = MouseButtonsStates[0] ? 0x8000 : 0; |
| 500 | break; |
| 501 | case VK_MBUTTON : /* VK_MBUTTON is 4 */ |
| 502 | retval = MouseButtonsStates[1] ? 0x8000 : 0; |
| 503 | break; |
| 504 | case VK_RBUTTON : /* VK_RBUTTON is 2 */ |
| 505 | retval = MouseButtonsStates[2] ? 0x8000 : 0; |
| 506 | break; |
| 507 | default : |
| 508 | if (vkey >= 'a' && vkey <= 'z') |
| 509 | vkey += 'A' - 'a'; |
| 510 | retval = ( (WORD)(QueueKeyStateTable[vkey] & 0x80) << 8 ) | |
| 511 | (WORD)(QueueKeyStateTable[vkey] & 0x01); |
| 512 | } |
| 513 | /* TRACE(key, "(0x%x) -> %x\n", vkey, retval); */ |
| 514 | return retval; |
| 515 | } |
| 516 | |
| 517 | /********************************************************************** |
| 518 | * GetKeyboardState (USER.222)(USER32.254) |
| 519 | * |
| 520 | * An application calls the GetKeyboardState function in response to a |
| 521 | * keyboard-input message. This function retrieves the state of the keyboard |
| 522 | * at the time the input message was generated. (SDK 3.1 Vol 2. p 387) |
| 523 | */ |
Francis Beaudet | ee3c1d7 | 1999-05-08 09:35:37 +0000 | [diff] [blame] | 524 | BOOL WINAPI GetKeyboardState(LPBYTE lpKeyState) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 525 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 526 | TRACE_(key)("(%p)\n", lpKeyState); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 527 | if (lpKeyState != NULL) { |
| 528 | QueueKeyStateTable[VK_LBUTTON] = MouseButtonsStates[0] ? 0x80 : 0; |
| 529 | QueueKeyStateTable[VK_MBUTTON] = MouseButtonsStates[1] ? 0x80 : 0; |
| 530 | QueueKeyStateTable[VK_RBUTTON] = MouseButtonsStates[2] ? 0x80 : 0; |
| 531 | memcpy(lpKeyState, QueueKeyStateTable, 256); |
| 532 | } |
Francis Beaudet | ee3c1d7 | 1999-05-08 09:35:37 +0000 | [diff] [blame] | 533 | |
| 534 | return TRUE; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | /********************************************************************** |
| 538 | * SetKeyboardState (USER.223)(USER32.484) |
| 539 | */ |
Francis Beaudet | ee3c1d7 | 1999-05-08 09:35:37 +0000 | [diff] [blame] | 540 | BOOL WINAPI SetKeyboardState(LPBYTE lpKeyState) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 541 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 542 | TRACE_(key)("(%p)\n", lpKeyState); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 543 | if (lpKeyState != NULL) { |
| 544 | memcpy(QueueKeyStateTable, lpKeyState, 256); |
| 545 | MouseButtonsStates[0] = (QueueKeyStateTable[VK_LBUTTON] != 0); |
| 546 | MouseButtonsStates[1] = (QueueKeyStateTable[VK_MBUTTON] != 0); |
| 547 | MouseButtonsStates[2] = (QueueKeyStateTable[VK_RBUTTON] != 0); |
| 548 | } |
Francis Beaudet | ee3c1d7 | 1999-05-08 09:35:37 +0000 | [diff] [blame] | 549 | |
| 550 | return TRUE; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | /********************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 554 | * GetAsyncKeyState (USER32.207) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 555 | * |
| 556 | * Determine if a key is or was pressed. retval has high-order |
| 557 | * bit set to 1 if currently pressed, low-order bit set to 1 if key has |
| 558 | * been pressed. |
| 559 | * |
| 560 | * This uses the variable AsyncMouseButtonsStates and |
| 561 | * AsyncKeyStateTable (set in event.c) which have the mouse button |
| 562 | * number or key number (whichever is applicable) set to true if the |
| 563 | * mouse or key had been depressed since the last call to |
| 564 | * GetAsyncKeyState. |
| 565 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 566 | WORD WINAPI GetAsyncKeyState(INT nKey) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 567 | { |
| 568 | short retval; |
| 569 | |
| 570 | switch (nKey) { |
| 571 | case VK_LBUTTON: |
| 572 | retval = (AsyncMouseButtonsStates[0] ? 0x0001 : 0) | |
| 573 | (MouseButtonsStates[0] ? 0x8000 : 0); |
| 574 | break; |
| 575 | case VK_MBUTTON: |
| 576 | retval = (AsyncMouseButtonsStates[1] ? 0x0001 : 0) | |
| 577 | (MouseButtonsStates[1] ? 0x8000 : 0); |
| 578 | break; |
| 579 | case VK_RBUTTON: |
| 580 | retval = (AsyncMouseButtonsStates[2] ? 0x0001 : 0) | |
| 581 | (MouseButtonsStates[2] ? 0x8000 : 0); |
| 582 | break; |
| 583 | default: |
| 584 | retval = AsyncKeyStateTable[nKey] | |
| 585 | ((InputKeyStateTable[nKey] & 0x80) ? 0x8000 : 0); |
| 586 | break; |
| 587 | } |
| 588 | |
| 589 | /* all states to false */ |
| 590 | memset( AsyncMouseButtonsStates, 0, sizeof(AsyncMouseButtonsStates) ); |
| 591 | memset( AsyncKeyStateTable, 0, sizeof(AsyncKeyStateTable) ); |
| 592 | |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 593 | TRACE_(key)("(%x) -> %x\n", nKey, retval); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 594 | return retval; |
| 595 | } |
| 596 | |
| 597 | /********************************************************************** |
| 598 | * GetAsyncKeyState16 (USER.249) |
| 599 | */ |
| 600 | WORD WINAPI GetAsyncKeyState16(INT16 nKey) |
| 601 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 602 | return GetAsyncKeyState(nKey); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 603 | } |
| 604 | |
Ulrich Weigand | 5cd4737 | 1999-05-22 19:00:27 +0000 | [diff] [blame] | 605 | /*********************************************************************** |
| 606 | * IsUserIdle (USER.333) |
| 607 | */ |
| 608 | BOOL16 WINAPI IsUserIdle16(void) |
| 609 | { |
| 610 | if ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 ) |
| 611 | return FALSE; |
| 612 | |
| 613 | if ( GetAsyncKeyState( VK_RBUTTON ) & 0x8000 ) |
| 614 | return FALSE; |
| 615 | |
| 616 | if ( GetAsyncKeyState( VK_MBUTTON ) & 0x8000 ) |
| 617 | return FALSE; |
| 618 | |
| 619 | /* Should check for screen saver activation here ... */ |
| 620 | |
| 621 | return TRUE; |
| 622 | } |
| 623 | |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 624 | /********************************************************************** |
| 625 | * KBD_translate_accelerator |
| 626 | * |
| 627 | * FIXME: should send some WM_INITMENU or/and WM_INITMENUPOPUP -messages |
| 628 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 629 | static BOOL KBD_translate_accelerator(HWND hWnd,LPMSG msg, |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 630 | BYTE fVirt,WORD key,WORD cmd) |
| 631 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 632 | BOOL sendmsg = FALSE; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 633 | |
| 634 | if(msg->wParam == key) |
| 635 | { |
| 636 | if (msg->message == WM_CHAR) { |
| 637 | if ( !(fVirt & FALT) && !(fVirt & FVIRTKEY) ) |
| 638 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 639 | TRACE_(accel)("found accel for WM_CHAR: ('%c')\n", |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 640 | msg->wParam&0xff); |
| 641 | sendmsg=TRUE; |
| 642 | } |
| 643 | } else { |
| 644 | if(fVirt & FVIRTKEY) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 645 | INT mask = 0; |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 646 | TRACE_(accel)("found accel for virt_key %04x (scan %04x)\n", |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 647 | msg->wParam,0xff & HIWORD(msg->lParam)); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 648 | if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT; |
| 649 | if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL; |
| 650 | if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 651 | if(mask == (fVirt & (FSHIFT | FCONTROL | FALT))) |
| 652 | sendmsg=TRUE; |
| 653 | else |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 654 | TRACE_(accel)(", but incorrect SHIFT/CTRL/ALT-state\n"); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 655 | } |
| 656 | else |
| 657 | { |
| 658 | if (!(msg->lParam & 0x01000000)) /* no special_key */ |
| 659 | { |
| 660 | if ((fVirt & FALT) && (msg->lParam & 0x20000000)) |
| 661 | { /* ^^ ALT pressed */ |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 662 | TRACE_(accel)("found accel for Alt-%c\n", msg->wParam&0xff); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 663 | sendmsg=TRUE; |
| 664 | } |
| 665 | } |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | if (sendmsg) /* found an accelerator, but send a message... ? */ |
| 670 | { |
| 671 | INT16 iSysStat,iStat,mesg=0; |
| 672 | HMENU16 hMenu; |
| 673 | |
| 674 | if (msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP) |
| 675 | mesg=1; |
| 676 | else |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 677 | if (GetCapture()) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 678 | mesg=2; |
| 679 | else |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 680 | if (!IsWindowEnabled(hWnd)) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 681 | mesg=3; |
| 682 | else |
| 683 | { |
| 684 | WND* wndPtr = WIN_FindWndPtr(hWnd); |
| 685 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 686 | hMenu = (wndPtr->dwStyle & WS_CHILD) ? 0 : (HMENU)wndPtr->wIDmenu; |
| 687 | iSysStat = (wndPtr->hSysMenu) ? GetMenuState(GetSubMenu16(wndPtr->hSysMenu, 0), |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 688 | cmd, MF_BYCOMMAND) : -1 ; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 689 | iStat = (hMenu) ? GetMenuState(hMenu, |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 690 | cmd, MF_BYCOMMAND) : -1 ; |
| 691 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 692 | WIN_ReleaseWndPtr(wndPtr); |
| 693 | |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 694 | if (iSysStat!=-1) |
| 695 | { |
| 696 | if (iSysStat & (MF_DISABLED|MF_GRAYED)) |
| 697 | mesg=4; |
| 698 | else |
| 699 | mesg=WM_SYSCOMMAND; |
| 700 | } |
| 701 | else |
| 702 | { |
| 703 | if (iStat!=-1) |
| 704 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 705 | if (IsIconic(hWnd)) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 706 | mesg=5; |
| 707 | else |
| 708 | { |
| 709 | if (iStat & (MF_DISABLED|MF_GRAYED)) |
| 710 | mesg=6; |
| 711 | else |
| 712 | mesg=WM_COMMAND; |
| 713 | } |
| 714 | } |
| 715 | else |
| 716 | mesg=WM_COMMAND; |
| 717 | } |
| 718 | } |
Rein Klazes | c18f629 | 2000-03-24 19:46:13 +0000 | [diff] [blame] | 719 | if( mesg==WM_COMMAND ) { |
| 720 | TRACE_(accel)(", sending WM_COMMAND, wParam=%0x\n", 0x10000 | cmd); |
| 721 | SendMessageA(hWnd, mesg, 0x10000 | cmd, 0L); |
| 722 | } else if( mesg==WM_SYSCOMMAND ) { |
| 723 | TRACE_(accel)(", sending WM_SYSCOMMAND, wParam=%0x\n", cmd); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 724 | SendMessageA(hWnd, mesg, cmd, 0x00010000L); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 725 | } |
| 726 | else |
| 727 | { |
| 728 | /* some reasons for NOT sending the WM_{SYS}COMMAND message: |
| 729 | * #0: unknown (please report!) |
| 730 | * #1: for WM_KEYUP,WM_SYSKEYUP |
| 731 | * #2: mouse is captured |
| 732 | * #3: window is disabled |
| 733 | * #4: it's a disabled system menu option |
| 734 | * #5: it's a menu option, but window is iconic |
| 735 | * #6: it's a menu option, but disabled |
| 736 | */ |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 737 | TRACE_(accel)(", but won't send WM_{SYS}COMMAND, reason is #%d\n",mesg); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 738 | if(mesg==0) |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 739 | ERR_(accel)(" unknown reason - please report!"); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 740 | } |
| 741 | return TRUE; |
| 742 | } |
| 743 | } |
| 744 | return FALSE; |
| 745 | } |
| 746 | |
| 747 | /********************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 748 | * TranslateAccelerator (USER32.551)(USER32.552)(USER32.553) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 749 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 750 | INT WINAPI TranslateAccelerator(HWND hWnd, HACCEL hAccel, LPMSG msg) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 751 | { |
Marcus Meissner | 688c565 | 1999-01-22 17:09:46 +0000 | [diff] [blame] | 752 | /* YES, Accel16! */ |
Gerard Patel | 16c3cc2 | 1999-05-29 14:02:28 +0000 | [diff] [blame] | 753 | LPACCEL16 lpAccelTbl; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 754 | int i; |
| 755 | |
Gerard Patel | 16c3cc2 | 1999-05-29 14:02:28 +0000 | [diff] [blame] | 756 | if (msg == NULL) |
| 757 | { |
| 758 | WARN_(accel)("msg null; should hang here to be win compatible\n"); |
| 759 | return 0; |
| 760 | } |
| 761 | if (!hAccel || !(lpAccelTbl = (LPACCEL16) LockResource16(hAccel))) |
| 762 | { |
| 763 | WARN_(accel)("invalid accel handle=%x\n", hAccel); |
| 764 | return 0; |
| 765 | } |
| 766 | if ((msg->message != WM_KEYDOWN && |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 767 | msg->message != WM_KEYUP && |
| 768 | msg->message != WM_SYSKEYDOWN && |
| 769 | msg->message != WM_SYSKEYUP && |
Gerard Patel | 16c3cc2 | 1999-05-29 14:02:28 +0000 | [diff] [blame] | 770 | msg->message != WM_CHAR)) return 0; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 771 | |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 772 | TRACE_(accel)("TranslateAccelerators hAccel=%04x, hWnd=%04x," |
Gerard Patel | 16c3cc2 | 1999-05-29 14:02:28 +0000 | [diff] [blame] | 773 | "msg->hwnd=%04x, msg->message=%04x, wParam=%08x, lParam=%lx\n", |
| 774 | hAccel,hWnd,msg->hwnd,msg->message,msg->wParam,msg->lParam); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 775 | |
| 776 | i = 0; |
| 777 | do |
| 778 | { |
| 779 | if (KBD_translate_accelerator(hWnd,msg,lpAccelTbl[i].fVirt, |
| 780 | lpAccelTbl[i].key,lpAccelTbl[i].cmd)) |
| 781 | return 1; |
| 782 | } while ((lpAccelTbl[i++].fVirt & 0x80) == 0); |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 783 | WARN_(accel)("couldn't translate accelerator key\n"); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 784 | return 0; |
| 785 | } |
| 786 | |
| 787 | /********************************************************************** |
| 788 | * TranslateAccelerator16 (USER.178) |
| 789 | */ |
| 790 | INT16 WINAPI TranslateAccelerator16(HWND16 hWnd, HACCEL16 hAccel, LPMSG16 msg) |
| 791 | { |
Gerard Patel | 16c3cc2 | 1999-05-29 14:02:28 +0000 | [diff] [blame] | 792 | LPACCEL16 lpAccelTbl; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 793 | int i; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 794 | MSG msg32; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 795 | |
Gerard Patel | 16c3cc2 | 1999-05-29 14:02:28 +0000 | [diff] [blame] | 796 | if (msg == NULL) |
| 797 | { |
| 798 | WARN_(accel)("msg null; should hang here to be win compatible\n"); |
| 799 | return 0; |
| 800 | } |
| 801 | if (!hAccel || !(lpAccelTbl = (LPACCEL16) LockResource16(hAccel))) |
| 802 | { |
| 803 | WARN_(accel)("invalid accel handle=%x\n", hAccel); |
| 804 | return 0; |
| 805 | } |
| 806 | if ((msg->message != WM_KEYDOWN && |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 807 | msg->message != WM_KEYUP && |
| 808 | msg->message != WM_SYSKEYDOWN && |
| 809 | msg->message != WM_SYSKEYUP && |
Gerard Patel | 16c3cc2 | 1999-05-29 14:02:28 +0000 | [diff] [blame] | 810 | msg->message != WM_CHAR)) return 0; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 811 | |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 812 | TRACE_(accel)("TranslateAccelerators hAccel=%04x, hWnd=%04x,\ |
Gerard Patel | 16c3cc2 | 1999-05-29 14:02:28 +0000 | [diff] [blame] | 813 | msg->hwnd=%04x, msg->message=%04x, wParam=%04x, lParam=%lx\n", hAccel,hWnd,msg->hwnd,msg->message,msg->wParam,msg->lParam); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 814 | |
Gerard Patel | 16c3cc2 | 1999-05-29 14:02:28 +0000 | [diff] [blame] | 815 | STRUCT32_MSG16to32(msg,&msg32); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 816 | |
| 817 | i = 0; |
| 818 | do |
| 819 | { |
| 820 | if (KBD_translate_accelerator(hWnd,&msg32,lpAccelTbl[i].fVirt, |
| 821 | lpAccelTbl[i].key,lpAccelTbl[i].cmd)) |
| 822 | return 1; |
| 823 | } while ((lpAccelTbl[i++].fVirt & 0x80) == 0); |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 824 | WARN_(accel)("couldn't translate accelerator key\n"); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 825 | return 0; |
| 826 | } |
| 827 | |
| 828 | |
| 829 | /********************************************************************** |
| 830 | * VkKeyScanA (USER32.573) |
| 831 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 832 | WORD WINAPI VkKeyScanA(CHAR cChar) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 833 | { |
| 834 | return VkKeyScan16(cChar); |
| 835 | } |
| 836 | |
| 837 | /****************************************************************************** |
| 838 | * VkKeyScanW (USER32.576) |
| 839 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 840 | WORD WINAPI VkKeyScanW(WCHAR cChar) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 841 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 842 | return VkKeyScanA((CHAR)cChar); /* FIXME: check unicode */ |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 843 | } |
| 844 | |
Alexandre Julliard | f80b2ab | 1999-03-28 13:15:40 +0000 | [diff] [blame] | 845 | /********************************************************************** |
| 846 | * VkKeyScanExA (USER32.574) |
| 847 | */ |
| 848 | WORD WINAPI VkKeyScanExA(CHAR cChar, HKL dwhkl) |
| 849 | { |
| 850 | /* FIXME: complete workaround this is */ |
| 851 | return VkKeyScan16(cChar); |
| 852 | } |
| 853 | |
| 854 | /****************************************************************************** |
| 855 | * VkKeyScanExW (USER32.575) |
| 856 | */ |
| 857 | WORD WINAPI VkKeyScanExW(WCHAR cChar, HKL dwhkl) |
| 858 | { |
| 859 | /* FIXME: complete workaround this is */ |
| 860 | return VkKeyScanA((CHAR)cChar); /* FIXME: check unicode */ |
| 861 | } |
| 862 | |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 863 | /****************************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 864 | * GetKeyboardType (USER32.255) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 865 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 866 | INT WINAPI GetKeyboardType(INT nTypeFlag) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 867 | { |
| 868 | return GetKeyboardType16(nTypeFlag); |
| 869 | } |
| 870 | |
| 871 | /****************************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 872 | * MapVirtualKeyA (USER32.383) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 873 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 874 | UINT WINAPI MapVirtualKeyA(UINT code, UINT maptype) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 875 | { |
| 876 | return MapVirtualKey16(code,maptype); |
| 877 | } |
| 878 | |
| 879 | /****************************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 880 | * MapVirtualKeyW (USER32.385) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 881 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 882 | UINT WINAPI MapVirtualKeyW(UINT code, UINT maptype) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 883 | { |
| 884 | return MapVirtualKey16(code,maptype); |
| 885 | } |
| 886 | |
Marcus Meissner | 592c910 | 1999-02-13 08:53:22 +0000 | [diff] [blame] | 887 | /****************************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 888 | * MapVirtualKeyExA (USER32.384) |
Marcus Meissner | 592c910 | 1999-02-13 08:53:22 +0000 | [diff] [blame] | 889 | */ |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 890 | UINT WINAPI MapVirtualKeyExA(UINT code, UINT maptype, HKL hkl) |
Marcus Meissner | 592c910 | 1999-02-13 08:53:22 +0000 | [diff] [blame] | 891 | { |
| 892 | if (hkl) |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 893 | FIXME_(keyboard)("(%d,%d,0x%08lx), hkl unhandled!\n",code,maptype,(DWORD)hkl); |
Marcus Meissner | 592c910 | 1999-02-13 08:53:22 +0000 | [diff] [blame] | 894 | return MapVirtualKey16(code,maptype); |
| 895 | } |
| 896 | |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 897 | /**************************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 898 | * GetKBCodePage (USER32.246) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 899 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 900 | UINT WINAPI GetKBCodePage(void) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 901 | { |
| 902 | return GetKBCodePage16(); |
| 903 | } |
| 904 | |
| 905 | /**************************************************************************** |
Ulrich Weigand | 8bf078b | 1998-11-14 18:26:59 +0000 | [diff] [blame] | 906 | * GetKeyboardLayoutName16 (USER.477) |
| 907 | */ |
| 908 | INT16 WINAPI GetKeyboardLayoutName16(LPSTR pwszKLID) |
| 909 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 910 | return GetKeyboardLayoutNameA(pwszKLID); |
Ulrich Weigand | 8bf078b | 1998-11-14 18:26:59 +0000 | [diff] [blame] | 911 | } |
| 912 | |
Guy Albertelli | 38d9ce8 | 1999-02-28 11:13:16 +0000 | [diff] [blame] | 913 | /*********************************************************************** |
| 914 | * GetKeyboardLayout (USER32.250) |
| 915 | * |
| 916 | * FIXME: - device handle for keyboard layout defaulted to |
| 917 | * the language id. This is the way Windows default works. |
| 918 | * - the thread identifier (dwLayout) is also ignored. |
| 919 | */ |
| 920 | HKL WINAPI GetKeyboardLayout(DWORD dwLayout) |
| 921 | { |
| 922 | HKL layout; |
| 923 | layout = GetSystemDefaultLCID(); /* FIXME */ |
| 924 | layout |= (layout<<16); /* FIXME */ |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 925 | TRACE_(keyboard)("returning %08x\n",layout); |
Guy Albertelli | 38d9ce8 | 1999-02-28 11:13:16 +0000 | [diff] [blame] | 926 | return layout; |
| 927 | } |
| 928 | |
Ulrich Weigand | 8bf078b | 1998-11-14 18:26:59 +0000 | [diff] [blame] | 929 | /**************************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 930 | * GetKeyboardLayoutNameA (USER32.252) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 931 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 932 | INT WINAPI GetKeyboardLayoutNameA(LPSTR pwszKLID) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 933 | { |
Guy Albertelli | 38d9ce8 | 1999-02-28 11:13:16 +0000 | [diff] [blame] | 934 | sprintf(pwszKLID, "%08x",GetKeyboardLayout(0)); |
Ulrich Weigand | 8bf078b | 1998-11-14 18:26:59 +0000 | [diff] [blame] | 935 | return 1; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | /**************************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 939 | * GetKeyboardLayoutNameW (USER32.253) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 940 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 941 | INT WINAPI GetKeyboardLayoutNameW(LPWSTR pwszKLID) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 942 | { |
Dimitrie O. Paun | 4d48dd3 | 2000-04-30 12:22:18 +0000 | [diff] [blame] | 943 | char buf[9]; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 944 | int res = GetKeyboardLayoutNameA(buf); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 945 | lstrcpyAtoW(pwszKLID,buf); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 946 | return res; |
| 947 | } |
| 948 | |
| 949 | /**************************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 950 | * GetKeyNameTextA (USER32.247) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 951 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 952 | INT WINAPI GetKeyNameTextA(LONG lParam, LPSTR lpBuffer, INT nSize) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 953 | { |
| 954 | return GetKeyNameText16(lParam,lpBuffer,nSize); |
| 955 | } |
| 956 | |
| 957 | /**************************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 958 | * GetKeyNameTextW (USER32.248) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 959 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 960 | INT WINAPI GetKeyNameTextW(LONG lParam, LPWSTR lpBuffer, INT nSize) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 961 | { |
Dimitrie O. Paun | 4d48dd3 | 2000-04-30 12:22:18 +0000 | [diff] [blame] | 962 | int res; |
| 963 | LPSTR buf = HeapAlloc( GetProcessHeap(), 0, nSize ); |
| 964 | if(buf == NULL) return 0; /* FIXME: is this the correct failure value?*/ |
| 965 | res = GetKeyNameTextA(lParam,buf,nSize); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 966 | |
| 967 | lstrcpynAtoW(lpBuffer,buf,nSize); |
| 968 | HeapFree( GetProcessHeap(), 0, buf ); |
| 969 | return res; |
| 970 | } |
| 971 | |
| 972 | /**************************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 973 | * ToAscii (USER32.546) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 974 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 975 | INT WINAPI ToAscii( UINT virtKey,UINT scanCode,LPBYTE lpKeyState, |
| 976 | LPWORD lpChar,UINT flags ) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 977 | { |
| 978 | return ToAscii16(virtKey,scanCode,lpKeyState,lpChar,flags); |
| 979 | } |
| 980 | |
Alexandre Julliard | f80b2ab | 1999-03-28 13:15:40 +0000 | [diff] [blame] | 981 | /**************************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 982 | * ToAsciiEx (USER32.547) |
Alexandre Julliard | f80b2ab | 1999-03-28 13:15:40 +0000 | [diff] [blame] | 983 | */ |
| 984 | INT WINAPI ToAsciiEx( UINT virtKey, UINT scanCode, LPBYTE lpKeyState, |
| 985 | LPWORD lpChar, UINT flags, HKL dwhkl ) |
| 986 | { |
| 987 | /* FIXME: need true implementation */ |
| 988 | return ToAscii16(virtKey,scanCode,lpKeyState,lpChar,flags); |
| 989 | } |
| 990 | |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 991 | /********************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 992 | * ActivateKeyboardLayout (USER32.1) |
Guy Albertelli | 38d9ce8 | 1999-02-28 11:13:16 +0000 | [diff] [blame] | 993 | * |
| 994 | * Call ignored. WINE supports only system default keyboard layout. |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 995 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 996 | HKL WINAPI ActivateKeyboardLayout(HKL hLayout, UINT flags) |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 997 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 998 | TRACE_(keyboard)("(%d, %d)\n", hLayout, flags); |
| 999 | ERR_(keyboard)("Only default system keyboard layout supported. Call ignored.\n"); |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1000 | return 0; |
| 1001 | } |
| 1002 | |
| 1003 | |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 1004 | /*********************************************************************** |
| 1005 | * GetKeyboardLayoutList (USER32.251) |
Guy Albertelli | 38d9ce8 | 1999-02-28 11:13:16 +0000 | [diff] [blame] | 1006 | * |
| 1007 | * FIXME: Supports only the system default language and layout and |
| 1008 | * returns only 1 value. |
| 1009 | * |
| 1010 | * Return number of values available if either input parm is |
| 1011 | * 0, per MS documentation. |
| 1012 | * |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 1013 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1014 | INT WINAPI GetKeyboardLayoutList(INT nBuff,HKL *layouts) |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 1015 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 1016 | TRACE_(keyboard)("(%d,%p)\n",nBuff,layouts); |
Guy Albertelli | 38d9ce8 | 1999-02-28 11:13:16 +0000 | [diff] [blame] | 1017 | if (!nBuff || !layouts) |
| 1018 | return 1; |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 1019 | if (layouts) |
| 1020 | layouts[0] = GetKeyboardLayout(0); |
| 1021 | return 1; |
| 1022 | } |
| 1023 | |
| 1024 | |
| 1025 | /*********************************************************************** |
| 1026 | * RegisterHotKey (USER32.433) |
| 1027 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1028 | BOOL WINAPI RegisterHotKey(HWND hwnd,INT id,UINT modifiers,UINT vk) { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 1029 | FIXME_(keyboard)("(0x%08x,%d,0x%08x,%d): stub\n",hwnd,id,modifiers,vk); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 1030 | return TRUE; |
| 1031 | } |
| 1032 | |
| 1033 | /*********************************************************************** |
| 1034 | * UnregisterHotKey (USER32.565) |
| 1035 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1036 | BOOL WINAPI UnregisterHotKey(HWND hwnd,INT id) { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 1037 | FIXME_(keyboard)("(0x%08x,%d): stub\n",hwnd,id); |
Ulrich Weigand | 2b06758 | 1998-11-08 12:26:36 +0000 | [diff] [blame] | 1038 | return TRUE; |
| 1039 | } |
| 1040 | |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1041 | |
| 1042 | /*********************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 1043 | * ToUnicode (USER32.548) |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1044 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1045 | INT WINAPI ToUnicode( |
| 1046 | UINT wVirtKey, |
| 1047 | UINT wScanCode, |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1048 | PBYTE lpKeyState, |
| 1049 | LPWSTR pwszBuff, |
Patrik Stridvall | 8276f69 | 1999-09-23 11:48:02 +0000 | [diff] [blame] | 1050 | INT cchBuff, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1051 | UINT wFlags) { |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1052 | |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 1053 | FIXME_(keyboard)(": stub\n"); |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1054 | return 0; |
| 1055 | } |
| 1056 | |
| 1057 | /*********************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 1058 | * LoadKeyboardLayoutA (USER32.367) |
Guy Albertelli | 38d9ce8 | 1999-02-28 11:13:16 +0000 | [diff] [blame] | 1059 | * Call ignored. WINE supports only system default keyboard layout. |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1060 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1061 | HKL WINAPI LoadKeyboardLayoutA(LPCSTR pwszKLID, UINT Flags) |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1062 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 1063 | TRACE_(keyboard)("(%s, %d)\n", pwszKLID, Flags); |
| 1064 | ERR_(keyboard)("Only default system keyboard layout supported. Call ignored.\n"); |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1065 | return 0; |
| 1066 | } |
| 1067 | |
| 1068 | /*********************************************************************** |
Patrik Stridvall | 533d333 | 2000-03-28 19:31:18 +0000 | [diff] [blame] | 1069 | * LoadKeyboardLayoutW (USER32.368) |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1070 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1071 | HKL WINAPI LoadKeyboardLayoutW(LPCWSTR pwszKLID, UINT Flags) |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1072 | { |
Dimitrie O. Paun | 4d48dd3 | 2000-04-30 12:22:18 +0000 | [diff] [blame] | 1073 | char buf[9]; |
| 1074 | |
Guy Albertelli | 38d9ce8 | 1999-02-28 11:13:16 +0000 | [diff] [blame] | 1075 | lstrcpynWtoA(buf,pwszKLID,8); |
| 1076 | buf[8] = 0; |
Dimitrie O. Paun | 4d48dd3 | 2000-04-30 12:22:18 +0000 | [diff] [blame] | 1077 | return LoadKeyboardLayoutA(buf, Flags); |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1078 | } |