3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * PROJECT: ReactOS user32.dll
22 * FILE: lib/user32/windows/input.c
24 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
26 * 09-05-2001 CSH Created
29 /* INCLUDES ******************************************************************/
35 /* FUNCTIONS *****************************************************************/
47 return NtUserDragDetect(hWnd
, pt
.x
, pt
.y
);
55 ActivateKeyboardLayout(HKL hkl
,
67 BlockInput(BOOL fBlockIt
)
69 return NtUserBlockInput(fBlockIt
);
77 EnableWindow(HWND hWnd
,
80 LONG Style
= NtUserGetWindowLong(hWnd
, GWL_STYLE
, FALSE
);
81 Style
= bEnable
? Style
& ~WS_DISABLED
: Style
| WS_DISABLED
;
82 NtUserSetWindowLong(hWnd
, GWL_STYLE
, Style
, FALSE
);
84 SendMessageA(hWnd
, WM_ENABLE
, (LPARAM
) IsWindowEnabled(hWnd
), 0);
86 // Return nonzero if it was disabled, or zero if it wasn't:
87 return IsWindowEnabled(hWnd
);
95 GetAsyncKeyState(int vKey
)
107 GetDoubleClickTime(VOID
)
109 return NtUserGetDoubleClickTime();
117 GetKeyboardLayout(DWORD idThread
)
139 GetKeyNameTextA(LONG lParam
,
143 LPWSTR intermediateString
=
144 HeapAlloc(GetProcessHeap(),0,nSize
* sizeof(WCHAR
));
147 BOOL defChar
= FALSE
;
149 if( !intermediateString
) return 0;
150 ret
= GetKeyNameTextW(lParam
,intermediateString
,nSize
);
151 if( ret
== 0 ) { lpString
[0] = 0; return 0; }
153 wstrLen
= wcslen( intermediateString
);
154 ret
= WideCharToMultiByte(CP_ACP
, 0,
155 intermediateString
, wstrLen
,
156 lpString
, nSize
, ".", &defChar
);
158 HeapFree(GetProcessHeap(),0,intermediateString
);
167 GetKeyNameTextW(LONG lParam
,
171 return NtUserGetKeyNameText( lParam
, lpString
, nSize
);
179 GetKeyState(int nVirtKey
)
181 return (SHORT
) NtUserGetKeyState((DWORD
) nVirtKey
);
189 GetKeyboardLayoutList(int nBuff
,
201 GetKeyboardLayoutNameA(LPSTR pwszKLID
)
212 GetKeyboardLayoutNameW(LPWSTR pwszKLID
)
223 GetKeyboardState(PBYTE lpKeyState
)
226 return (BOOL
) NtUserGetKeyboardState((LPBYTE
) lpKeyState
);
234 GetKeyboardType(int nTypeFlag
)
245 GetLastInputInfo(PLASTINPUTINFO plii
)
256 LoadKeyboardLayoutA(LPCSTR pwszKLID
,
268 LoadKeyboardLayoutW(LPCWSTR pwszKLID
,
280 MapVirtualKeyA(UINT uCode
,
283 return MapVirtualKeyExA( uCode
, uMapType
, GetKeyboardLayout( 0 ) );
291 MapVirtualKeyExA(UINT uCode
,
295 return MapVirtualKeyExW( uCode
, uMapType
, dwhkl
);
303 MapVirtualKeyExW(UINT uCode
,
307 return NtUserMapVirtualKeyEx( uCode
, uMapType
, 0, dwhkl
);
315 MapVirtualKeyW(UINT uCode
,
318 return MapVirtualKeyExW( uCode
, uMapType
, GetKeyboardLayout( 0 ) );
326 OemKeyScan(WORD wOemChar
)
337 RegisterHotKey(HWND hWnd
,
342 return (BOOL
)NtUserRegisterHotKey(hWnd
,
353 SetDoubleClickTime(UINT uInterval
)
355 return (BOOL
)NtUserSystemParametersInfo(SPI_SETDOUBLECLICKTIME
,
368 return NtUserSetFocus(hWnd
);
376 SetKeyboardState(LPBYTE lpKeyState
)
378 return (BOOL
) NtUserSetKeyboardState((LPBYTE
)lpKeyState
);
390 return NtUserSwapMouseButton(fSwap
);
398 ToAscii(UINT uVirtKey
,
400 CONST PBYTE lpKeyState
,
404 return ToAsciiEx(uVirtKey
, uScanCode
, lpKeyState
, lpChar
, uFlags
, 0);
412 ToAsciiEx(UINT uVirtKey
,
414 CONST PBYTE lpKeyState
,
422 Ret
= ToUnicodeEx(uVirtKey
, uScanCode
, lpKeyState
, UniChars
, 2, uFlags
, dwhkl
);
423 CharCount
= (Ret
< 0 ? 1 : Ret
);
424 WideCharToMultiByte(CP_ACP
, 0, UniChars
, CharCount
, (LPSTR
) lpChar
, 2, NULL
, NULL
);
434 ToUnicode(UINT wVirtKey
,
436 CONST PBYTE lpKeyState
,
441 return ToUnicodeEx( wVirtKey
, wScanCode
, lpKeyState
, pwszBuff
, cchBuff
,
450 ToUnicodeEx(UINT wVirtKey
,
452 CONST PBYTE lpKeyState
,
458 return NtUserToUnicodeEx( wVirtKey
, wScanCode
, lpKeyState
, pwszBuff
, cchBuff
,
467 UnloadKeyboardLayout(HKL hkl
)
478 UnregisterHotKey(HWND hWnd
,
481 return (BOOL
)NtUserUnregisterHotKey(hWnd
, id
);
493 if (IsDBCSLeadByte(ch
)) return -1;
495 MultiByteToWideChar(CP_ACP
, 0, &ch
, 1, &wChar
, 1);
496 return VkKeyScanW(wChar
);
504 VkKeyScanExA(CHAR ch
,
509 if (IsDBCSLeadByte(ch
)) return -1;
511 MultiByteToWideChar(CP_ACP
, 0, &ch
, 1, &wChar
, 1);
512 return VkKeyScanExW(wChar
, dwhkl
);
520 VkKeyScanExW(WCHAR ch
,
534 return VkKeyScanExW(ch
, GetKeyboardLayout(0));
548 return NtUserSendInput(nInputs
, pInputs
, cbSize
);
552 * Private call for CSRSS
556 PrivateCsrssRegisterPrimitive(VOID
)
558 NtUserCallNoParam(NOPARAM_ROUTINE_REGISTER_PRIMITIVE
);
562 * Another private call for CSRSS
566 PrivateCsrssAcquireOrReleaseInputOwnership(BOOL Release
)
568 NtUserAcquireOrReleaseInputOwnership(Release
);
580 ULONG_PTR dwExtraInfo
)
586 Input
.type
= INPUT_KEYBOARD
;
588 Input
.ki
.wScan
= bScan
;
589 Input
.ki
.dwFlags
= dwFlags
;
591 Input
.ki
.dwExtraInfo
= dwExtraInfo
;
593 NtUserSendInput(1, &Input
, sizeof(INPUT
));
607 ULONG_PTR dwExtraInfo
)
611 Input
.type
= INPUT_MOUSE
;
614 Input
.mi
.mouseData
= dwData
;
615 Input
.mi
.dwFlags
= dwFlags
;
617 Input
.mi
.dwExtraInfo
= dwExtraInfo
;
619 NtUserSendInput(1, &Input
, sizeof(INPUT
));