2004-01-09 01:03:00 +01:00
|
|
|
/*
|
|
|
|
* WinTab32 library
|
|
|
|
*
|
|
|
|
* Copyright 2003 CodeWeavers, Aric Stewart
|
|
|
|
*
|
|
|
|
* 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
|
2004-01-09 01:03:00 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2013-10-22 16:16:09 +02:00
|
|
|
#include "winreg.h"
|
2004-01-09 01:03:00 +01:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winerror.h"
|
2013-02-06 13:19:43 +01:00
|
|
|
#define NOFIX32
|
2004-01-09 01:03:00 +01:00
|
|
|
#include "wintab.h"
|
|
|
|
#include "wintab_internal.h"
|
2013-10-22 16:16:09 +02:00
|
|
|
#include "wine/unicode.h"
|
2004-01-09 01:03:00 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wintab32);
|
|
|
|
|
|
|
|
HWND hwndDefault = NULL;
|
|
|
|
static const WCHAR
|
|
|
|
WC_TABLETCLASSNAME[] = {'W','i','n','e','T','a','b','l','e','t','C','l','a','s','s',0};
|
2011-11-15 14:41:30 +01:00
|
|
|
static CRITICAL_SECTION_DEBUG csTablet_debug =
|
|
|
|
{
|
|
|
|
0, 0, &csTablet,
|
|
|
|
{ &csTablet_debug.ProcessLocksList, &csTablet_debug.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": csTablet") }
|
|
|
|
};
|
|
|
|
CRITICAL_SECTION csTablet = { &csTablet_debug, -1, 0, 0, 0, 0 };
|
2004-01-09 01:03:00 +01:00
|
|
|
|
2008-12-16 14:30:37 +01:00
|
|
|
int (CDECL *pLoadTabletInfo)(HWND hwnddefault) = NULL;
|
|
|
|
int (CDECL *pGetCurrentPacket)(LPWTPACKET packet) = NULL;
|
|
|
|
int (CDECL *pAttachEventQueueToTablet)(HWND hOwner) = NULL;
|
|
|
|
UINT (CDECL *pWTInfoW)(UINT wCategory, UINT nIndex, LPVOID lpOutput) = NULL;
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
static LRESULT WINAPI TABLET_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
|
|
|
|
2005-06-17 12:11:37 +02:00
|
|
|
static VOID TABLET_Register(void)
|
2004-01-09 01:03:00 +01:00
|
|
|
{
|
|
|
|
WNDCLASSW wndClass;
|
|
|
|
ZeroMemory(&wndClass, sizeof(WNDCLASSW));
|
|
|
|
wndClass.style = CS_GLOBALCLASS;
|
|
|
|
wndClass.lpfnWndProc = TABLET_WindowProc;
|
|
|
|
wndClass.cbClsExtra = 0;
|
|
|
|
wndClass.cbWndExtra = 0;
|
2004-12-22 16:13:20 +01:00
|
|
|
wndClass.hCursor = NULL;
|
2004-01-09 01:03:00 +01:00
|
|
|
wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW +1);
|
|
|
|
wndClass.lpszClassName = WC_TABLETCLASSNAME;
|
|
|
|
RegisterClassW(&wndClass);
|
|
|
|
}
|
|
|
|
|
2005-06-17 12:11:37 +02:00
|
|
|
static VOID TABLET_Unregister(void)
|
2004-01-09 01:03:00 +01:00
|
|
|
{
|
2004-12-22 16:13:20 +01:00
|
|
|
UnregisterClassW(WC_TABLETCLASSNAME, NULL);
|
2004-01-09 01:03:00 +01:00
|
|
|
}
|
|
|
|
|
2013-10-22 16:16:09 +02:00
|
|
|
static HMODULE load_graphics_driver(void)
|
|
|
|
{
|
|
|
|
static const WCHAR display_device_guid_propW[] = {
|
|
|
|
'_','_','w','i','n','e','_','d','i','s','p','l','a','y','_',
|
|
|
|
'd','e','v','i','c','e','_','g','u','i','d',0 };
|
|
|
|
static const WCHAR key_pathW[] = {
|
|
|
|
'S','y','s','t','e','m','\\',
|
|
|
|
'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
|
|
|
|
'C','o','n','t','r','o','l','\\',
|
|
|
|
'V','i','d','e','o','\\','{',0};
|
|
|
|
static const WCHAR displayW[] = {'}','\\','0','0','0','0',0};
|
|
|
|
static const WCHAR driverW[] = {'G','r','a','p','h','i','c','s','D','r','i','v','e','r',0};
|
|
|
|
|
|
|
|
HMODULE ret = 0;
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD size;
|
|
|
|
WCHAR path[MAX_PATH];
|
2018-11-16 21:50:37 +01:00
|
|
|
WCHAR key[ARRAY_SIZE(key_pathW) + ARRAY_SIZE(displayW) + 40];
|
2013-10-22 16:16:09 +02:00
|
|
|
UINT guid_atom = HandleToULong( GetPropW( GetDesktopWindow(), display_device_guid_propW ));
|
|
|
|
|
|
|
|
if (!guid_atom) return 0;
|
|
|
|
memcpy( key, key_pathW, sizeof(key_pathW) );
|
|
|
|
if (!GlobalGetAtomNameW( guid_atom, key + strlenW(key), 40 )) return 0;
|
|
|
|
strcatW( key, displayW );
|
|
|
|
if (RegOpenKeyW( HKEY_LOCAL_MACHINE, key, &hkey )) return 0;
|
|
|
|
size = sizeof(path);
|
|
|
|
if (!RegQueryValueExW( hkey, driverW, NULL, NULL, (BYTE *)path, &size )) ret = LoadLibraryW( path );
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
TRACE( "%s %p\n", debugstr_w(path), ret );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved)
|
|
|
|
{
|
|
|
|
static const WCHAR name[] = {'T','a','b','l','e','t',0};
|
|
|
|
|
2006-10-08 19:33:43 +02:00
|
|
|
TRACE("%p, %x, %p\n",hInstDLL,fdwReason,lpReserved);
|
2004-01-09 01:03:00 +01:00
|
|
|
switch (fdwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
TRACE("Initialization\n");
|
2007-09-18 01:53:43 +02:00
|
|
|
DisableThreadLibraryCalls(hInstDLL);
|
2013-02-06 13:19:43 +01:00
|
|
|
TABLET_Register();
|
|
|
|
hwndDefault = CreateWindowW(WC_TABLETCLASSNAME, name,
|
|
|
|
WS_POPUPWINDOW,0,0,0,0,0,0,hInstDLL,0);
|
|
|
|
if (hwndDefault)
|
2004-01-09 01:03:00 +01:00
|
|
|
{
|
2013-10-22 16:16:09 +02:00
|
|
|
HMODULE module = load_graphics_driver();
|
2013-02-06 13:19:43 +01:00
|
|
|
pLoadTabletInfo = (void *)GetProcAddress(module, "LoadTabletInfo");
|
|
|
|
pAttachEventQueueToTablet = (void *)GetProcAddress(module, "AttachEventQueueToTablet");
|
|
|
|
pGetCurrentPacket = (void *)GetProcAddress(module, "GetCurrentPacket");
|
|
|
|
pWTInfoW = (void *)GetProcAddress(module, "WTInfoW");
|
2004-01-09 01:03:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
2013-05-14 11:27:40 +02:00
|
|
|
if (lpReserved) break;
|
2004-01-09 01:03:00 +01:00
|
|
|
TRACE("Detaching\n");
|
2013-05-14 11:27:40 +02:00
|
|
|
if (hwndDefault) DestroyWindow(hwndDefault);
|
2004-01-09 01:03:00 +01:00
|
|
|
TABLET_Unregister();
|
|
|
|
DeleteCriticalSection(&csTablet);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The window proc for the default TABLET window
|
|
|
|
*/
|
|
|
|
static LRESULT WINAPI TABLET_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
2004-01-16 22:26:08 +01:00
|
|
|
TRACE("Incoming Message 0x%x (0x%08x, 0x%08x)\n", uMsg, (UINT)wParam,
|
2004-01-09 01:03:00 +01:00
|
|
|
(UINT)lParam);
|
|
|
|
|
|
|
|
switch(uMsg)
|
|
|
|
{
|
|
|
|
case WM_NCCREATE:
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WT_PACKET:
|
|
|
|
{
|
|
|
|
WTPACKET packet;
|
|
|
|
LPOPENCONTEXT handler;
|
2010-07-20 15:20:07 +02:00
|
|
|
if (pGetCurrentPacket)
|
|
|
|
{
|
|
|
|
pGetCurrentPacket(&packet);
|
|
|
|
handler = AddPacketToContextQueue(&packet,(HWND)lParam);
|
|
|
|
if (handler && handler->context.lcOptions & CXO_MESSAGES)
|
|
|
|
TABLET_PostTabletMessage(handler, _WT_PACKET(handler->context.lcMsgBase),
|
|
|
|
(WPARAM)packet.pkSerialNumber,
|
|
|
|
(LPARAM)handler->handle, FALSE);
|
|
|
|
}
|
2004-01-09 01:03:00 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WT_PROXIMITY:
|
|
|
|
{
|
2005-01-24 13:40:01 +01:00
|
|
|
WTPACKET packet;
|
2004-01-09 01:03:00 +01:00
|
|
|
LPOPENCONTEXT handler;
|
2010-07-20 15:20:07 +02:00
|
|
|
if (pGetCurrentPacket)
|
|
|
|
{
|
|
|
|
pGetCurrentPacket(&packet);
|
|
|
|
handler = AddPacketToContextQueue(&packet,(HWND)wParam);
|
|
|
|
if (handler)
|
|
|
|
TABLET_PostTabletMessage(handler, WT_PROXIMITY,
|
|
|
|
(WPARAM)handler->handle, lParam, TRUE);
|
|
|
|
}
|
2004-01-09 01:03:00 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|