1998-11-08 13:26:36 +01:00
|
|
|
/*
|
|
|
|
* USER Input processing
|
|
|
|
*
|
|
|
|
* Copyright 1993 Bob Amstadt
|
2002-06-01 01:06:46 +02:00
|
|
|
* Copyright 1996 Albrecht Kleine
|
1998-11-08 13:26:36 +01:00
|
|
|
* Copyright 1997 David Faure
|
|
|
|
* Copyright 1998 Morten Welinder
|
|
|
|
* Copyright 1998 Ulrich Weigand
|
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include <stdio.h>
|
1998-11-08 13:26:36 +01:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
2015-03-26 15:29:46 +01:00
|
|
|
|
2011-03-02 21:29:17 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
2000-12-19 05:53:20 +01:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "wingdi.h"
|
1999-02-22 11:16:00 +01:00
|
|
|
#include "winuser.h"
|
2003-08-20 20:22:31 +02:00
|
|
|
#include "winnls.h"
|
2002-11-18 20:47:20 +01:00
|
|
|
#include "winternl.h"
|
1998-11-08 13:26:36 +01:00
|
|
|
#include "winerror.h"
|
2006-07-24 14:13:53 +02:00
|
|
|
#include "win.h"
|
|
|
|
#include "user_private.h"
|
2020-05-26 22:01:35 +02:00
|
|
|
#include "dbt.h"
|
2006-07-24 14:13:53 +02:00
|
|
|
#include "wine/server.h"
|
|
|
|
#include "wine/debug.h"
|
1998-11-08 13:26:36 +01:00
|
|
|
|
2006-07-24 14:13:53 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(win);
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(keyboard);
|
1998-11-08 13:26:36 +01:00
|
|
|
|
2015-04-07 02:53:06 +02:00
|
|
|
INT global_key_state_counter = 0;
|
2001-06-19 21:16:41 +02:00
|
|
|
|
2001-10-18 23:38:59 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_key_state
|
|
|
|
*/
|
|
|
|
static WORD get_key_state(void)
|
|
|
|
{
|
|
|
|
WORD ret = 0;
|
|
|
|
|
2005-03-09 12:51:31 +01:00
|
|
|
if (GetSystemMetrics( SM_SWAPBUTTON ))
|
2001-10-18 23:38:59 +02:00
|
|
|
{
|
2005-03-09 17:45:23 +01:00
|
|
|
if (GetAsyncKeyState(VK_RBUTTON) & 0x80) ret |= MK_LBUTTON;
|
|
|
|
if (GetAsyncKeyState(VK_LBUTTON) & 0x80) ret |= MK_RBUTTON;
|
2001-10-18 23:38:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-03-09 17:45:23 +01:00
|
|
|
if (GetAsyncKeyState(VK_LBUTTON) & 0x80) ret |= MK_LBUTTON;
|
|
|
|
if (GetAsyncKeyState(VK_RBUTTON) & 0x80) ret |= MK_RBUTTON;
|
2001-10-18 23:38:59 +02:00
|
|
|
}
|
2005-03-09 17:45:23 +01:00
|
|
|
if (GetAsyncKeyState(VK_MBUTTON) & 0x80) ret |= MK_MBUTTON;
|
|
|
|
if (GetAsyncKeyState(VK_SHIFT) & 0x80) ret |= MK_SHIFT;
|
|
|
|
if (GetAsyncKeyState(VK_CONTROL) & 0x80) ret |= MK_CONTROL;
|
|
|
|
if (GetAsyncKeyState(VK_XBUTTON1) & 0x80) ret |= MK_XBUTTON1;
|
|
|
|
if (GetAsyncKeyState(VK_XBUTTON2) & 0x80) ret |= MK_XBUTTON2;
|
2001-10-18 23:38:59 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-30 10:43:58 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_locale_kbd_layout
|
|
|
|
*/
|
|
|
|
static HKL get_locale_kbd_layout(void)
|
|
|
|
{
|
|
|
|
ULONG_PTR layout;
|
|
|
|
LANGID langid;
|
|
|
|
|
|
|
|
/* FIXME:
|
|
|
|
*
|
|
|
|
* layout = main_key_tab[kbd_layout].lcid;
|
|
|
|
*
|
|
|
|
* Winword uses return value of GetKeyboardLayout as a codepage
|
|
|
|
* to translate ANSI keyboard messages to unicode. But we have
|
|
|
|
* a problem with it: for instance Polish keyboard layout is
|
|
|
|
* identical to the US one, and therefore instead of the Polish
|
|
|
|
* locale id we return the US one.
|
|
|
|
*/
|
|
|
|
|
|
|
|
layout = GetUserDefaultLCID();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Microsoft Office expects this value to be something specific
|
|
|
|
* for Japanese and Korean Windows with an IME the value is 0xe001
|
|
|
|
* We should probably check to see if an IME exists and if so then
|
|
|
|
* set this word properly.
|
|
|
|
*/
|
|
|
|
langid = PRIMARYLANGID( LANGIDFROMLCID( layout ) );
|
|
|
|
if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN)
|
|
|
|
layout = MAKELONG( layout, 0xe001 ); /* IME */
|
|
|
|
else
|
|
|
|
layout = MAKELONG( layout, layout );
|
|
|
|
|
|
|
|
return (HKL)layout;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-06 12:03:14 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* keyboard_init
|
|
|
|
*/
|
|
|
|
void keyboard_init(void)
|
|
|
|
{
|
|
|
|
WCHAR layout[KL_NAMELENGTH];
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
if (RegCreateKeyExW( HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", 0, NULL, 0,
|
|
|
|
KEY_ALL_ACCESS, NULL, &hkey, NULL ))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (GetKeyboardLayoutNameW( layout ))
|
|
|
|
RegSetValueExW( hkey, L"1", 0, REG_SZ, (const BYTE *)layout, sizeof(layout) );
|
|
|
|
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-12 14:54:03 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* set_capture_window
|
|
|
|
*/
|
|
|
|
BOOL set_capture_window( HWND hwnd, UINT gui_flags, HWND *prev_ret )
|
|
|
|
{
|
|
|
|
HWND previous = 0;
|
|
|
|
UINT flags = 0;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
if (gui_flags & GUI_INMENUMODE) flags |= CAPTURE_MENU;
|
|
|
|
if (gui_flags & GUI_INMOVESIZE) flags |= CAPTURE_MOVESIZE;
|
|
|
|
|
|
|
|
SERVER_START_REQ( set_capture_window )
|
|
|
|
{
|
2008-12-08 16:58:20 +01:00
|
|
|
req->handle = wine_server_user_handle( hwnd );
|
2008-03-12 14:54:03 +01:00
|
|
|
req->flags = flags;
|
|
|
|
if ((ret = !wine_server_call_err( req )))
|
|
|
|
{
|
2008-12-08 16:58:20 +01:00
|
|
|
previous = wine_server_ptr_handle( reply->previous );
|
|
|
|
hwnd = wine_server_ptr_handle( reply->full_handle );
|
2008-03-12 14:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
2010-01-11 21:47:43 +01:00
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
USER_Driver->pSetCapture( hwnd, gui_flags );
|
2008-03-12 14:55:28 +01:00
|
|
|
|
2016-02-01 05:32:51 +01:00
|
|
|
if (previous)
|
2010-01-11 21:47:43 +01:00
|
|
|
SendMessageW( previous, WM_CAPTURECHANGED, 0, (LPARAM)hwnd );
|
2008-03-12 14:54:03 +01:00
|
|
|
|
2010-01-11 21:47:43 +01:00
|
|
|
if (prev_ret) *prev_ret = previous;
|
|
|
|
}
|
2008-03-12 14:54:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-02 19:43:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* __wine_send_input (USER32.@)
|
|
|
|
*
|
|
|
|
* Internal SendInput function to allow the graphics driver to inject real events.
|
|
|
|
*/
|
2021-04-09 13:11:33 +02:00
|
|
|
BOOL CDECL __wine_send_input( HWND hwnd, const INPUT *input, const RAWINPUT *rawinput )
|
2011-03-02 19:43:53 +01:00
|
|
|
{
|
2021-04-09 13:11:33 +02:00
|
|
|
NTSTATUS status = send_hardware_message( hwnd, input, rawinput, 0 );
|
2011-03-02 19:43:53 +01:00
|
|
|
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return !status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-02 21:29:17 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* update_mouse_coords
|
|
|
|
*
|
|
|
|
* Helper for SendInput.
|
|
|
|
*/
|
|
|
|
static void update_mouse_coords( INPUT *input )
|
|
|
|
{
|
|
|
|
if (!(input->u.mi.dwFlags & MOUSEEVENTF_MOVE)) return;
|
|
|
|
|
|
|
|
if (input->u.mi.dwFlags & MOUSEEVENTF_ABSOLUTE)
|
|
|
|
{
|
2018-08-27 14:18:24 +02:00
|
|
|
DPI_AWARENESS_CONTEXT context = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
|
2021-05-18 11:11:25 +02:00
|
|
|
RECT rc;
|
|
|
|
|
2018-08-27 14:17:19 +02:00
|
|
|
if (input->u.mi.dwFlags & MOUSEEVENTF_VIRTUALDESK)
|
2021-05-18 11:11:25 +02:00
|
|
|
rc = get_virtual_screen_rect();
|
2018-08-27 14:17:19 +02:00
|
|
|
else
|
2021-05-18 11:11:25 +02:00
|
|
|
rc = get_primary_monitor_rect();
|
|
|
|
|
|
|
|
input->u.mi.dx = rc.left + ((input->u.mi.dx * (rc.right - rc.left)) >> 16);
|
|
|
|
input->u.mi.dy = rc.top + ((input->u.mi.dy * (rc.bottom - rc.top)) >> 16);
|
2018-08-27 14:18:24 +02:00
|
|
|
SetThreadDpiAwarenessContext( context );
|
2011-03-02 21:29:17 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int accel[3];
|
|
|
|
|
|
|
|
/* dx and dy can be negative numbers for relative movements */
|
|
|
|
SystemParametersInfoW(SPI_GETMOUSE, 0, accel, 0);
|
|
|
|
|
|
|
|
if (!accel[2]) return;
|
|
|
|
|
|
|
|
if (abs(input->u.mi.dx) > accel[0])
|
|
|
|
{
|
|
|
|
input->u.mi.dx *= 2;
|
|
|
|
if ((abs(input->u.mi.dx) > accel[1]) && (accel[2] == 2)) input->u.mi.dx *= 2;
|
|
|
|
}
|
|
|
|
if (abs(input->u.mi.dy) > accel[0])
|
|
|
|
{
|
|
|
|
input->u.mi.dy *= 2;
|
|
|
|
if ((abs(input->u.mi.dy) > accel[1]) && (accel[2] == 2)) input->u.mi.dy *= 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-25 22:01:03 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SendInput (USER32.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size )
|
|
|
|
{
|
2011-03-02 21:29:17 +01:00
|
|
|
UINT i;
|
2021-04-09 13:11:32 +02:00
|
|
|
NTSTATUS status = STATUS_SUCCESS;
|
2006-07-24 14:13:53 +02:00
|
|
|
|
2021-04-09 13:11:31 +02:00
|
|
|
if (size != sizeof(INPUT))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!count)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!inputs)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_NOACCESS );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-03-02 21:29:17 +01:00
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
2021-04-09 13:11:32 +02:00
|
|
|
INPUT input = inputs[i];
|
|
|
|
switch (input.type)
|
2006-07-24 14:13:53 +02:00
|
|
|
{
|
2021-04-09 13:11:32 +02:00
|
|
|
case INPUT_MOUSE:
|
2011-03-02 21:29:17 +01:00
|
|
|
/* we need to update the coordinates to what the server expects */
|
|
|
|
update_mouse_coords( &input );
|
2021-04-09 13:11:32 +02:00
|
|
|
/* fallthrough */
|
|
|
|
case INPUT_KEYBOARD:
|
2021-04-09 13:11:33 +02:00
|
|
|
status = send_hardware_message( 0, &input, NULL, SEND_HWMSG_INJECTED );
|
2021-04-09 13:11:32 +02:00
|
|
|
break;
|
|
|
|
case INPUT_HARDWARE:
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return 0;
|
2006-07-24 14:13:53 +02:00
|
|
|
}
|
2011-03-02 21:29:17 +01:00
|
|
|
|
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
break;
|
|
|
|
}
|
2006-07-24 14:13:53 +02:00
|
|
|
}
|
|
|
|
|
2011-03-02 21:29:17 +01:00
|
|
|
return i;
|
2001-06-25 22:01:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* keybd_event (USER32.@)
|
|
|
|
*/
|
|
|
|
void WINAPI keybd_event( BYTE bVk, BYTE bScan,
|
2002-10-31 02:04:39 +01:00
|
|
|
DWORD dwFlags, ULONG_PTR dwExtraInfo )
|
2001-06-25 22:01:03 +02:00
|
|
|
{
|
|
|
|
INPUT input;
|
|
|
|
|
|
|
|
input.type = INPUT_KEYBOARD;
|
|
|
|
input.u.ki.wVk = bVk;
|
|
|
|
input.u.ki.wScan = bScan;
|
|
|
|
input.u.ki.dwFlags = dwFlags;
|
2010-09-22 08:49:45 +02:00
|
|
|
input.u.ki.time = 0;
|
2001-10-17 19:50:02 +02:00
|
|
|
input.u.ki.dwExtraInfo = dwExtraInfo;
|
2001-06-25 22:01:03 +02:00
|
|
|
SendInput( 1, &input, sizeof(input) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/***********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* mouse_event (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
|
|
|
void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
|
2002-10-31 02:04:39 +01:00
|
|
|
DWORD dwData, ULONG_PTR dwExtraInfo )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2001-06-25 22:01:03 +02:00
|
|
|
INPUT input;
|
|
|
|
|
|
|
|
input.type = INPUT_MOUSE;
|
|
|
|
input.u.mi.dx = dx;
|
|
|
|
input.u.mi.dy = dy;
|
|
|
|
input.u.mi.mouseData = dwData;
|
|
|
|
input.u.mi.dwFlags = dwFlags;
|
2010-09-22 08:49:45 +02:00
|
|
|
input.u.mi.time = 0;
|
2001-10-18 23:38:59 +02:00
|
|
|
input.u.mi.dwExtraInfo = dwExtraInfo;
|
|
|
|
SendInput( 1, &input, sizeof(input) );
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
2001-06-25 22:01:03 +02:00
|
|
|
|
2000-12-16 21:37:16 +01:00
|
|
|
/***********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetCursorPos (USER32.@)
|
2000-12-16 21:37:16 +01:00
|
|
|
*/
|
2009-09-12 14:10:56 +02:00
|
|
|
BOOL WINAPI DECLSPEC_HOTPATCH GetCursorPos( POINT *pt )
|
2000-12-16 21:37:16 +01:00
|
|
|
{
|
2011-03-31 20:15:56 +02:00
|
|
|
BOOL ret;
|
|
|
|
DWORD last_change;
|
2018-08-27 14:19:13 +02:00
|
|
|
UINT dpi;
|
2011-02-28 22:50:21 +01:00
|
|
|
|
2005-07-18 17:14:56 +02:00
|
|
|
if (!pt) return FALSE;
|
2011-02-28 22:50:21 +01:00
|
|
|
|
|
|
|
SERVER_START_REQ( set_cursor )
|
|
|
|
{
|
|
|
|
if ((ret = !wine_server_call( req )))
|
|
|
|
{
|
|
|
|
pt->x = reply->new_x;
|
|
|
|
pt->y = reply->new_y;
|
2011-03-31 20:15:56 +02:00
|
|
|
last_change = reply->last_change;
|
2011-02-28 22:50:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2011-03-31 20:15:56 +02:00
|
|
|
|
|
|
|
/* query new position from graphics driver if we haven't updated recently */
|
|
|
|
if (ret && GetTickCount() - last_change > 100) ret = USER_Driver->pGetCursorPos( pt );
|
2018-08-27 14:19:13 +02:00
|
|
|
if (ret && (dpi = get_thread_dpi()))
|
|
|
|
{
|
|
|
|
DPI_AWARENESS_CONTEXT context;
|
|
|
|
context = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
|
|
|
|
*pt = map_dpi_point( *pt, get_monitor_dpi( MonitorFromPoint( *pt, MONITOR_DEFAULTTOPRIMARY )), dpi );
|
|
|
|
SetThreadDpiAwarenessContext( context );
|
|
|
|
}
|
2011-02-28 22:50:21 +01:00
|
|
|
return ret;
|
2000-12-16 21:37:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-29 01:38:10 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetCursorInfo (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetCursorInfo( PCURSORINFO pci )
|
|
|
|
{
|
2010-05-11 11:21:03 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2014-01-29 22:28:27 +01:00
|
|
|
if (!pci) return FALSE;
|
2010-05-11 11:21:03 +02:00
|
|
|
|
|
|
|
SERVER_START_REQ( get_thread_input )
|
|
|
|
{
|
|
|
|
req->tid = 0;
|
|
|
|
if ((ret = !wine_server_call( req )))
|
|
|
|
{
|
|
|
|
pci->hCursor = wine_server_ptr_handle( reply->cursor );
|
|
|
|
pci->flags = (reply->show_count >= 0) ? CURSOR_SHOWING : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2002-08-29 01:38:10 +02:00
|
|
|
GetCursorPos(&pci->ptScreenPos);
|
2010-05-11 11:21:03 +02:00
|
|
|
return ret;
|
2002-08-29 01:38:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-21 02:44:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetCursorPos (USER32.@)
|
|
|
|
*/
|
2009-09-12 14:10:56 +02:00
|
|
|
BOOL WINAPI DECLSPEC_HOTPATCH SetCursorPos( INT x, INT y )
|
2001-06-21 02:44:09 +02:00
|
|
|
{
|
2018-08-27 14:19:13 +02:00
|
|
|
POINT pt = { x, y };
|
2011-02-24 17:47:59 +01:00
|
|
|
BOOL ret;
|
2011-04-20 20:30:09 +02:00
|
|
|
INT prev_x, prev_y, new_x, new_y;
|
2018-08-27 14:19:13 +02:00
|
|
|
UINT dpi;
|
|
|
|
|
|
|
|
if ((dpi = get_thread_dpi()))
|
|
|
|
pt = map_dpi_point( pt, dpi, get_monitor_dpi( MonitorFromPoint( pt, MONITOR_DEFAULTTOPRIMARY )));
|
2011-02-24 17:47:59 +01:00
|
|
|
|
|
|
|
SERVER_START_REQ( set_cursor )
|
|
|
|
{
|
|
|
|
req->flags = SET_CURSOR_POS;
|
2018-08-27 14:19:13 +02:00
|
|
|
req->x = pt.x;
|
|
|
|
req->y = pt.y;
|
2011-02-24 17:47:59 +01:00
|
|
|
if ((ret = !wine_server_call( req )))
|
|
|
|
{
|
2011-04-20 20:30:09 +02:00
|
|
|
prev_x = reply->prev_x;
|
|
|
|
prev_y = reply->prev_y;
|
|
|
|
new_x = reply->new_x;
|
|
|
|
new_y = reply->new_y;
|
2011-02-24 17:47:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2011-04-20 20:30:09 +02:00
|
|
|
if (ret && (prev_x != new_x || prev_y != new_y)) USER_Driver->pSetCursorPos( new_x, new_y );
|
2011-02-24 17:47:59 +01:00
|
|
|
return ret;
|
2001-06-21 02:44:09 +02:00
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/**********************************************************************
|
2002-10-12 03:24:37 +02:00
|
|
|
* SetCapture (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2009-09-12 14:10:56 +02:00
|
|
|
HWND WINAPI DECLSPEC_HOTPATCH SetCapture( HWND hwnd )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2010-01-11 21:47:43 +01:00
|
|
|
HWND previous = 0;
|
1998-11-08 13:26:36 +01:00
|
|
|
|
2008-03-12 14:54:03 +01:00
|
|
|
set_capture_window( hwnd, 0, &previous );
|
2002-10-12 03:24:37 +02:00
|
|
|
return previous;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* ReleaseCapture (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2009-09-12 14:10:56 +02:00
|
|
|
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseCapture(void)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2008-03-12 14:54:03 +01:00
|
|
|
BOOL ret = set_capture_window( 0, 0, NULL );
|
2006-03-27 14:23:17 +02:00
|
|
|
|
|
|
|
/* Somebody may have missed some mouse movements */
|
2010-01-11 21:47:43 +01:00
|
|
|
if (ret) mouse_event( MOUSEEVENTF_MOVE, 0, 0, 0, 0 );
|
2006-03-27 14:23:17 +02:00
|
|
|
|
2005-10-03 13:06:14 +02:00
|
|
|
return ret;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetCapture (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HWND WINAPI GetCapture(void)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2002-10-12 03:24:37 +02:00
|
|
|
HWND ret = 0;
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_thread_input )
|
|
|
|
{
|
|
|
|
req->tid = GetCurrentThreadId();
|
2008-12-08 16:58:20 +01:00
|
|
|
if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->capture );
|
2002-10-12 03:24:37 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
2002-10-12 03:24:37 +02:00
|
|
|
|
2012-10-15 12:20:28 +02:00
|
|
|
static void check_for_events( UINT flags )
|
|
|
|
{
|
|
|
|
if (USER_Driver->pMsgWaitForMultipleObjectsEx( 0, NULL, 0, flags, 0 ) == WAIT_TIMEOUT)
|
|
|
|
flush_window_surfaces( TRUE );
|
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/**********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetAsyncKeyState (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Determine if a key is or was pressed. retval has high-order
|
1998-11-08 13:26:36 +01:00
|
|
|
* bit set to 1 if currently pressed, low-order bit set to 1 if key has
|
|
|
|
* been pressed.
|
|
|
|
*/
|
2011-02-28 21:55:01 +01:00
|
|
|
SHORT WINAPI DECLSPEC_HOTPATCH GetAsyncKeyState( INT key )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2015-04-07 02:33:28 +02:00
|
|
|
struct user_key_state_info *key_state_info = get_user_thread_info()->key_state;
|
2015-04-07 02:53:06 +02:00
|
|
|
INT counter = global_key_state_counter;
|
2017-12-18 16:20:58 +01:00
|
|
|
BYTE prev_key_state;
|
2011-02-28 21:55:01 +01:00
|
|
|
SHORT ret;
|
|
|
|
|
|
|
|
if (key < 0 || key >= 256) return 0;
|
|
|
|
|
2012-10-15 12:20:28 +02:00
|
|
|
check_for_events( QS_INPUT );
|
|
|
|
|
2019-11-06 11:06:23 +01:00
|
|
|
if (key_state_info && !(key_state_info->state[key] & 0xc0) &&
|
|
|
|
key_state_info->counter == counter && GetTickCount() - key_state_info->time < 50)
|
2011-02-28 21:55:01 +01:00
|
|
|
{
|
2019-11-06 11:06:23 +01:00
|
|
|
/* use cached value */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (!key_state_info)
|
|
|
|
{
|
|
|
|
key_state_info = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*key_state_info) );
|
|
|
|
get_user_thread_info()->key_state = key_state_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
SERVER_START_REQ( get_key_state )
|
|
|
|
{
|
2021-04-02 10:07:59 +02:00
|
|
|
req->async = 1;
|
2019-11-06 11:06:23 +01:00
|
|
|
req->key = key;
|
|
|
|
if (key_state_info)
|
2015-04-07 02:33:28 +02:00
|
|
|
{
|
2019-11-06 11:06:23 +01:00
|
|
|
prev_key_state = key_state_info->state[key];
|
|
|
|
wine_server_set_reply( req, key_state_info->state, sizeof(key_state_info->state) );
|
2015-04-07 02:33:28 +02:00
|
|
|
}
|
2019-11-06 11:06:23 +01:00
|
|
|
if (!wine_server_call( req ))
|
2011-02-28 21:55:01 +01:00
|
|
|
{
|
2019-11-06 11:06:23 +01:00
|
|
|
if (reply->state & 0x40) ret |= 0x0001;
|
|
|
|
if (reply->state & 0x80) ret |= 0x8000;
|
2017-12-18 16:20:58 +01:00
|
|
|
if (key_state_info)
|
|
|
|
{
|
2019-11-06 11:06:23 +01:00
|
|
|
/* force refreshing the key state cache - some multithreaded programs
|
|
|
|
* (like Adobe Photoshop CS5) expect that changes to the async key state
|
|
|
|
* are also immediately available in other threads. */
|
|
|
|
if (prev_key_state != key_state_info->state[key])
|
2020-05-02 15:10:10 +02:00
|
|
|
counter = InterlockedIncrement( &global_key_state_counter );
|
2019-11-06 11:06:23 +01:00
|
|
|
|
|
|
|
key_state_info->time = GetTickCount();
|
|
|
|
key_state_info->counter = counter;
|
2011-02-28 21:55:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-06 11:06:23 +01:00
|
|
|
SERVER_END_REQ;
|
|
|
|
|
2011-02-28 21:55:01 +01:00
|
|
|
return ret;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-05-22 21:00:27 +02:00
|
|
|
|
2005-04-26 10:18:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetQueueStatus (USER32.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetQueueStatus( UINT flags )
|
|
|
|
{
|
2012-10-15 12:20:28 +02:00
|
|
|
DWORD ret;
|
2005-04-26 10:18:47 +02:00
|
|
|
|
2005-11-14 16:17:09 +01:00
|
|
|
if (flags & ~(QS_ALLINPUT | QS_ALLPOSTMESSAGE | QS_SMRESULT))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_FLAGS );
|
|
|
|
return 0;
|
|
|
|
}
|
2005-10-27 20:28:23 +02:00
|
|
|
|
2012-10-15 12:20:28 +02:00
|
|
|
check_for_events( flags );
|
2005-04-26 10:18:47 +02:00
|
|
|
|
|
|
|
SERVER_START_REQ( get_queue_status )
|
|
|
|
{
|
2015-04-21 10:01:37 +02:00
|
|
|
req->clear_bits = flags;
|
2005-04-26 10:18:47 +02:00
|
|
|
wine_server_call( req );
|
|
|
|
ret = MAKELONG( reply->changed_bits & flags, reply->wake_bits & flags );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetInputState (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetInputState(void)
|
|
|
|
{
|
2012-10-15 12:20:28 +02:00
|
|
|
DWORD ret;
|
2005-04-26 10:18:47 +02:00
|
|
|
|
2012-10-15 12:20:28 +02:00
|
|
|
check_for_events( QS_INPUT );
|
2005-04-26 10:18:47 +02:00
|
|
|
|
|
|
|
SERVER_START_REQ( get_queue_status )
|
|
|
|
{
|
2015-04-21 10:01:37 +02:00
|
|
|
req->clear_bits = 0;
|
2005-04-26 10:18:47 +02:00
|
|
|
wine_server_call( req );
|
|
|
|
ret = reply->wake_bits & (QS_KEY | QS_MOUSEBUTTON);
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-28 14:04:14 +02:00
|
|
|
/******************************************************************
|
|
|
|
* GetLastInputInfo (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetLastInputInfo(PLASTINPUTINFO plii)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
TRACE("%p\n", plii);
|
|
|
|
|
|
|
|
if (plii->cbSize != sizeof (*plii) )
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_last_input_time )
|
|
|
|
{
|
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
if (ret)
|
|
|
|
plii->dwTime = reply->time;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-26 10:18:47 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* AttachThreadInput (USER32.@)
|
|
|
|
*
|
|
|
|
* Attaches the input processing mechanism of one thread to that of
|
|
|
|
* another thread.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AttachThreadInput( DWORD from, DWORD to, BOOL attach )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
SERVER_START_REQ( attach_thread_input )
|
|
|
|
{
|
|
|
|
req->tid_from = from;
|
|
|
|
req->tid_to = to;
|
|
|
|
req->attach = attach;
|
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetKeyState (USER32.@)
|
|
|
|
*
|
|
|
|
* An application calls the GetKeyState function in response to a
|
|
|
|
* keyboard-input message. This function retrieves the state of the key
|
|
|
|
* at the time the input message was generated.
|
|
|
|
*/
|
2009-09-12 14:10:56 +02:00
|
|
|
SHORT WINAPI DECLSPEC_HOTPATCH GetKeyState(INT vkey)
|
2005-04-26 10:18:47 +02:00
|
|
|
{
|
|
|
|
SHORT retval = 0;
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_key_state )
|
|
|
|
{
|
|
|
|
req->key = vkey;
|
2020-05-18 18:35:58 +02:00
|
|
|
if (!wine_server_call( req )) retval = (signed char)(reply->state & 0x81);
|
2005-04-26 10:18:47 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
TRACE("key (0x%x) -> %x\n", vkey, retval);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetKeyboardState (USER32.@)
|
|
|
|
*/
|
2009-09-12 14:10:56 +02:00
|
|
|
BOOL WINAPI DECLSPEC_HOTPATCH GetKeyboardState( LPBYTE state )
|
2005-04-26 10:18:47 +02:00
|
|
|
{
|
|
|
|
BOOL ret;
|
2020-05-18 18:35:58 +02:00
|
|
|
UINT i;
|
2005-04-26 10:18:47 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", state);
|
|
|
|
|
|
|
|
memset( state, 0, 256 );
|
|
|
|
SERVER_START_REQ( get_key_state )
|
|
|
|
{
|
|
|
|
req->key = -1;
|
|
|
|
wine_server_set_reply( req, state, 256 );
|
|
|
|
ret = !wine_server_call_err( req );
|
2020-05-18 18:35:58 +02:00
|
|
|
for (i = 0; i < 256; i++) state[i] &= 0x81;
|
2005-04-26 10:18:47 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* SetKeyboardState (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetKeyboardState( LPBYTE state )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
SERVER_START_REQ( set_key_state )
|
|
|
|
{
|
|
|
|
wine_server_add_data( req, state, 256 );
|
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/**********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* VkKeyScanA (USER32.@)
|
2001-10-17 19:50:02 +02:00
|
|
|
*
|
|
|
|
* VkKeyScan translates an ANSI character to a virtual-key and shift code
|
|
|
|
* for the current keyboard.
|
|
|
|
* high-order byte yields :
|
|
|
|
* 0 Unshifted
|
|
|
|
* 1 Shift
|
|
|
|
* 2 Ctrl
|
|
|
|
* 3-5 Shift-key combinations that are not used for characters
|
|
|
|
* 6 Ctrl-Alt
|
|
|
|
* 7 Ctrl-Alt-Shift
|
|
|
|
* I.e. : Shift = 1, Ctrl = 2, Alt = 4.
|
|
|
|
* FIXME : works ok except for dead chars :
|
|
|
|
* VkKeyScan '^'(0x5e, 94) ... got keycode 00 ... returning 00
|
|
|
|
* VkKeyScan '`'(0x60, 96) ... got keycode 00 ... returning 00
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2003-11-14 04:32:43 +01:00
|
|
|
SHORT WINAPI VkKeyScanA(CHAR cChar)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
WCHAR wChar;
|
|
|
|
|
|
|
|
if (IsDBCSLeadByte(cChar)) return -1;
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, &cChar, 1, &wChar, 1);
|
|
|
|
return VkKeyScanW(wChar);
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* VkKeyScanW (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2003-11-14 04:32:43 +01:00
|
|
|
SHORT WINAPI VkKeyScanW(WCHAR cChar)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
return VkKeyScanExW(cChar, GetKeyboardLayout(0));
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-03-28 15:15:40 +02:00
|
|
|
/**********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* VkKeyScanExA (USER32.@)
|
1999-03-28 15:15:40 +02:00
|
|
|
*/
|
|
|
|
WORD WINAPI VkKeyScanExA(CHAR cChar, HKL dwhkl)
|
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
WCHAR wChar;
|
|
|
|
|
|
|
|
if (IsDBCSLeadByte(cChar)) return -1;
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, &cChar, 1, &wChar, 1);
|
|
|
|
return VkKeyScanExW(wChar, dwhkl);
|
1999-03-28 15:15:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* VkKeyScanExW (USER32.@)
|
1999-03-28 15:15:40 +02:00
|
|
|
*/
|
2021-04-30 10:43:57 +02:00
|
|
|
WORD WINAPI VkKeyScanExW( WCHAR chr, HKL layout )
|
1999-03-28 15:15:40 +02:00
|
|
|
{
|
2021-04-30 10:43:57 +02:00
|
|
|
WORD shift = 0x100, ctrl = 0x200;
|
|
|
|
SHORT ret;
|
|
|
|
|
|
|
|
TRACE_(keyboard)( "chr %s, layout %p\n", debugstr_wn(&chr, 1), layout );
|
|
|
|
|
|
|
|
if ((ret = USER_Driver->pVkKeyScanEx( chr, layout )) != -256) return ret;
|
|
|
|
|
|
|
|
/* FIXME: English keyboard layout specific */
|
|
|
|
|
|
|
|
if (chr == VK_CANCEL || chr == VK_BACK || chr == VK_TAB || chr == VK_RETURN ||
|
|
|
|
chr == VK_ESCAPE || chr == VK_SPACE) ret = chr;
|
|
|
|
else if (chr >= '0' && chr <= '9') ret = chr;
|
|
|
|
else if (chr == ')') ret = shift + '0';
|
|
|
|
else if (chr == '!') ret = shift + '1';
|
|
|
|
else if (chr == '@') ret = shift + '2';
|
|
|
|
else if (chr == '#') ret = shift + '3';
|
|
|
|
else if (chr == '$') ret = shift + '4';
|
|
|
|
else if (chr == '%') ret = shift + '5';
|
|
|
|
else if (chr == '^') ret = shift + '6';
|
|
|
|
else if (chr == '&') ret = shift + '7';
|
|
|
|
else if (chr == '*') ret = shift + '8';
|
|
|
|
else if (chr == '(') ret = shift + '9';
|
|
|
|
else if (chr >= 'a' && chr <= 'z') ret = chr - 'a' + 'A';
|
|
|
|
else if (chr >= 'A' && chr <= 'Z') ret = shift + chr;
|
|
|
|
else if (chr == ';') ret = VK_OEM_1;
|
|
|
|
else if (chr == '=') ret = VK_OEM_PLUS;
|
|
|
|
else if (chr == ',') ret = VK_OEM_COMMA;
|
|
|
|
else if (chr == '-') ret = VK_OEM_MINUS;
|
|
|
|
else if (chr == '.') ret = VK_OEM_PERIOD;
|
|
|
|
else if (chr == '/') ret = VK_OEM_2;
|
|
|
|
else if (chr == '`') ret = VK_OEM_3;
|
|
|
|
else if (chr == '[') ret = VK_OEM_4;
|
|
|
|
else if (chr == '\\') ret = VK_OEM_5;
|
|
|
|
else if (chr == ']') ret = VK_OEM_6;
|
|
|
|
else if (chr == '\'') ret = VK_OEM_7;
|
|
|
|
else if (chr == ':') ret = shift + VK_OEM_1;
|
|
|
|
else if (chr == '+') ret = shift + VK_OEM_PLUS;
|
|
|
|
else if (chr == '<') ret = shift + VK_OEM_COMMA;
|
|
|
|
else if (chr == '_') ret = shift + VK_OEM_MINUS;
|
|
|
|
else if (chr == '>') ret = shift + VK_OEM_PERIOD;
|
|
|
|
else if (chr == '?') ret = shift + VK_OEM_2;
|
|
|
|
else if (chr == '~') ret = shift + VK_OEM_3;
|
|
|
|
else if (chr == '{') ret = shift + VK_OEM_4;
|
|
|
|
else if (chr == '|') ret = shift + VK_OEM_5;
|
|
|
|
else if (chr == '}') ret = shift + VK_OEM_6;
|
|
|
|
else if (chr == '\"') ret = shift + VK_OEM_7;
|
|
|
|
else if (chr == 0x7f) ret = ctrl + VK_BACK;
|
|
|
|
else if (chr == '\n') ret = ctrl + VK_RETURN;
|
|
|
|
else if (chr == 0xf000) ret = ctrl + '2';
|
|
|
|
else if (chr == 0x0000) ret = ctrl + shift + '2';
|
|
|
|
else if (chr >= 0x0001 && chr <= 0x001a) ret = ctrl + 'A' + chr - 1;
|
|
|
|
else if (chr >= 0x001c && chr <= 0x001d) ret = ctrl + VK_OEM_3 + chr;
|
|
|
|
else if (chr == 0x001e) ret = ctrl + shift + '6';
|
|
|
|
else if (chr == 0x001f) ret = ctrl + shift + VK_OEM_MINUS;
|
|
|
|
else ret = -1;
|
|
|
|
|
|
|
|
TRACE_(keyboard)( "ret %04x\n", ret );
|
|
|
|
return ret;
|
1999-03-28 15:15:40 +02:00
|
|
|
}
|
2001-10-17 19:50:02 +02:00
|
|
|
|
2004-09-02 00:47:48 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* OemKeyScan (USER32.@)
|
|
|
|
*/
|
2016-09-22 12:12:38 +02:00
|
|
|
DWORD WINAPI OemKeyScan( WORD oem )
|
2004-09-02 00:47:48 +02:00
|
|
|
{
|
2016-09-22 12:12:38 +02:00
|
|
|
WCHAR wchr;
|
|
|
|
DWORD vkey, scan;
|
|
|
|
char oem_char = LOBYTE( oem );
|
|
|
|
|
|
|
|
if (!OemToCharBuffW( &oem_char, &wchr, 1 ))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
vkey = VkKeyScanW( wchr );
|
|
|
|
scan = MapVirtualKeyW( LOBYTE( vkey ), MAPVK_VK_TO_VSC );
|
|
|
|
if (!scan) return -1;
|
|
|
|
|
|
|
|
vkey &= 0xff00;
|
|
|
|
vkey <<= 8;
|
|
|
|
return vkey | scan;
|
2004-09-02 00:47:48 +02:00
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/******************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKeyboardType (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI GetKeyboardType(INT nTypeFlag)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2001-10-17 19:50:02 +02:00
|
|
|
TRACE_(keyboard)("(%d)\n", nTypeFlag);
|
2018-08-17 10:14:49 +02:00
|
|
|
if (LOWORD(GetKeyboardLayout(0)) == MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN))
|
|
|
|
{
|
|
|
|
/* scan code for `_', the key left of r-shift, in Japanese 106 keyboard */
|
|
|
|
const UINT JP106_VSC_USCORE = 0x73;
|
|
|
|
|
|
|
|
switch(nTypeFlag)
|
|
|
|
{
|
|
|
|
case 0: /* Keyboard type */
|
|
|
|
return 7; /* Japanese keyboard */
|
|
|
|
case 1: /* Keyboard Subtype */
|
|
|
|
/* Test keyboard mappings to detect Japanese keyboard */
|
|
|
|
if (MapVirtualKeyW(VK_OEM_102, MAPVK_VK_TO_VSC) == JP106_VSC_USCORE
|
|
|
|
&& MapVirtualKeyW(JP106_VSC_USCORE, MAPVK_VSC_TO_VK) == VK_OEM_102)
|
|
|
|
return 2; /* Japanese 106 */
|
|
|
|
else
|
|
|
|
return 0; /* AT-101 */
|
|
|
|
case 2: /* Number of F-keys */
|
|
|
|
return 12; /* It has 12 F-keys */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch(nTypeFlag)
|
|
|
|
{
|
|
|
|
case 0: /* Keyboard type */
|
|
|
|
return 4; /* AT-101 */
|
|
|
|
case 1: /* Keyboard Subtype */
|
|
|
|
return 0; /* There are no defined subtypes */
|
|
|
|
case 2: /* Number of F-keys */
|
|
|
|
return 12; /* We're doing an 101 for now, so return 12 F-keys */
|
|
|
|
}
|
2001-10-17 19:50:02 +02:00
|
|
|
}
|
2018-08-17 10:14:49 +02:00
|
|
|
WARN_(keyboard)("Unknown type\n");
|
|
|
|
return 0; /* The book says 0 here, so 0 */
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* MapVirtualKeyA (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT WINAPI MapVirtualKeyA(UINT code, UINT maptype)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
return MapVirtualKeyExA( code, maptype, GetKeyboardLayout(0) );
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* MapVirtualKeyW (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT WINAPI MapVirtualKeyW(UINT code, UINT maptype)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
return MapVirtualKeyExW(code, maptype, GetKeyboardLayout(0));
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-02-13 09:53:22 +01:00
|
|
|
/******************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* MapVirtualKeyExA (USER32.@)
|
1999-02-13 09:53:22 +01:00
|
|
|
*/
|
2000-03-28 21:31:18 +02:00
|
|
|
UINT WINAPI MapVirtualKeyExA(UINT code, UINT maptype, HKL hkl)
|
1999-02-13 09:53:22 +01:00
|
|
|
{
|
2008-01-23 13:26:57 +01:00
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
ret = MapVirtualKeyExW( code, maptype, hkl );
|
|
|
|
if (maptype == MAPVK_VK_TO_CHAR)
|
|
|
|
{
|
|
|
|
BYTE ch = 0;
|
|
|
|
WCHAR wch = ret;
|
|
|
|
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, &wch, 1, (LPSTR)&ch, 1, NULL, NULL );
|
|
|
|
ret = ch;
|
|
|
|
}
|
|
|
|
return ret;
|
1999-02-13 09:53:22 +01:00
|
|
|
}
|
|
|
|
|
2021-04-30 10:43:55 +02:00
|
|
|
|
|
|
|
/* English keyboard layout (0x0409) */
|
|
|
|
static const UINT kbd_en_vsc2vk[] =
|
|
|
|
{
|
|
|
|
0x00, 0x1b, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0xbd, 0xbb, 0x08, 0x09,
|
|
|
|
0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49, 0x4f, 0x50, 0xdb, 0xdd, 0x0d, 0xa2, 0x41, 0x53,
|
|
|
|
0x44, 0x46, 0x47, 0x48, 0x4a, 0x4b, 0x4c, 0xba, 0xde, 0xc0, 0xa0, 0xdc, 0x5a, 0x58, 0x43, 0x56,
|
|
|
|
0x42, 0x4e, 0x4d, 0xbc, 0xbe, 0xbf, 0xa1, 0x6a, 0xa4, 0x20, 0x14, 0x70, 0x71, 0x72, 0x73, 0x74,
|
|
|
|
0x75, 0x76, 0x77, 0x78, 0x79, 0x90, 0x91, 0x24, 0x26, 0x21, 0x6d, 0x25, 0x0c, 0x27, 0x6b, 0x23,
|
|
|
|
0x28, 0x22, 0x2d, 0x2e, 0x2c, 0x00, 0xe2, 0x7a, 0x7b, 0x0c, 0xee, 0xf1, 0xea, 0xf9, 0xf5, 0xf3,
|
|
|
|
0x00, 0x00, 0xfb, 0x2f, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0xed,
|
|
|
|
0x00, 0xe9, 0x00, 0xc1, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x00, 0xeb, 0x09, 0x00, 0xc2, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
/* 0xe000 */
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x0d, 0xa3, 0x00, 0x00,
|
|
|
|
0xad, 0xb7, 0xb3, 0x00, 0xb2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xae, 0x00,
|
|
|
|
0xaf, 0x00, 0xac, 0x00, 0x00, 0x6f, 0x00, 0x2c, 0xa5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x24, 0x26, 0x21, 0x00, 0x25, 0x00, 0x27, 0x00, 0x23,
|
|
|
|
0x28, 0x22, 0x2d, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5b, 0x5c, 0x5d, 0x00, 0x5f,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xab, 0xa8, 0xa9, 0xa7, 0xa6, 0xb6, 0xb4, 0xb5, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
/* 0xe100 */
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const UINT kbd_en_vk2char[] =
|
|
|
|
{
|
|
|
|
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x08, 0x09, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
' ', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
|
|
|
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*', '+', 0x00, '-', '.', '/',
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ';', '=', ',', '-', '.', '/',
|
|
|
|
'`', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, '[', '\\', ']', '\'', 0x00,
|
|
|
|
0x00, 0x00, '\\', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
};
|
|
|
|
|
2021-04-30 10:43:56 +02:00
|
|
|
static const WCHAR *kbd_en_vscname[] =
|
|
|
|
{
|
|
|
|
0, L"Esc", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L"Backspace", L"Tab",
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L"Enter", L"Ctrl", 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L"Shift", 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, L"Right Shift", L"Num *", L"Alt", L"Space", L"Caps Lock", L"F1", L"F2", L"F3", L"F4", L"F5",
|
|
|
|
L"F6", L"F7", L"F8", L"F9", L"F10", L"Pause", L"Scroll Lock", L"Num 7", L"Num 8", L"Num 9", L"Num -", L"Num 4", L"Num 5", L"Num 6", L"Num +", L"Num 1",
|
|
|
|
L"Num 2", L"Num 3", L"Num 0", L"Num Del", L"Sys Req", 0, 0, L"F11", L"F12", 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L"F13", L"F14", L"F15", L"F16",
|
|
|
|
L"F17", L"F18", L"F19", L"F20", L"F21", L"F22", L"F23", L"F24", 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* extended */
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L"Num Enter", L"Right Ctrl", 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, L"Num /", 0, L"Prnt Scrn", L"Right Alt", 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, L"Num Lock", L"Break", L"Home", L"Up", L"Page Up", 0, L"Left", 0, L"Right", 0, L"End",
|
|
|
|
L"Down", L"Page Down", L"Insert", L"Delete", L"<00>", 0, L"Help", 0, 0, 0, 0, L"Left Windows", L"Right Windows", L"Application", 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
};
|
|
|
|
|
2021-04-30 10:43:55 +02:00
|
|
|
|
2000-12-05 04:56:56 +01:00
|
|
|
/******************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* MapVirtualKeyExW (USER32.@)
|
2000-12-05 04:56:56 +01:00
|
|
|
*/
|
2021-04-30 10:43:55 +02:00
|
|
|
UINT WINAPI MapVirtualKeyExW( UINT code, UINT type, HKL layout )
|
2000-12-05 04:56:56 +01:00
|
|
|
{
|
2021-04-30 10:43:55 +02:00
|
|
|
const UINT *vsc2vk, *vk2char;
|
|
|
|
UINT vsc2vk_size, vk2char_size;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE_(keyboard)( "code %u, type %u, layout %p.\n", code, type, layout );
|
|
|
|
|
|
|
|
if ((ret = USER_Driver->pMapVirtualKeyEx( code, type, layout )) != -1) return ret;
|
|
|
|
|
|
|
|
/* FIXME: English keyboard layout specific */
|
|
|
|
|
|
|
|
vsc2vk = kbd_en_vsc2vk;
|
|
|
|
vsc2vk_size = ARRAYSIZE(kbd_en_vsc2vk);
|
|
|
|
vk2char = kbd_en_vk2char;
|
|
|
|
vk2char_size = ARRAYSIZE(kbd_en_vk2char);
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case MAPVK_VK_TO_VSC_EX:
|
|
|
|
case MAPVK_VK_TO_VSC:
|
|
|
|
switch (code)
|
|
|
|
{
|
|
|
|
case VK_SHIFT: code = VK_LSHIFT; break;
|
|
|
|
case VK_CONTROL: code = VK_LCONTROL; break;
|
|
|
|
case VK_MENU: code = VK_LMENU; break;
|
|
|
|
case VK_NUMPAD0: code = VK_INSERT; break;
|
|
|
|
case VK_NUMPAD1: code = VK_END; break;
|
|
|
|
case VK_NUMPAD2: code = VK_DOWN; break;
|
|
|
|
case VK_NUMPAD3: code = VK_NEXT; break;
|
|
|
|
case VK_NUMPAD4: code = VK_LEFT; break;
|
|
|
|
case VK_NUMPAD5: code = VK_CLEAR; break;
|
|
|
|
case VK_NUMPAD6: code = VK_RIGHT; break;
|
|
|
|
case VK_NUMPAD7: code = VK_HOME; break;
|
|
|
|
case VK_NUMPAD8: code = VK_UP; break;
|
|
|
|
case VK_NUMPAD9: code = VK_PRIOR; break;
|
|
|
|
case VK_DECIMAL: code = VK_DELETE; break;
|
|
|
|
}
|
2003-11-14 04:32:43 +01:00
|
|
|
|
2021-04-30 10:43:55 +02:00
|
|
|
for (ret = 0; ret < vsc2vk_size; ++ret) if (vsc2vk[ret] == code) break;
|
|
|
|
if (ret >= vsc2vk_size) ret = 0;
|
|
|
|
|
|
|
|
if (type == MAPVK_VK_TO_VSC)
|
|
|
|
{
|
|
|
|
if (ret >= 0x200) ret = 0;
|
|
|
|
else ret &= 0xff;
|
|
|
|
}
|
|
|
|
else if (ret >= 0x100) ret += 0xdf00;
|
|
|
|
break;
|
|
|
|
case MAPVK_VSC_TO_VK:
|
|
|
|
case MAPVK_VSC_TO_VK_EX:
|
|
|
|
if (code & 0xe000) code -= 0xdf00;
|
|
|
|
if (code >= vsc2vk_size) ret = 0;
|
|
|
|
else ret = vsc2vk[code];
|
|
|
|
|
|
|
|
if (type == MAPVK_VSC_TO_VK)
|
|
|
|
{
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case VK_LSHIFT: case VK_RSHIFT: ret = VK_SHIFT; break;
|
|
|
|
case VK_LCONTROL: case VK_RCONTROL: ret = VK_CONTROL; break;
|
|
|
|
case VK_LMENU: case VK_RMENU: ret = VK_MENU; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAPVK_VK_TO_CHAR:
|
|
|
|
if (code >= vk2char_size) ret = 0;
|
|
|
|
else ret = vk2char[code];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME_(keyboard)( "unknown type %d\n", type );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE_(keyboard)( "returning 0x%04x\n", ret );
|
|
|
|
return ret;
|
2000-12-05 04:56:56 +01:00
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKBCodePage (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT WINAPI GetKBCodePage(void)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2000-12-29 20:47:53 +01:00
|
|
|
return GetOEMCP();
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-02-28 12:13:16 +01:00
|
|
|
/***********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKeyboardLayout (USER32.@)
|
1999-02-28 12:13:16 +01:00
|
|
|
*
|
2003-11-14 04:32:43 +01:00
|
|
|
* - device handle for keyboard layout defaulted to
|
1999-02-28 12:13:16 +01:00
|
|
|
* the language id. This is the way Windows default works.
|
2011-02-11 18:37:14 +01:00
|
|
|
* - the thread identifier is also ignored.
|
1999-02-28 12:13:16 +01:00
|
|
|
*/
|
2011-02-10 05:41:34 +01:00
|
|
|
HKL WINAPI GetKeyboardLayout(DWORD thread_id)
|
1999-02-28 12:13:16 +01:00
|
|
|
{
|
2021-05-05 11:46:51 +02:00
|
|
|
struct user_thread_info *thread = get_user_thread_info();
|
|
|
|
HKL layout = thread->kbd_layout;
|
2021-05-03 11:37:58 +02:00
|
|
|
|
2021-05-05 11:46:51 +02:00
|
|
|
if (thread_id && thread_id != GetCurrentThreadId())
|
|
|
|
FIXME( "couldn't return keyboard layout for thread %04x\n", thread_id );
|
2021-05-03 11:37:58 +02:00
|
|
|
|
2021-05-05 11:46:51 +02:00
|
|
|
if (!layout) return get_locale_kbd_layout();
|
|
|
|
return layout;
|
1999-02-28 12:13:16 +01:00
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKeyboardLayoutNameA (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2003-11-14 04:32:43 +01:00
|
|
|
BOOL WINAPI GetKeyboardLayoutNameA(LPSTR pszKLID)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
WCHAR buf[KL_NAMELENGTH];
|
|
|
|
|
|
|
|
if (GetKeyboardLayoutNameW(buf))
|
|
|
|
return WideCharToMultiByte( CP_ACP, 0, buf, -1, pszKLID, KL_NAMELENGTH, NULL, NULL ) != 0;
|
|
|
|
return FALSE;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKeyboardLayoutNameW (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2021-05-06 12:03:12 +02:00
|
|
|
BOOL WINAPI GetKeyboardLayoutNameW( WCHAR *name )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2021-05-07 10:29:43 +02:00
|
|
|
struct user_thread_info *info = get_user_thread_info();
|
2021-05-06 12:03:13 +02:00
|
|
|
WCHAR klid[KL_NAMELENGTH], value[5];
|
|
|
|
DWORD value_size, tmp, i = 0;
|
|
|
|
HKEY hkey;
|
2021-05-06 12:03:12 +02:00
|
|
|
HKL layout;
|
|
|
|
|
|
|
|
TRACE_(keyboard)( "name %p\n", name );
|
|
|
|
|
|
|
|
if (!name)
|
2015-01-11 23:24:20 +01:00
|
|
|
{
|
2021-05-06 12:03:12 +02:00
|
|
|
SetLastError( ERROR_NOACCESS );
|
2015-01-11 23:24:20 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2021-05-06 12:03:12 +02:00
|
|
|
|
2021-05-07 10:29:43 +02:00
|
|
|
if (info->kbd_layout_id)
|
|
|
|
{
|
|
|
|
swprintf( name, KL_NAMELENGTH, L"%08X", info->kbd_layout_id );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-05-06 12:03:12 +02:00
|
|
|
layout = GetKeyboardLayout( 0 );
|
|
|
|
tmp = HandleToUlong( layout );
|
|
|
|
if (HIWORD( tmp ) == LOWORD( tmp )) tmp = LOWORD( tmp );
|
|
|
|
swprintf( name, KL_NAMELENGTH, L"%08X", tmp );
|
|
|
|
|
2021-05-06 12:03:13 +02:00
|
|
|
if (!RegOpenKeyW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Keyboard Layouts", &hkey ))
|
|
|
|
{
|
|
|
|
while (!RegEnumKeyW( hkey, i++, klid, ARRAY_SIZE(klid) ))
|
|
|
|
{
|
|
|
|
value_size = sizeof(value);
|
|
|
|
if (!RegGetValueW( hkey, klid, L"Layout Id", RRF_RT_REG_SZ, NULL, (void *)&value, &value_size ))
|
|
|
|
tmp = 0xf000 | (wcstoul( value, NULL, 16 ) & 0xfff);
|
|
|
|
else
|
|
|
|
tmp = wcstoul( klid, NULL, 16 );
|
|
|
|
|
|
|
|
if (HIWORD( layout ) == tmp)
|
|
|
|
{
|
|
|
|
lstrcpynW( name, klid, KL_NAMELENGTH );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
|
|
|
|
2021-05-07 10:29:43 +02:00
|
|
|
info->kbd_layout_id = wcstoul( name, NULL, 16 );
|
|
|
|
|
2021-05-06 12:03:12 +02:00
|
|
|
TRACE_(keyboard)( "ret %s\n", debugstr_w( name ) );
|
|
|
|
return TRUE;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKeyNameTextA (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI GetKeyNameTextA(LONG lParam, LPSTR lpBuffer, INT nSize)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
WCHAR buf[256];
|
|
|
|
INT ret;
|
|
|
|
|
2012-02-15 12:07:34 +01:00
|
|
|
if (!nSize || !GetKeyNameTextW(lParam, buf, 256))
|
2006-07-30 03:28:26 +02:00
|
|
|
{
|
|
|
|
lpBuffer[0] = 0;
|
2003-11-14 04:32:43 +01:00
|
|
|
return 0;
|
2006-07-30 03:28:26 +02:00
|
|
|
}
|
2003-11-14 04:32:43 +01:00
|
|
|
ret = WideCharToMultiByte(CP_ACP, 0, buf, -1, lpBuffer, nSize, NULL, NULL);
|
|
|
|
if (!ret && nSize)
|
|
|
|
{
|
|
|
|
ret = nSize - 1;
|
|
|
|
lpBuffer[ret] = 0;
|
|
|
|
}
|
2012-02-15 12:07:34 +01:00
|
|
|
else ret--;
|
|
|
|
|
2003-11-14 04:32:43 +01:00
|
|
|
return ret;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKeyNameTextW (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2021-04-30 10:43:56 +02:00
|
|
|
INT WINAPI GetKeyNameTextW( LONG lparam, LPWSTR buffer, INT size )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2021-04-30 10:43:56 +02:00
|
|
|
INT code = ((lparam >> 16) & 0x1ff), vkey, len;
|
|
|
|
UINT vsc2vk_size, vscname_size;
|
|
|
|
const WCHAR *const *vscname;
|
|
|
|
const UINT *vsc2vk;
|
|
|
|
WCHAR tmp[2];
|
|
|
|
|
|
|
|
TRACE_(keyboard)( "lparam %d, buffer %p, size %d.\n", lparam, buffer, size );
|
|
|
|
|
|
|
|
if (!buffer || !size) return 0;
|
|
|
|
if ((len = USER_Driver->pGetKeyNameText( lparam, buffer, size )) >= 0) return len;
|
|
|
|
|
|
|
|
/* FIXME: English keyboard layout specific */
|
|
|
|
|
|
|
|
vsc2vk = kbd_en_vsc2vk;
|
|
|
|
vsc2vk_size = ARRAYSIZE(kbd_en_vsc2vk);
|
|
|
|
vscname = kbd_en_vscname;
|
|
|
|
vscname_size = ARRAYSIZE(kbd_en_vscname);
|
|
|
|
|
|
|
|
if (lparam & 0x2000000)
|
|
|
|
{
|
|
|
|
switch ((vkey = vsc2vk[code]))
|
|
|
|
{
|
|
|
|
case VK_RSHIFT:
|
|
|
|
case VK_RCONTROL:
|
|
|
|
case VK_RMENU:
|
|
|
|
for (code = 0; code < vsc2vk_size; ++code)
|
|
|
|
if (vsc2vk[code] == (vkey - 1)) break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (code >= vscname_size) buffer[0] = 0;
|
|
|
|
else if (vscname[code]) lstrcpynW( buffer, vscname[code], size );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vkey = MapVirtualKeyW( code & 0xff, MAPVK_VSC_TO_VK );
|
|
|
|
tmp[0] = MapVirtualKeyW( vkey, MAPVK_VK_TO_CHAR );
|
|
|
|
tmp[1] = 0;
|
|
|
|
lstrcpynW( buffer, tmp, size );
|
|
|
|
}
|
|
|
|
len = wcslen( buffer );
|
|
|
|
|
|
|
|
TRACE_(keyboard)( "ret %d, str %s.\n", len, debugstr_w(buffer) );
|
|
|
|
return len;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
2000-10-25 23:34:31 +02:00
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* ToUnicode (USER32.@)
|
2000-10-25 23:34:31 +02:00
|
|
|
*/
|
2008-10-27 11:23:02 +01:00
|
|
|
INT WINAPI ToUnicode(UINT virtKey, UINT scanCode, const BYTE *lpKeyState,
|
2000-10-25 23:34:31 +02:00
|
|
|
LPWSTR lpwStr, int size, UINT flags)
|
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
return ToUnicodeEx(virtKey, scanCode, lpKeyState, lpwStr, size, flags, GetKeyboardLayout(0));
|
2000-10-25 23:34:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* ToUnicodeEx (USER32.@)
|
2000-10-25 23:34:31 +02:00
|
|
|
*/
|
2021-04-29 09:53:52 +02:00
|
|
|
INT WINAPI ToUnicodeEx( UINT virt, UINT scan, const BYTE *state,
|
|
|
|
WCHAR *str, int size, UINT flags, HKL layout )
|
2000-10-25 23:34:31 +02:00
|
|
|
{
|
2021-04-29 09:53:53 +02:00
|
|
|
BOOL shift, ctrl, alt, numlock;
|
2021-04-29 09:53:52 +02:00
|
|
|
WCHAR buffer[2];
|
|
|
|
INT len;
|
|
|
|
|
|
|
|
TRACE_(keyboard)( "virt %u, scan %u, state %p, str %p, size %d, flags %x, layout %p.\n",
|
|
|
|
virt, scan, state, str, size, flags, layout );
|
|
|
|
|
|
|
|
if (!state) return 0;
|
|
|
|
if ((len = USER_Driver->pToUnicodeEx( virt, scan, state, str, size, flags, layout )) >= -1) return len;
|
|
|
|
|
2021-04-29 09:53:53 +02:00
|
|
|
alt = state[VK_MENU] & 0x80;
|
2021-04-29 09:53:52 +02:00
|
|
|
shift = state[VK_SHIFT] & 0x80;
|
|
|
|
ctrl = state[VK_CONTROL] & 0x80;
|
|
|
|
numlock = state[VK_NUMLOCK] & 0x01;
|
|
|
|
|
|
|
|
/* FIXME: English keyboard layout specific */
|
|
|
|
|
|
|
|
if (scan & 0x8000) buffer[0] = 0; /* key up */
|
2021-04-29 09:53:54 +02:00
|
|
|
else if (virt == VK_ESCAPE) buffer[0] = VK_ESCAPE;
|
2021-04-29 09:53:52 +02:00
|
|
|
else if (!ctrl)
|
|
|
|
{
|
|
|
|
switch (virt)
|
|
|
|
{
|
|
|
|
case VK_BACK: buffer[0] = '\b'; break;
|
|
|
|
case VK_OEM_1: buffer[0] = shift ? ':' : ';'; break;
|
|
|
|
case VK_OEM_2: buffer[0] = shift ? '?' : '/'; break;
|
|
|
|
case VK_OEM_3: buffer[0] = shift ? '~' : '`'; break;
|
|
|
|
case VK_OEM_4: buffer[0] = shift ? '{' : '['; break;
|
|
|
|
case VK_OEM_5: buffer[0] = shift ? '|' : '\\'; break;
|
|
|
|
case VK_OEM_6: buffer[0] = shift ? '}' : ']'; break;
|
|
|
|
case VK_OEM_7: buffer[0] = shift ? '"' : '\''; break;
|
|
|
|
case VK_OEM_COMMA: buffer[0] = shift ? '<' : ','; break;
|
|
|
|
case VK_OEM_MINUS: buffer[0] = shift ? '_' : '-'; break;
|
|
|
|
case VK_OEM_PERIOD: buffer[0] = shift ? '>' : '.'; break;
|
|
|
|
case VK_OEM_PLUS: buffer[0] = shift ? '+' : '='; break;
|
|
|
|
case VK_RETURN: buffer[0] = '\r'; break;
|
|
|
|
case VK_SPACE: buffer[0] = ' '; break;
|
|
|
|
case VK_TAB: buffer[0] = '\t'; break;
|
|
|
|
case VK_MULTIPLY: buffer[0] = '*'; break;
|
|
|
|
case VK_ADD: buffer[0] = '+'; break;
|
|
|
|
case VK_SUBTRACT: buffer[0] = '-'; break;
|
|
|
|
case VK_DIVIDE: buffer[0] = '/'; break;
|
|
|
|
default:
|
|
|
|
if (virt >= '0' && virt <= '9')
|
|
|
|
buffer[0] = shift ? ")!@#$%^&*("[virt - '0'] : virt;
|
|
|
|
else if (virt >= 'A' && virt <= 'Z')
|
|
|
|
buffer[0] = shift || (state[VK_CAPITAL] & 0x01) ? virt : virt + 'a' - 'A';
|
|
|
|
else if (virt >= VK_NUMPAD0 && virt <= VK_NUMPAD9 && numlock && !shift)
|
|
|
|
buffer[0] = '0' + virt - VK_NUMPAD0;
|
|
|
|
else if (virt == VK_DECIMAL && numlock && !shift)
|
|
|
|
buffer[0] = '.';
|
|
|
|
else
|
|
|
|
buffer[0] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-04-29 09:53:53 +02:00
|
|
|
else if (!alt) /* Control codes */
|
2021-04-29 09:53:52 +02:00
|
|
|
{
|
|
|
|
switch (virt)
|
|
|
|
{
|
|
|
|
case VK_OEM_4: buffer[0] = 0x1b; break;
|
|
|
|
case VK_OEM_5: buffer[0] = 0x1c; break;
|
|
|
|
case VK_OEM_6: buffer[0] = 0x1d; break;
|
2021-05-06 12:03:15 +02:00
|
|
|
case '6': buffer[0] = shift ? 0x1e : 0; break;
|
|
|
|
case VK_OEM_MINUS: buffer[0] = shift ? 0x1f : 0; break;
|
|
|
|
case VK_BACK: buffer[0] = 0x7f; break;
|
2021-04-29 09:53:54 +02:00
|
|
|
case VK_RETURN: buffer[0] = shift ? 0 : '\n'; break;
|
2021-05-06 12:03:15 +02:00
|
|
|
case '2': buffer[0] = shift ? 0xffff : 0xf000; break;
|
2021-04-29 09:53:54 +02:00
|
|
|
case VK_SPACE: buffer[0] = ' '; break;
|
2021-04-29 09:53:52 +02:00
|
|
|
default:
|
|
|
|
if (virt >= 'A' && virt <= 'Z') buffer[0] = virt - 'A' + 1;
|
|
|
|
else buffer[0] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-04-29 09:53:53 +02:00
|
|
|
else buffer[0] = 0;
|
2021-04-29 09:53:52 +02:00
|
|
|
buffer[1] = 0;
|
|
|
|
len = wcslen( buffer );
|
2021-05-06 12:03:15 +02:00
|
|
|
if (buffer[0] == 0xffff) buffer[0] = 0;
|
2021-04-29 09:53:52 +02:00
|
|
|
lstrcpynW( str, buffer, size );
|
|
|
|
|
|
|
|
TRACE_(keyboard)( "ret %d, str %s.\n", len, debugstr_w(str) );
|
|
|
|
return len;
|
2000-10-25 23:34:31 +02:00
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* ToAscii (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2008-10-27 11:23:02 +01:00
|
|
|
INT WINAPI ToAscii( UINT virtKey, UINT scanCode, const BYTE *lpKeyState,
|
2003-11-14 04:32:43 +01:00
|
|
|
LPWORD lpChar, UINT flags )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
return ToAsciiEx(virtKey, scanCode, lpKeyState, lpChar, flags, GetKeyboardLayout(0));
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-03-28 15:15:40 +02:00
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* ToAsciiEx (USER32.@)
|
1999-03-28 15:15:40 +02:00
|
|
|
*/
|
2008-10-27 11:23:02 +01:00
|
|
|
INT WINAPI ToAsciiEx( UINT virtKey, UINT scanCode, const BYTE *lpKeyState,
|
1999-03-28 15:15:40 +02:00
|
|
|
LPWORD lpChar, UINT flags, HKL dwhkl )
|
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
WCHAR uni_chars[2];
|
|
|
|
INT ret, n_ret;
|
|
|
|
|
|
|
|
ret = ToUnicodeEx(virtKey, scanCode, lpKeyState, uni_chars, 2, flags, dwhkl);
|
|
|
|
if (ret < 0) n_ret = 1; /* FIXME: make ToUnicode return 2 for dead chars */
|
|
|
|
else n_ret = ret;
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, uni_chars, n_ret, (LPSTR)lpChar, 2, NULL, NULL);
|
|
|
|
return ret;
|
1999-03-28 15:15:40 +02:00
|
|
|
}
|
|
|
|
|
1998-12-10 16:49:22 +01:00
|
|
|
/**********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* ActivateKeyboardLayout (USER32.@)
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
2021-05-03 11:37:56 +02:00
|
|
|
HKL WINAPI ActivateKeyboardLayout( HKL layout, UINT flags )
|
1998-12-10 16:49:22 +01:00
|
|
|
{
|
2021-05-05 11:46:48 +02:00
|
|
|
struct user_thread_info *info = get_user_thread_info();
|
2021-05-03 11:37:56 +02:00
|
|
|
HKL old_layout;
|
2003-11-14 04:32:43 +01:00
|
|
|
|
2021-05-03 11:37:56 +02:00
|
|
|
TRACE_(keyboard)( "layout %p, flags %x\n", layout, flags );
|
|
|
|
|
2021-05-03 11:37:57 +02:00
|
|
|
if (flags) FIXME_(keyboard)( "flags %x not supported\n", flags );
|
|
|
|
|
|
|
|
if (layout == (HKL)HKL_NEXT || layout == (HKL)HKL_PREV)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
FIXME_(keyboard)( "HKL_NEXT and HKL_PREV not supported\n" );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-05-05 11:46:50 +02:00
|
|
|
if (!USER_Driver->pActivateKeyboardLayout( layout, flags ))
|
|
|
|
return 0;
|
2021-05-03 11:37:56 +02:00
|
|
|
|
2021-05-05 11:46:50 +02:00
|
|
|
old_layout = info->kbd_layout;
|
|
|
|
info->kbd_layout = layout;
|
2021-05-07 10:29:43 +02:00
|
|
|
if (old_layout != layout) info->kbd_layout_id = 0;
|
2021-05-05 11:46:50 +02:00
|
|
|
|
|
|
|
if (!old_layout) return get_locale_kbd_layout();
|
|
|
|
return old_layout;
|
1998-12-10 16:49:22 +01:00
|
|
|
}
|
|
|
|
|
2006-09-29 18:59:11 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* BlockInput (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI BlockInput(BOOL fBlockIt)
|
|
|
|
{
|
|
|
|
FIXME_(keyboard)("(%d): stub\n", fBlockIt);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
1998-12-10 16:49:22 +01:00
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/***********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKeyboardLayoutList (USER32.@)
|
1999-02-28 12:13:16 +01:00
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Return number of values available if either input parm is
|
1999-02-28 12:13:16 +01:00
|
|
|
* 0, per MS documentation.
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2021-04-30 10:43:58 +02:00
|
|
|
UINT WINAPI GetKeyboardLayoutList( INT size, HKL *layouts )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2021-04-30 10:43:59 +02:00
|
|
|
WCHAR klid[KL_NAMELENGTH], value[5];
|
|
|
|
DWORD value_size, count, tmp, i = 0;
|
2021-04-30 10:43:58 +02:00
|
|
|
HKEY hkey;
|
|
|
|
HKL layout;
|
|
|
|
|
|
|
|
TRACE_(keyboard)( "size %d, layouts %p.\n", size, layouts );
|
|
|
|
|
|
|
|
if ((count = USER_Driver->pGetKeyboardLayoutList( size, layouts )) != ~0) return count;
|
|
|
|
|
|
|
|
layout = get_locale_kbd_layout();
|
|
|
|
count = 0;
|
|
|
|
|
|
|
|
count++;
|
|
|
|
if (size && layouts)
|
|
|
|
{
|
|
|
|
layouts[count - 1] = layout;
|
|
|
|
if (count == size) return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!RegOpenKeyW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Keyboard Layouts", &hkey ))
|
|
|
|
{
|
|
|
|
while (!RegEnumKeyW( hkey, i++, klid, ARRAY_SIZE(klid) ))
|
|
|
|
{
|
|
|
|
tmp = wcstoul( klid, NULL, 16 );
|
2021-04-30 10:43:59 +02:00
|
|
|
value_size = sizeof(value);
|
|
|
|
if (!RegGetValueW( hkey, klid, L"Layout Id", RRF_RT_REG_SZ, NULL, (void *)&value, &value_size ))
|
|
|
|
tmp = MAKELONG( LOWORD( tmp ), 0xf000 | (wcstoul( value, NULL, 16 ) & 0xfff) );
|
|
|
|
|
2021-04-30 10:43:58 +02:00
|
|
|
if (layout == UlongToHandle( tmp )) continue;
|
|
|
|
|
|
|
|
count++;
|
|
|
|
if (size && layouts)
|
|
|
|
{
|
|
|
|
layouts[count - 1] = UlongToHandle( tmp );
|
|
|
|
if (count == size) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
2008-12-17 17:13:27 +01:00
|
|
|
|
2021-04-30 10:43:58 +02:00
|
|
|
return count;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* RegisterHotKey (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2005-04-25 13:33:34 +02:00
|
|
|
BOOL WINAPI RegisterHotKey(HWND hwnd,INT id,UINT modifiers,UINT vk)
|
|
|
|
{
|
2011-05-26 22:52:17 +02:00
|
|
|
BOOL ret;
|
2011-06-23 19:34:26 +02:00
|
|
|
int replaced=0;
|
2011-05-26 22:52:17 +02:00
|
|
|
|
|
|
|
TRACE_(keyboard)("(%p,%d,0x%08x,%X)\n",hwnd,id,modifiers,vk);
|
|
|
|
|
2011-06-23 19:34:26 +02:00
|
|
|
if ((hwnd == NULL || WIN_IsCurrentThread(hwnd)) &&
|
|
|
|
!USER_Driver->pRegisterHotKey(hwnd, modifiers, vk))
|
|
|
|
return FALSE;
|
2011-05-26 22:52:17 +02:00
|
|
|
|
|
|
|
SERVER_START_REQ( register_hotkey )
|
|
|
|
{
|
|
|
|
req->window = wine_server_user_handle( hwnd );
|
|
|
|
req->id = id;
|
|
|
|
req->flags = modifiers;
|
|
|
|
req->vkey = vk;
|
2011-06-23 19:34:26 +02:00
|
|
|
if ((ret = !wine_server_call_err( req )))
|
|
|
|
{
|
|
|
|
replaced = reply->replaced;
|
|
|
|
modifiers = reply->flags;
|
|
|
|
vk = reply->vkey;
|
|
|
|
}
|
2011-05-26 22:52:17 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
2011-06-23 19:34:26 +02:00
|
|
|
if (ret && replaced)
|
|
|
|
USER_Driver->pUnregisterHotKey(hwnd, modifiers, vk);
|
2011-05-26 22:52:17 +02:00
|
|
|
|
|
|
|
return ret;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* UnregisterHotKey (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2005-04-25 13:33:34 +02:00
|
|
|
BOOL WINAPI UnregisterHotKey(HWND hwnd,INT id)
|
|
|
|
{
|
2011-05-26 22:52:17 +02:00
|
|
|
BOOL ret;
|
2011-06-23 19:34:26 +02:00
|
|
|
UINT modifiers, vk;
|
2011-05-26 22:52:17 +02:00
|
|
|
|
|
|
|
TRACE_(keyboard)("(%p,%d)\n",hwnd,id);
|
|
|
|
|
|
|
|
SERVER_START_REQ( unregister_hotkey )
|
|
|
|
{
|
|
|
|
req->window = wine_server_user_handle( hwnd );
|
|
|
|
req->id = id;
|
2011-06-23 19:34:26 +02:00
|
|
|
if ((ret = !wine_server_call_err( req )))
|
|
|
|
{
|
|
|
|
modifiers = reply->flags;
|
|
|
|
vk = reply->vkey;
|
|
|
|
}
|
2011-05-26 22:52:17 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
2011-06-23 19:34:26 +02:00
|
|
|
if (ret)
|
|
|
|
USER_Driver->pUnregisterHotKey(hwnd, modifiers, vk);
|
2011-05-26 22:52:17 +02:00
|
|
|
|
|
|
|
return ret;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1998-12-10 16:49:22 +01:00
|
|
|
/***********************************************************************
|
2002-11-18 20:47:20 +01:00
|
|
|
* LoadKeyboardLayoutW (USER32.@)
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
2021-05-07 10:29:44 +02:00
|
|
|
HKL WINAPI LoadKeyboardLayoutW( const WCHAR *name, UINT flags )
|
1998-12-10 16:49:22 +01:00
|
|
|
{
|
2021-05-07 10:29:46 +02:00
|
|
|
WCHAR layout_path[MAX_PATH], value[5];
|
|
|
|
DWORD value_size, tmp;
|
|
|
|
HKEY hkey;
|
2021-05-07 10:29:45 +02:00
|
|
|
HKL layout;
|
|
|
|
|
2021-05-07 10:29:44 +02:00
|
|
|
FIXME_(keyboard)( "name %s, flags %x, semi-stub!\n", debugstr_w( name ), flags );
|
2021-05-07 10:29:45 +02:00
|
|
|
|
|
|
|
tmp = wcstoul( name, NULL, 16 );
|
2021-05-14 13:40:07 +02:00
|
|
|
if (HIWORD( tmp )) layout = UlongToHandle( tmp );
|
|
|
|
else layout = UlongToHandle( MAKELONG( LOWORD( tmp ), LOWORD( tmp ) ) );
|
2021-05-07 10:29:45 +02:00
|
|
|
|
2021-05-07 10:29:46 +02:00
|
|
|
wcscpy( layout_path, L"System\\CurrentControlSet\\Control\\Keyboard Layouts\\" );
|
|
|
|
wcscat( layout_path, name );
|
|
|
|
|
|
|
|
if (!RegOpenKeyW( HKEY_LOCAL_MACHINE, layout_path, &hkey ))
|
|
|
|
{
|
|
|
|
value_size = sizeof(value);
|
|
|
|
if (!RegGetValueW( hkey, NULL, L"Layout Id", RRF_RT_REG_SZ, NULL, (void *)&value, &value_size ))
|
|
|
|
layout = UlongToHandle( MAKELONG( LOWORD( tmp ), 0xf000 | (wcstoul( value, NULL, 16 ) & 0xfff) ) );
|
|
|
|
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
|
|
|
|
2021-05-07 10:29:45 +02:00
|
|
|
if ((flags & KLF_ACTIVATE) && ActivateKeyboardLayout( layout, 0 )) return layout;
|
|
|
|
|
2021-05-07 10:29:44 +02:00
|
|
|
/* FIXME: semi-stub: returning default layout */
|
|
|
|
return get_locale_kbd_layout();
|
1998-12-10 16:49:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2002-11-18 20:47:20 +01:00
|
|
|
* LoadKeyboardLayoutA (USER32.@)
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
2002-11-18 20:47:20 +01:00
|
|
|
HKL WINAPI LoadKeyboardLayoutA(LPCSTR pwszKLID, UINT Flags)
|
1998-12-10 16:49:22 +01:00
|
|
|
{
|
2002-11-18 20:47:20 +01:00
|
|
|
HKL ret;
|
|
|
|
UNICODE_STRING pwszKLIDW;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-11-18 20:47:20 +01:00
|
|
|
if (pwszKLID) RtlCreateUnicodeStringFromAsciiz(&pwszKLIDW, pwszKLID);
|
|
|
|
else pwszKLIDW.Buffer = NULL;
|
|
|
|
|
|
|
|
ret = LoadKeyboardLayoutW(pwszKLIDW.Buffer, Flags);
|
|
|
|
RtlFreeUnicodeString(&pwszKLIDW);
|
|
|
|
return ret;
|
1998-12-10 16:49:22 +01:00
|
|
|
}
|
2002-01-15 21:41:41 +01:00
|
|
|
|
|
|
|
|
2003-11-14 04:32:43 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* UnloadKeyboardLayout (USER32.@)
|
|
|
|
*/
|
2021-05-07 10:29:44 +02:00
|
|
|
BOOL WINAPI UnloadKeyboardLayout( HKL layout )
|
2003-11-14 04:32:43 +01:00
|
|
|
{
|
2021-05-07 10:29:44 +02:00
|
|
|
FIXME_(keyboard)( "layout %p, stub!\n", layout );
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
2003-11-14 04:32:43 +01:00
|
|
|
}
|
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
typedef struct __TRACKINGLIST {
|
|
|
|
TRACKMOUSEEVENT tme;
|
|
|
|
POINT pos; /* center of hover rectangle */
|
2002-06-01 01:06:46 +02:00
|
|
|
} _TRACKINGLIST;
|
2002-01-15 21:41:41 +01:00
|
|
|
|
2006-07-20 15:27:29 +02:00
|
|
|
/* FIXME: move tracking stuff into a per thread data */
|
|
|
|
static _TRACKINGLIST tracking_info;
|
2002-01-15 21:41:41 +01:00
|
|
|
static UINT_PTR timer;
|
|
|
|
|
2006-10-16 17:37:40 +02:00
|
|
|
static void check_mouse_leave(HWND hwnd, int hittest)
|
|
|
|
{
|
|
|
|
if (tracking_info.tme.hwndTrack != hwnd)
|
|
|
|
{
|
|
|
|
if (tracking_info.tme.dwFlags & TME_NONCLIENT)
|
|
|
|
PostMessageW(tracking_info.tme.hwndTrack, WM_NCMOUSELEAVE, 0, 0);
|
|
|
|
else
|
|
|
|
PostMessageW(tracking_info.tme.hwndTrack, WM_MOUSELEAVE, 0, 0);
|
|
|
|
|
|
|
|
/* remove the TME_LEAVE flag */
|
|
|
|
tracking_info.tme.dwFlags &= ~TME_LEAVE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (hittest == HTCLIENT)
|
|
|
|
{
|
|
|
|
if (tracking_info.tme.dwFlags & TME_NONCLIENT)
|
|
|
|
{
|
|
|
|
PostMessageW(tracking_info.tme.hwndTrack, WM_NCMOUSELEAVE, 0, 0);
|
|
|
|
/* remove the TME_LEAVE flag */
|
|
|
|
tracking_info.tme.dwFlags &= ~TME_LEAVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!(tracking_info.tme.dwFlags & TME_NONCLIENT))
|
|
|
|
{
|
|
|
|
PostMessageW(tracking_info.tme.hwndTrack, WM_MOUSELEAVE, 0, 0);
|
|
|
|
/* remove the TME_LEAVE flag */
|
|
|
|
tracking_info.tme.dwFlags &= ~TME_LEAVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-24 14:19:25 +02:00
|
|
|
static void CALLBACK TrackMouseEventProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent,
|
|
|
|
DWORD dwTime)
|
2002-01-15 21:41:41 +01:00
|
|
|
{
|
|
|
|
POINT pos;
|
2006-07-24 14:19:25 +02:00
|
|
|
INT hoverwidth = 0, hoverheight = 0, hittest;
|
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("hwnd %p, msg %04x, id %04lx, time %u\n", hwnd, uMsg, idEvent, dwTime);
|
2002-01-15 21:41:41 +01:00
|
|
|
|
|
|
|
GetCursorPos(&pos);
|
2006-07-24 14:19:25 +02:00
|
|
|
hwnd = WINPOS_WindowFromPoint(hwnd, pos, &hittest);
|
|
|
|
|
|
|
|
TRACE("point %s hwnd %p hittest %d\n", wine_dbgstr_point(&pos), hwnd, hittest);
|
2002-01-15 21:41:41 +01:00
|
|
|
|
2006-07-20 15:27:29 +02:00
|
|
|
SystemParametersInfoW(SPI_GETMOUSEHOVERWIDTH, 0, &hoverwidth, 0);
|
|
|
|
SystemParametersInfoW(SPI_GETMOUSEHOVERHEIGHT, 0, &hoverheight, 0);
|
2002-01-15 21:41:41 +01:00
|
|
|
|
2006-07-24 14:19:25 +02:00
|
|
|
TRACE("tracked pos %s, current pos %s, hover width %d, hover height %d\n",
|
|
|
|
wine_dbgstr_point(&tracking_info.pos), wine_dbgstr_point(&pos),
|
|
|
|
hoverwidth, hoverheight);
|
|
|
|
|
2006-07-20 15:27:29 +02:00
|
|
|
/* see if this tracking event is looking for TME_LEAVE and that the */
|
|
|
|
/* mouse has left the window */
|
|
|
|
if (tracking_info.tme.dwFlags & TME_LEAVE)
|
|
|
|
{
|
2006-10-16 17:37:40 +02:00
|
|
|
check_mouse_leave(hwnd, hittest);
|
2006-07-20 15:27:29 +02:00
|
|
|
}
|
2002-01-15 21:41:41 +01:00
|
|
|
|
2006-07-24 14:19:25 +02:00
|
|
|
if (tracking_info.tme.hwndTrack != hwnd)
|
|
|
|
{
|
|
|
|
/* mouse is gone, stop tracking mouse hover */
|
|
|
|
tracking_info.tme.dwFlags &= ~TME_HOVER;
|
|
|
|
}
|
|
|
|
|
2006-07-20 15:27:29 +02:00
|
|
|
/* see if we are tracking hovering for this hwnd */
|
|
|
|
if (tracking_info.tme.dwFlags & TME_HOVER)
|
|
|
|
{
|
|
|
|
/* has the cursor moved outside the rectangle centered around pos? */
|
2006-07-24 14:19:25 +02:00
|
|
|
if ((abs(pos.x - tracking_info.pos.x) > (hoverwidth / 2)) ||
|
|
|
|
(abs(pos.y - tracking_info.pos.y) > (hoverheight / 2)))
|
2006-07-20 15:27:29 +02:00
|
|
|
{
|
2006-07-24 14:19:25 +02:00
|
|
|
/* record this new position as the current position */
|
2006-07-20 15:27:29 +02:00
|
|
|
tracking_info.pos = pos;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-07-24 14:19:25 +02:00
|
|
|
if (hittest == HTCLIENT)
|
|
|
|
{
|
|
|
|
ScreenToClient(hwnd, &pos);
|
|
|
|
TRACE("client cursor pos %s\n", wine_dbgstr_point(&pos));
|
2006-07-20 15:27:29 +02:00
|
|
|
|
|
|
|
PostMessageW(tracking_info.tme.hwndTrack, WM_MOUSEHOVER,
|
2006-07-24 14:19:25 +02:00
|
|
|
get_key_state(), MAKELPARAM( pos.x, pos.y ));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (tracking_info.tme.dwFlags & TME_NONCLIENT)
|
|
|
|
PostMessageW(tracking_info.tme.hwndTrack, WM_NCMOUSEHOVER,
|
|
|
|
hittest, MAKELPARAM( pos.x, pos.y ));
|
|
|
|
}
|
2006-07-20 15:27:29 +02:00
|
|
|
|
|
|
|
/* stop tracking mouse hover */
|
|
|
|
tracking_info.tme.dwFlags &= ~TME_HOVER;
|
2002-01-15 21:41:41 +01:00
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
/* stop the timer if the tracking list is empty */
|
2006-07-20 15:27:29 +02:00
|
|
|
if (!(tracking_info.tme.dwFlags & (TME_HOVER | TME_LEAVE)))
|
|
|
|
{
|
2006-07-24 14:19:25 +02:00
|
|
|
KillSystemTimer(tracking_info.tme.hwndTrack, timer);
|
2002-01-15 21:41:41 +01:00
|
|
|
timer = 0;
|
2006-07-24 14:19:25 +02:00
|
|
|
tracking_info.tme.hwndTrack = 0;
|
|
|
|
tracking_info.tme.dwFlags = 0;
|
|
|
|
tracking_info.tme.dwHoverTime = 0;
|
2002-01-15 21:41:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* TrackMouseEvent [USER32]
|
|
|
|
*
|
|
|
|
* Requests notification of mouse events
|
|
|
|
*
|
|
|
|
* During mouse tracking WM_MOUSEHOVER or WM_MOUSELEAVE events are posted
|
|
|
|
* to the hwnd specified in the ptme structure. After the event message
|
|
|
|
* is posted to the hwnd, the entry in the queue is removed.
|
|
|
|
*
|
|
|
|
* If the current hwnd isn't ptme->hwndTrack the TME_HOVER flag is completely
|
|
|
|
* ignored. The TME_LEAVE flag results in a WM_MOUSELEAVE message being posted
|
|
|
|
* immediately and the TME_LEAVE flag being ignored.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ptme [I,O] pointer to TRACKMOUSEEVENT information structure.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: non-zero
|
|
|
|
* Failure: zero
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL WINAPI
|
|
|
|
TrackMouseEvent (TRACKMOUSEEVENT *ptme)
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
POINT pos;
|
2006-07-20 15:27:29 +02:00
|
|
|
DWORD hover_time;
|
2006-07-24 14:19:25 +02:00
|
|
|
INT hittest;
|
2002-01-15 21:41:41 +01:00
|
|
|
|
2006-09-30 00:25:15 +02:00
|
|
|
TRACE("%x, %x, %p, %u\n", ptme->cbSize, ptme->dwFlags, ptme->hwndTrack, ptme->dwHoverTime);
|
2002-01-15 21:41:41 +01:00
|
|
|
|
|
|
|
if (ptme->cbSize != sizeof(TRACKMOUSEEVENT)) {
|
|
|
|
WARN("wrong TRACKMOUSEEVENT size from app\n");
|
2006-07-20 15:27:29 +02:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
2002-01-15 21:41:41 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-07-20 15:27:29 +02:00
|
|
|
/* fill the TRACKMOUSEEVENT struct with the current tracking for the given hwnd */
|
|
|
|
if (ptme->dwFlags & TME_QUERY )
|
|
|
|
{
|
|
|
|
*ptme = tracking_info.tme;
|
2006-07-24 17:45:30 +02:00
|
|
|
/* set cbSize in the case it's not initialized yet */
|
|
|
|
ptme->cbSize = sizeof(TRACKMOUSEEVENT);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-07-20 15:27:29 +02:00
|
|
|
return TRUE; /* return here, TME_QUERY is retrieving information */
|
2002-01-15 21:41:41 +01:00
|
|
|
}
|
|
|
|
|
2006-07-20 15:27:29 +02:00
|
|
|
if (!IsWindow(ptme->hwndTrack))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|
|
|
return FALSE;
|
2003-11-26 06:06:59 +01:00
|
|
|
}
|
|
|
|
|
2011-02-16 02:09:35 +01:00
|
|
|
hover_time = (ptme->dwFlags & TME_HOVER) ? ptme->dwHoverTime : HOVER_DEFAULT;
|
2002-01-15 21:41:41 +01:00
|
|
|
|
2011-02-16 02:09:35 +01:00
|
|
|
/* if HOVER_DEFAULT was specified replace this with the system's current value.
|
2006-10-14 20:16:30 +02:00
|
|
|
* TME_LEAVE doesn't need to specify hover time so use default */
|
2011-02-16 02:09:35 +01:00
|
|
|
if (hover_time == HOVER_DEFAULT || hover_time == 0)
|
2006-07-20 15:27:29 +02:00
|
|
|
SystemParametersInfoW(SPI_GETMOUSEHOVERTIME, 0, &hover_time, 0);
|
2002-01-15 21:41:41 +01:00
|
|
|
|
2006-07-20 15:27:29 +02:00
|
|
|
GetCursorPos(&pos);
|
2006-07-24 14:19:25 +02:00
|
|
|
hwnd = WINPOS_WindowFromPoint(ptme->hwndTrack, pos, &hittest);
|
|
|
|
TRACE("point %s hwnd %p hittest %d\n", wine_dbgstr_point(&pos), hwnd, hittest);
|
2002-01-15 21:41:41 +01:00
|
|
|
|
2006-07-20 15:27:29 +02:00
|
|
|
if (ptme->dwFlags & ~(TME_CANCEL | TME_HOVER | TME_LEAVE | TME_NONCLIENT))
|
2006-09-30 00:25:15 +02:00
|
|
|
FIXME("Unknown flag(s) %08x\n", ptme->dwFlags & ~(TME_CANCEL | TME_HOVER | TME_LEAVE | TME_NONCLIENT));
|
2002-01-15 21:41:41 +01:00
|
|
|
|
2006-07-20 15:27:29 +02:00
|
|
|
if (ptme->dwFlags & TME_CANCEL)
|
|
|
|
{
|
|
|
|
if (tracking_info.tme.hwndTrack == ptme->hwndTrack)
|
|
|
|
{
|
|
|
|
tracking_info.tme.dwFlags &= ~(ptme->dwFlags & ~TME_CANCEL);
|
2002-01-15 21:41:41 +01:00
|
|
|
|
|
|
|
/* if we aren't tracking on hover or leave remove this entry */
|
2006-07-20 15:27:29 +02:00
|
|
|
if (!(tracking_info.tme.dwFlags & (TME_HOVER | TME_LEAVE)))
|
2002-01-15 21:41:41 +01:00
|
|
|
{
|
2006-07-24 14:19:25 +02:00
|
|
|
KillSystemTimer(tracking_info.tme.hwndTrack, timer);
|
2006-07-20 15:27:29 +02:00
|
|
|
timer = 0;
|
2006-07-24 14:19:25 +02:00
|
|
|
tracking_info.tme.hwndTrack = 0;
|
|
|
|
tracking_info.tme.dwFlags = 0;
|
|
|
|
tracking_info.tme.dwHoverTime = 0;
|
2002-01-15 21:41:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2006-10-16 17:37:40 +02:00
|
|
|
/* In our implementation it's possible that another window will receive a
|
|
|
|
* WM_MOUSEMOVE and call TrackMouseEvent before TrackMouseEventProc is
|
|
|
|
* called. In such a situation post the WM_MOUSELEAVE now */
|
|
|
|
if (tracking_info.tme.dwFlags & TME_LEAVE && tracking_info.tme.hwndTrack != NULL)
|
|
|
|
check_mouse_leave(hwnd, hittest);
|
|
|
|
|
2006-07-24 14:19:25 +02:00
|
|
|
if (timer)
|
|
|
|
{
|
|
|
|
KillSystemTimer(tracking_info.tme.hwndTrack, timer);
|
|
|
|
timer = 0;
|
|
|
|
tracking_info.tme.hwndTrack = 0;
|
|
|
|
tracking_info.tme.dwFlags = 0;
|
|
|
|
tracking_info.tme.dwHoverTime = 0;
|
|
|
|
}
|
|
|
|
|
2006-07-20 15:27:29 +02:00
|
|
|
if (ptme->hwndTrack == hwnd)
|
|
|
|
{
|
2002-01-15 21:41:41 +01:00
|
|
|
/* Adding new mouse event to the tracking list */
|
2006-07-20 15:27:29 +02:00
|
|
|
tracking_info.tme = *ptme;
|
|
|
|
tracking_info.tme.dwHoverTime = hover_time;
|
2002-01-15 21:41:41 +01:00
|
|
|
|
|
|
|
/* Initialize HoverInfo variables even if not hover tracking */
|
2006-07-20 15:27:29 +02:00
|
|
|
tracking_info.pos = pos;
|
2002-01-15 21:41:41 +01:00
|
|
|
|
2006-10-14 20:04:53 +02:00
|
|
|
timer = SetSystemTimer(tracking_info.tme.hwndTrack, (UINT_PTR)&tracking_info.tme, hover_time, TrackMouseEventProc);
|
2002-01-15 21:41:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2008-02-23 09:44:02 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetMouseMovePointsEx [USER32]
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: count of point set in the buffer
|
|
|
|
* Failure: -1
|
|
|
|
*/
|
2020-10-03 01:44:16 +02:00
|
|
|
int WINAPI GetMouseMovePointsEx( UINT size, LPMOUSEMOVEPOINT ptin, LPMOUSEMOVEPOINT ptout, int count, DWORD resolution )
|
|
|
|
{
|
|
|
|
cursor_pos_t *pos, positions[64];
|
|
|
|
int copied;
|
|
|
|
unsigned int i;
|
2008-02-23 09:44:02 +01:00
|
|
|
|
2020-10-03 01:44:16 +02:00
|
|
|
|
|
|
|
TRACE( "%d, %p, %p, %d, %d\n", size, ptin, ptout, count, resolution );
|
|
|
|
|
|
|
|
if ((size != sizeof(MOUSEMOVEPOINT)) || (count < 0) || (count > ARRAY_SIZE( positions )))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
2008-02-23 09:44:02 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-10-03 01:44:16 +02:00
|
|
|
if (!ptin || (!ptout && count))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_NOACCESS );
|
2008-02-23 09:44:02 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-10-03 01:44:16 +02:00
|
|
|
if (resolution != GMMP_USE_DISPLAY_POINTS)
|
|
|
|
{
|
|
|
|
FIXME( "only GMMP_USE_DISPLAY_POINTS is supported for now\n" );
|
|
|
|
SetLastError( ERROR_POINT_NOT_FOUND );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_cursor_history )
|
|
|
|
{
|
|
|
|
wine_server_set_reply( req, &positions, sizeof(positions) );
|
|
|
|
if (wine_server_call_err( req )) return -1;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE( positions ); i++)
|
|
|
|
{
|
|
|
|
pos = &positions[i];
|
|
|
|
if (ptin->x == pos->x && ptin->y == pos->y && (!ptin->time || ptin->time == pos->time))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == ARRAY_SIZE( positions ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_POINT_NOT_FOUND );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (copied = 0; copied < count && i < ARRAY_SIZE( positions ); copied++, i++)
|
|
|
|
{
|
|
|
|
pos = &positions[i];
|
|
|
|
ptout[copied].x = pos->x;
|
|
|
|
ptout[copied].y = pos->y;
|
|
|
|
ptout[copied].time = pos->time;
|
|
|
|
ptout[copied].dwExtraInfo = pos->info;
|
|
|
|
}
|
2008-02-23 09:44:02 +01:00
|
|
|
|
2020-10-03 01:44:16 +02:00
|
|
|
return copied;
|
2008-02-23 09:44:02 +01:00
|
|
|
}
|
2018-04-11 15:24:23 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EnableMouseInPointer (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnableMouseInPointer(BOOL enable)
|
|
|
|
{
|
|
|
|
FIXME("(%#x) stub\n", enable);
|
|
|
|
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2020-05-26 22:01:35 +02:00
|
|
|
|
|
|
|
static DWORD CALLBACK devnotify_window_callback(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header)
|
|
|
|
{
|
|
|
|
SendMessageTimeoutW(handle, WM_DEVICECHANGE, flags, (LPARAM)header, SMTO_ABORTIFHUNG, 2000, NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD CALLBACK devnotify_service_callback(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header)
|
|
|
|
{
|
|
|
|
FIXME("Support for service handles is not yet implemented!\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct device_notification_details
|
|
|
|
{
|
|
|
|
DWORD (CALLBACK *cb)(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header);
|
|
|
|
HANDLE handle;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern HDEVNOTIFY WINAPI I_ScRegisterDeviceNotification( struct device_notification_details *details,
|
|
|
|
void *filter, DWORD flags );
|
|
|
|
extern BOOL WINAPI I_ScUnregisterDeviceNotification( HDEVNOTIFY handle );
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RegisterDeviceNotificationA (USER32.@)
|
|
|
|
*
|
|
|
|
* See RegisterDeviceNotificationW.
|
|
|
|
*/
|
|
|
|
HDEVNOTIFY WINAPI RegisterDeviceNotificationA(HANDLE hRecipient, LPVOID pNotificationFilter, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
TRACE("(hwnd=%p, filter=%p,flags=0x%08x)\n",
|
|
|
|
hRecipient,pNotificationFilter,dwFlags);
|
|
|
|
if (pNotificationFilter)
|
|
|
|
FIXME("The notification filter will requires an A->W when filter support is implemented\n");
|
|
|
|
return RegisterDeviceNotificationW(hRecipient, pNotificationFilter, dwFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RegisterDeviceNotificationW (USER32.@)
|
|
|
|
*/
|
|
|
|
HDEVNOTIFY WINAPI RegisterDeviceNotificationW( HANDLE handle, void *filter, DWORD flags )
|
|
|
|
{
|
|
|
|
struct device_notification_details details;
|
|
|
|
|
|
|
|
TRACE("handle %p, filter %p, flags %#x\n", handle, filter, flags);
|
|
|
|
|
|
|
|
if (flags & ~(DEVICE_NOTIFY_SERVICE_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES))
|
|
|
|
FIXME("unhandled flags %#x\n", flags);
|
|
|
|
|
|
|
|
details.handle = handle;
|
|
|
|
|
|
|
|
if (flags & DEVICE_NOTIFY_SERVICE_HANDLE)
|
|
|
|
details.cb = devnotify_service_callback;
|
|
|
|
else
|
|
|
|
details.cb = devnotify_window_callback;
|
|
|
|
|
|
|
|
return I_ScRegisterDeviceNotification( &details, filter, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* UnregisterDeviceNotification (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI UnregisterDeviceNotification( HDEVNOTIFY handle )
|
|
|
|
{
|
|
|
|
TRACE("%p\n", handle);
|
|
|
|
|
|
|
|
return I_ScUnregisterDeviceNotification( handle );
|
|
|
|
}
|