2002-12-17 02:49:16 +01:00
|
|
|
/*
|
|
|
|
* Tablet Context
|
|
|
|
*
|
|
|
|
* Copyright 2002 Patrik Stridvall
|
2004-01-09 01:03:00 +01:00
|
|
|
* Copyright 2003 CodeWeavers, Aric Stewart
|
2002-12-17 02:49:16 +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
|
2002-12-17 02:49:16 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2004-01-09 01:03:00 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2002-12-17 02:49:16 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winerror.h"
|
2004-01-09 01:03:00 +01:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
2007-09-20 22:01:06 +02:00
|
|
|
#include "winnls.h"
|
2002-12-17 02:49:16 +01:00
|
|
|
|
|
|
|
#include "wintab.h"
|
2004-01-09 01:03:00 +01:00
|
|
|
#include "wintab_internal.h"
|
2002-12-17 02:49:16 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wintab32);
|
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
/*
|
|
|
|
* Documentation found at
|
|
|
|
* http://www.csl.sony.co.jp/projects/ar/restricted/wintabl.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
static LPOPENCONTEXT gOpenContexts;
|
|
|
|
static HCTX gTopContext = (HCTX)0xc00;
|
|
|
|
|
2007-09-20 22:02:10 +02:00
|
|
|
static void LOGCONTEXTAtoW(const LOGCONTEXTA *in, LOGCONTEXTW *out)
|
|
|
|
{
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, in->lcName, -1, out->lcName, LCNAMELEN);
|
|
|
|
out->lcName[LCNAMELEN - 1] = 0;
|
|
|
|
/* we use the fact that the fields after lcName are the same in LOGCONTEXTA and W */
|
|
|
|
memcpy(&out->lcOptions, &in->lcOptions, sizeof(LOGCONTEXTA) - FIELD_OFFSET(LOGCONTEXTA, lcOptions));
|
|
|
|
}
|
|
|
|
|
2007-09-20 22:01:06 +02:00
|
|
|
static void LOGCONTEXTWtoA(const LOGCONTEXTW *in, LOGCONTEXTA *out)
|
|
|
|
{
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, in->lcName, LCNAMELEN, out->lcName, LCNAMELEN, NULL, NULL);
|
|
|
|
out->lcName[LCNAMELEN - 1] = 0;
|
|
|
|
/* we use the fact that the fields after lcName are the same in LOGCONTEXTA and W */
|
|
|
|
memcpy(&out->lcOptions, &in->lcOptions, sizeof(LOGCONTEXTW) - FIELD_OFFSET(LOGCONTEXTW, lcOptions));
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_logcontext_category(UINT wCategory)
|
|
|
|
{
|
|
|
|
return wCategory == WTI_DEFSYSCTX || wCategory == WTI_DEFCONTEXT || wCategory == WTI_DDCTXS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_string_field(UINT wCategory, UINT nIndex)
|
|
|
|
{
|
|
|
|
if (wCategory == WTI_INTERFACE && nIndex == IFC_WINTABID)
|
|
|
|
return TRUE;
|
|
|
|
if (is_logcontext_category(wCategory) && nIndex == CTX_NAME)
|
|
|
|
return TRUE;
|
2007-12-24 20:35:32 +01:00
|
|
|
if ((wCategory >= WTI_CURSORS && wCategory <= WTI_CURSORS + 9) &&
|
|
|
|
(nIndex == CSR_NAME || nIndex == CSR_BTNNAMES))
|
2007-09-20 22:01:06 +02:00
|
|
|
return TRUE;
|
|
|
|
if (wCategory == WTI_DEVICES && (nIndex == DVC_NAME || nIndex == DVC_PNPID))
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-12-26 13:25:54 +01:00
|
|
|
static const char* DUMPBITS(int x)
|
2004-01-09 01:03:00 +01:00
|
|
|
{
|
2007-12-26 13:25:54 +01:00
|
|
|
char buf[200];
|
|
|
|
buf[0] = 0;
|
|
|
|
if (x&PK_CONTEXT) strcat(buf,"PK_CONTEXT ");
|
|
|
|
if (x&PK_STATUS) strcat(buf, "PK_STATUS ");
|
|
|
|
if (x&PK_TIME) strcat(buf, "PK_TIME ");
|
|
|
|
if (x&PK_CHANGED) strcat(buf, "PK_CHANGED ");
|
|
|
|
if (x&PK_SERIAL_NUMBER) strcat(buf, "PK_SERIAL_NUMBER ");
|
|
|
|
if (x&PK_CURSOR) strcat(buf, "PK_CURSOR ");
|
|
|
|
if (x&PK_BUTTONS) strcat(buf, "PK_BUTTONS ");
|
|
|
|
if (x&PK_X) strcat(buf, "PK_X ");
|
|
|
|
if (x&PK_Y) strcat(buf, "PK_Y ");
|
|
|
|
if (x&PK_Z) strcat(buf, "PK_Z ");
|
|
|
|
if (x&PK_NORMAL_PRESSURE) strcat(buf, "PK_NORMAL_PRESSURE ");
|
|
|
|
if (x&PK_TANGENT_PRESSURE) strcat(buf, "PK_TANGENT_PRESSURE ");
|
|
|
|
if (x&PK_ORIENTATION) strcat(buf, "PK_ORIENTATION ");
|
|
|
|
if (x&PK_ROTATION) strcat(buf, "PK_ROTATION ");
|
|
|
|
return wine_dbg_sprintf("{%s}",buf);
|
2004-01-09 01:03:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void DUMPPACKET(WTPACKET packet)
|
|
|
|
{
|
2006-10-08 19:33:43 +02:00
|
|
|
TRACE("pkContext: %p pkStatus: 0x%x pkTime : 0x%x pkChanged: 0x%x pkSerialNumber: 0x%x pkCursor : %i pkButtons: %x pkX: %i pkY: %i pkZ: %i pkNormalPressure: %i pkTangentPressure: %i pkOrientation: (%i,%i,%i) pkRotation: (%i,%i,%i)\n",
|
2007-12-26 13:25:54 +01:00
|
|
|
packet.pkContext, packet.pkStatus, packet.pkTime, packet.pkChanged, packet.pkSerialNumber,
|
|
|
|
packet.pkCursor, packet.pkButtons, packet.pkX, packet.pkY, packet.pkZ,
|
|
|
|
packet.pkNormalPressure, packet.pkTangentPressure,
|
|
|
|
packet.pkOrientation.orAzimuth, packet.pkOrientation.orAltitude, packet.pkOrientation.orTwist,
|
|
|
|
packet.pkRotation.roPitch, packet.pkRotation.roRoll, packet.pkRotation.roYaw);
|
2004-01-09 01:03:00 +01:00
|
|
|
}
|
|
|
|
|
2007-09-20 22:02:10 +02:00
|
|
|
static inline void DUMPCONTEXT(LOGCONTEXTW lc)
|
2004-01-09 01:03:00 +01:00
|
|
|
{
|
2008-10-01 18:26:05 +02:00
|
|
|
TRACE("Name: %s, Options: %x, Status: %x, Locks: %x, MsgBase: %x, "
|
|
|
|
"Device: %x, PktRate: %x, "
|
|
|
|
"%x%s, %x%s, %x%s, "
|
|
|
|
"BtnDnMask: %x, BtnUpMask: %x, "
|
|
|
|
"InOrgX: %i, InOrgY: %i, InOrgZ: %i, "
|
|
|
|
"InExtX: %i, InExtY: %i, InExtZ: %i, "
|
|
|
|
"OutOrgX: %i, OutOrgY: %i, OutOrgZ: %i, "
|
|
|
|
"OutExtX: %i, OutExtY: %i, OutExtZ: %i, "
|
|
|
|
"SensX: %i, SensY: %i, SensZ: %i, "
|
|
|
|
"SysMode: %i, "
|
|
|
|
"SysOrgX: %i, SysOrgY: %i, "
|
|
|
|
"SysExtX: %i, SysExtY: %i, "
|
|
|
|
"SysSensX: %i, SysSensY: %i\n",
|
2007-12-26 13:25:54 +01:00
|
|
|
wine_dbgstr_w(lc.lcName), lc.lcOptions, lc.lcStatus, lc.lcLocks, lc.lcMsgBase,
|
|
|
|
lc.lcDevice, lc.lcPktRate, lc.lcPktData, DUMPBITS(lc.lcPktData),
|
|
|
|
lc.lcPktMode, DUMPBITS(lc.lcPktMode), lc.lcMoveMask,
|
|
|
|
DUMPBITS(lc.lcMoveMask), lc.lcBtnDnMask, lc.lcBtnUpMask,
|
|
|
|
lc.lcInOrgX, lc.lcInOrgY, lc.lcInOrgZ, lc.lcInExtX, lc.lcInExtY,
|
|
|
|
lc.lcInExtZ, lc.lcOutOrgX, lc.lcOutOrgY, lc.lcOutOrgZ, lc.lcOutExtX,
|
|
|
|
lc.lcOutExtY, lc.lcOutExtZ, lc.lcSensX, lc.lcSensY, lc.lcSensZ, lc.lcSysMode,
|
|
|
|
lc.lcSysOrgX, lc.lcSysOrgY, lc.lcSysExtX, lc.lcSysExtY, lc.lcSysSensX,
|
|
|
|
lc.lcSysSensY);
|
2004-01-09 01:03:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Find an open context given the handle */
|
|
|
|
static LPOPENCONTEXT TABLET_FindOpenContext(HCTX hCtx)
|
|
|
|
{
|
|
|
|
LPOPENCONTEXT ptr = gOpenContexts;
|
|
|
|
while (ptr)
|
|
|
|
{
|
|
|
|
if (ptr->handle == hCtx) return ptr;
|
|
|
|
ptr = ptr->next;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-03-03 09:26:33 +01:00
|
|
|
static inline BOOL LoadTablet(void)
|
2004-01-09 01:03:00 +01:00
|
|
|
{
|
2011-03-03 09:26:33 +01:00
|
|
|
static enum {TI_START = 0, TI_OK, TI_FAIL} loaded = TI_START;
|
|
|
|
|
|
|
|
if (loaded == TI_START)
|
|
|
|
{
|
|
|
|
if (pLoadTabletInfo && pLoadTabletInfo(hwndDefault))
|
|
|
|
{
|
2018-10-25 16:59:47 +02:00
|
|
|
TRACE("Initialized the tablet to hwnd %p\n", hwndDefault);
|
2011-03-03 09:26:33 +01:00
|
|
|
loaded = TI_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-25 16:59:47 +02:00
|
|
|
TRACE("Failed to initialize the tablet to hwnd %p\n", hwndDefault);
|
2011-03-03 09:26:33 +01:00
|
|
|
loaded = TI_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return loaded == TI_OK;
|
2004-01-09 01:03:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int TABLET_PostTabletMessage(LPOPENCONTEXT newcontext, UINT msg, WPARAM wParam,
|
|
|
|
LPARAM lParam, BOOL send_always)
|
|
|
|
{
|
|
|
|
if ((send_always) || (newcontext->context.lcOptions & CXO_MESSAGES))
|
|
|
|
{
|
2005-09-12 16:12:46 +02:00
|
|
|
TRACE("Posting message %x to %p\n",msg, newcontext->hwndOwner);
|
2004-01-09 01:03:00 +01:00
|
|
|
return PostMessageA(newcontext->hwndOwner, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-17 13:31:59 +01:00
|
|
|
static inline DWORD ScaleForContext(DWORD In, LONG InOrg, LONG InExt, LONG OutOrg, LONG OutExt)
|
2004-01-09 01:03:00 +01:00
|
|
|
{
|
|
|
|
if (((InExt > 0 )&&(OutExt > 0)) || ((InExt<0) && (OutExt < 0)))
|
|
|
|
return ((In - InOrg) * abs(OutExt) / abs(InExt)) + OutOrg;
|
|
|
|
else
|
|
|
|
return ((abs(InExt) - (In - InOrg))*abs(OutExt) / abs(InExt)) + OutOrg;
|
|
|
|
}
|
|
|
|
|
|
|
|
LPOPENCONTEXT AddPacketToContextQueue(LPWTPACKET packet, HWND hwnd)
|
|
|
|
{
|
|
|
|
LPOPENCONTEXT ptr=NULL;
|
|
|
|
|
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
ptr = gOpenContexts;
|
|
|
|
while (ptr)
|
|
|
|
{
|
|
|
|
TRACE("Trying Queue %p (%p %p)\n", ptr->handle, hwnd, ptr->hwndOwner);
|
|
|
|
|
|
|
|
if (ptr->hwndOwner == hwnd)
|
|
|
|
{
|
|
|
|
int tgt;
|
|
|
|
if (!ptr->enabled)
|
|
|
|
{
|
|
|
|
ptr = ptr->next;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
tgt = ptr->PacketsQueued;
|
|
|
|
|
|
|
|
packet->pkContext = ptr->handle;
|
|
|
|
|
|
|
|
/* translate packet data to the context */
|
|
|
|
|
|
|
|
/* Scale as per documentation */
|
|
|
|
packet->pkY = ScaleForContext(packet->pkY, ptr->context.lcInOrgY,
|
|
|
|
ptr->context.lcInExtY, ptr->context.lcOutOrgY,
|
|
|
|
ptr->context.lcOutExtY);
|
|
|
|
|
|
|
|
packet->pkX = ScaleForContext(packet->pkX, ptr->context.lcInOrgX,
|
|
|
|
ptr->context.lcInExtX, ptr->context.lcOutOrgX,
|
|
|
|
ptr->context.lcOutExtX);
|
|
|
|
|
|
|
|
/* flip the Y axis */
|
|
|
|
if (ptr->context.lcOutExtY > 0)
|
|
|
|
packet->pkY = ptr->context.lcOutExtY - packet->pkY;
|
2008-09-30 00:20:15 +02:00
|
|
|
else if (ptr->context.lcOutExtY < 0)
|
|
|
|
packet->pkY = abs(ptr->context.lcOutExtY + packet->pkY);
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
DUMPPACKET(*packet);
|
|
|
|
|
2005-01-24 14:32:55 +01:00
|
|
|
if (tgt == ptr->QueueSize)
|
2004-01-09 01:03:00 +01:00
|
|
|
{
|
|
|
|
TRACE("Queue Overflow %p\n",ptr->handle);
|
2005-01-24 14:32:55 +01:00
|
|
|
ptr->PacketQueue[tgt-1].pkStatus |= TPS_QUEUE_ERR;
|
2004-01-09 01:03:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Placed in queue %p index %i\n",ptr->handle,tgt);
|
2008-03-22 18:10:10 +01:00
|
|
|
ptr->PacketQueue[tgt] = *packet;
|
2004-01-09 01:03:00 +01:00
|
|
|
ptr->PacketsQueued++;
|
|
|
|
|
|
|
|
if (ptr->ActiveCursor != packet->pkCursor)
|
|
|
|
{
|
|
|
|
ptr->ActiveCursor = packet->pkCursor;
|
|
|
|
if (ptr->context.lcOptions & CXO_CSRMESSAGES)
|
2005-01-24 13:40:01 +01:00
|
|
|
TABLET_PostTabletMessage(ptr, _WT_CSRCHANGE(ptr->context.lcMsgBase),
|
2004-01-09 01:03:00 +01:00
|
|
|
(WPARAM)packet->pkSerialNumber, (LPARAM)ptr->handle,
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ptr = ptr->next;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
TRACE("Done (%p)\n",ptr);
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2005-01-24 14:36:21 +01:00
|
|
|
/*
|
|
|
|
* Flushes all packets from the queue.
|
|
|
|
*/
|
2007-03-23 16:10:45 +01:00
|
|
|
static inline void TABLET_FlushQueue(LPOPENCONTEXT context)
|
2005-01-24 14:36:21 +01:00
|
|
|
{
|
|
|
|
context->PacketsQueued = 0;
|
|
|
|
}
|
|
|
|
|
2007-03-23 16:10:45 +01:00
|
|
|
static inline int CopyTabletData(LPVOID target, LPVOID src, INT size)
|
2004-01-09 01:03:00 +01:00
|
|
|
{
|
|
|
|
memcpy(target,src,size);
|
|
|
|
return(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT TABLET_FindPacket(LPOPENCONTEXT context, UINT wSerial,
|
|
|
|
LPWTPACKET *pkt)
|
|
|
|
{
|
|
|
|
int loop;
|
|
|
|
int index = -1;
|
|
|
|
for (loop = 0; loop < context->PacketsQueued; loop++)
|
|
|
|
if (context->PacketQueue[loop].pkSerialNumber == wSerial)
|
|
|
|
{
|
|
|
|
index = loop;
|
|
|
|
*pkt = &context->PacketQueue[loop];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("%i .. %i\n",context->PacketsQueued,index);
|
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LPVOID TABLET_CopyPacketData(LPOPENCONTEXT context, LPVOID lpPkt,
|
|
|
|
LPWTPACKET wtp)
|
|
|
|
{
|
|
|
|
LPBYTE ptr;
|
|
|
|
|
|
|
|
ptr = lpPkt;
|
2007-12-26 13:25:54 +01:00
|
|
|
TRACE("Packet Bits %s\n",DUMPBITS(context->context.lcPktData));
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
if (context->context.lcPktData & PK_CONTEXT)
|
|
|
|
ptr+=CopyTabletData(ptr,&wtp->pkContext,sizeof(HCTX));
|
|
|
|
if (context->context.lcPktData & PK_STATUS)
|
|
|
|
ptr+=CopyTabletData(ptr,&wtp->pkStatus,sizeof(UINT));
|
|
|
|
if (context->context.lcPktData & PK_TIME)
|
|
|
|
ptr+=CopyTabletData(ptr,&wtp->pkTime,sizeof(LONG));
|
|
|
|
if (context->context.lcPktData & PK_CHANGED)
|
|
|
|
ptr+=CopyTabletData(ptr,&wtp->pkChanged,sizeof(WTPKT));
|
|
|
|
if (context->context.lcPktData & PK_SERIAL_NUMBER)
|
2014-03-20 08:16:22 +01:00
|
|
|
ptr+=CopyTabletData(ptr,&wtp->pkSerialNumber,sizeof(UINT));
|
2004-01-09 01:03:00 +01:00
|
|
|
if (context->context.lcPktData & PK_CURSOR)
|
|
|
|
ptr+=CopyTabletData(ptr,&wtp->pkCursor,sizeof(UINT));
|
|
|
|
if (context->context.lcPktData & PK_BUTTONS)
|
|
|
|
ptr+=CopyTabletData(ptr,&wtp->pkButtons,sizeof(DWORD));
|
|
|
|
if (context->context.lcPktData & PK_X)
|
|
|
|
ptr+=CopyTabletData(ptr,&wtp->pkX,sizeof(DWORD));
|
|
|
|
if (context->context.lcPktData & PK_Y)
|
|
|
|
ptr+=CopyTabletData(ptr,&wtp->pkY,sizeof(DWORD));
|
|
|
|
if (context->context.lcPktData & PK_Z)
|
|
|
|
ptr+=CopyTabletData(ptr,&wtp->pkZ,sizeof(DWORD));
|
|
|
|
if (context->context.lcPktData & PK_NORMAL_PRESSURE)
|
|
|
|
ptr+=CopyTabletData(ptr,&wtp->pkNormalPressure,sizeof(UINT));
|
|
|
|
if (context->context.lcPktData & PK_TANGENT_PRESSURE)
|
|
|
|
ptr+=CopyTabletData(ptr,&wtp->pkTangentPressure,sizeof(UINT));
|
|
|
|
if (context->context.lcPktData & PK_ORIENTATION)
|
|
|
|
ptr+=CopyTabletData(ptr,&wtp->pkOrientation,sizeof(ORIENTATION));
|
|
|
|
if (context->context.lcPktData & PK_ROTATION)
|
|
|
|
ptr+=CopyTabletData(ptr,&wtp->pkRotation,sizeof(ROTATION));
|
|
|
|
|
|
|
|
/*TRACE("Copied %i bytes\n",(INT)ptr - (INT)lpPkt); */
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID TABLET_BlankPacketData(LPOPENCONTEXT context, LPVOID lpPkt, INT n)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
if (context->context.lcPktData & PK_CONTEXT)
|
|
|
|
rc +=sizeof(HCTX);
|
|
|
|
if (context->context.lcPktData & PK_STATUS)
|
|
|
|
rc +=sizeof(UINT);
|
|
|
|
if (context->context.lcPktData & PK_TIME)
|
|
|
|
rc += sizeof(LONG);
|
|
|
|
if (context->context.lcPktData & PK_CHANGED)
|
|
|
|
rc += sizeof(WTPKT);
|
|
|
|
if (context->context.lcPktData & PK_SERIAL_NUMBER)
|
|
|
|
rc += sizeof(UINT);
|
|
|
|
if (context->context.lcPktData & PK_CURSOR)
|
|
|
|
rc += sizeof(UINT);
|
|
|
|
if (context->context.lcPktData & PK_BUTTONS)
|
|
|
|
rc += sizeof(DWORD);
|
|
|
|
if (context->context.lcPktData & PK_X)
|
|
|
|
rc += sizeof(DWORD);
|
|
|
|
if (context->context.lcPktData & PK_Y)
|
|
|
|
rc += sizeof(DWORD);
|
|
|
|
if (context->context.lcPktData & PK_Z)
|
|
|
|
rc += sizeof(DWORD);
|
|
|
|
if (context->context.lcPktData & PK_NORMAL_PRESSURE)
|
|
|
|
rc += sizeof(UINT);
|
|
|
|
if (context->context.lcPktData & PK_TANGENT_PRESSURE)
|
|
|
|
rc += sizeof(UINT);
|
|
|
|
if (context->context.lcPktData & PK_ORIENTATION)
|
|
|
|
rc += sizeof(ORIENTATION);
|
|
|
|
if (context->context.lcPktData & PK_ROTATION)
|
|
|
|
rc += sizeof(ROTATION);
|
|
|
|
|
|
|
|
rc *= n;
|
|
|
|
memset(lpPkt,0,rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-04 12:48:29 +01:00
|
|
|
static UINT WTInfoT(UINT wCategory, UINT nIndex, LPVOID lpOutput, BOOL bUnicode)
|
2002-12-17 02:49:16 +01:00
|
|
|
{
|
2004-12-06 17:07:33 +01:00
|
|
|
UINT result;
|
2007-12-30 18:41:54 +01:00
|
|
|
|
2011-03-03 09:26:33 +01:00
|
|
|
if (!LoadTablet()) return 0;
|
|
|
|
|
2007-12-30 18:41:54 +01:00
|
|
|
TRACE("(%d, %d, %p, %d)\n", wCategory, nIndex, lpOutput, bUnicode);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-12-06 17:07:33 +01:00
|
|
|
/*
|
|
|
|
* Handle system extents here, as we can use user32.dll code to set them.
|
|
|
|
*/
|
|
|
|
if(wCategory == WTI_DEFSYSCTX)
|
|
|
|
{
|
|
|
|
switch(nIndex)
|
|
|
|
{
|
|
|
|
case CTX_SYSEXTX:
|
|
|
|
if(lpOutput != NULL)
|
|
|
|
*(LONG*)lpOutput = GetSystemMetrics(SM_CXSCREEN);
|
|
|
|
return sizeof(LONG);
|
|
|
|
case CTX_SYSEXTY:
|
|
|
|
if(lpOutput != NULL)
|
|
|
|
*(LONG*)lpOutput = GetSystemMetrics(SM_CYSCREEN);
|
|
|
|
return sizeof(LONG);
|
|
|
|
/* No action, delegate to X11Drv */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-20 22:01:06 +02:00
|
|
|
if (is_logcontext_category(wCategory) && nIndex == 0)
|
|
|
|
{
|
|
|
|
if (lpOutput)
|
|
|
|
{
|
|
|
|
LOGCONTEXTW buf;
|
|
|
|
pWTInfoW(wCategory, nIndex, &buf);
|
2004-12-06 17:07:33 +01:00
|
|
|
|
2007-09-20 22:01:06 +02:00
|
|
|
/* Handle system extents here, as we can use user32.dll code to set them */
|
2015-01-12 11:28:30 +01:00
|
|
|
if(wCategory == WTI_DEFSYSCTX)
|
2007-09-20 22:01:06 +02:00
|
|
|
{
|
|
|
|
buf.lcSysExtX = GetSystemMetrics(SM_CXSCREEN);
|
|
|
|
buf.lcSysExtY = GetSystemMetrics(SM_CYSCREEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bUnicode)
|
|
|
|
memcpy(lpOutput, &buf, sizeof(buf));
|
|
|
|
else
|
|
|
|
LOGCONTEXTWtoA(&buf, lpOutput);
|
|
|
|
}
|
|
|
|
|
2007-12-30 18:41:54 +01:00
|
|
|
result = bUnicode ? sizeof(LOGCONTEXTW) : sizeof(LOGCONTEXTA);
|
2007-09-20 22:01:06 +02:00
|
|
|
}
|
|
|
|
else if (is_string_field(wCategory, nIndex) && !bUnicode)
|
2004-12-06 17:07:33 +01:00
|
|
|
{
|
2007-09-20 22:01:06 +02:00
|
|
|
int size = pWTInfoW(wCategory, nIndex, NULL);
|
|
|
|
WCHAR *buf = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
pWTInfoW(wCategory, nIndex, buf);
|
|
|
|
result = WideCharToMultiByte(CP_ACP, 0, buf, size/sizeof(WCHAR), lpOutput, lpOutput ? 2*size : 0, NULL, NULL);
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2004-12-06 17:07:33 +01:00
|
|
|
}
|
2007-09-20 22:01:06 +02:00
|
|
|
else
|
|
|
|
result = pWTInfoW(wCategory, nIndex, lpOutput);
|
|
|
|
|
2007-12-30 18:41:54 +01:00
|
|
|
TRACE("returns %d\n", result);
|
2004-12-06 17:07:33 +01:00
|
|
|
return result;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2007-09-20 22:01:06 +02:00
|
|
|
* WTInfoA (WINTAB32.20)
|
2002-12-17 02:49:16 +01:00
|
|
|
*/
|
2007-09-20 22:01:06 +02:00
|
|
|
UINT WINAPI WTInfoA(UINT wCategory, UINT nIndex, LPVOID lpOutput)
|
2002-12-17 02:49:16 +01:00
|
|
|
{
|
2007-09-20 22:01:06 +02:00
|
|
|
return WTInfoT(wCategory, nIndex, lpOutput, FALSE);
|
|
|
|
}
|
2002-12-17 02:49:16 +01:00
|
|
|
|
|
|
|
|
2007-09-20 22:01:06 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* WTInfoW (WINTAB32.1020)
|
|
|
|
*/
|
|
|
|
UINT WINAPI WTInfoW(UINT wCategory, UINT nIndex, LPVOID lpOutput)
|
|
|
|
{
|
|
|
|
return WTInfoT(wCategory, nIndex, lpOutput, TRUE);
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2018-09-13 17:29:22 +02:00
|
|
|
* WTOpenW (WINTAB32.1021)
|
2002-12-17 02:49:16 +01:00
|
|
|
*/
|
2007-09-20 22:02:10 +02:00
|
|
|
HCTX WINAPI WTOpenW(HWND hWnd, LPLOGCONTEXTW lpLogCtx, BOOL fEnable)
|
2002-12-17 02:49:16 +01:00
|
|
|
{
|
2004-01-09 01:03:00 +01:00
|
|
|
LPOPENCONTEXT newcontext;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2011-03-03 09:26:33 +01:00
|
|
|
if (!LoadTablet()) return 0;
|
|
|
|
|
2008-04-29 07:21:30 +02:00
|
|
|
TRACE("hWnd=%p, lpLogCtx=%p, fEnable=%u\n", hWnd, lpLogCtx, fEnable);
|
2004-01-09 01:03:00 +01:00
|
|
|
DUMPCONTEXT(*lpLogCtx);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
newcontext = HeapAlloc(GetProcessHeap(), 0 , sizeof(OPENCONTEXT));
|
2008-03-22 18:10:10 +01:00
|
|
|
newcontext->context = *lpLogCtx;
|
2004-01-09 01:03:00 +01:00
|
|
|
newcontext->hwndOwner = hWnd;
|
|
|
|
newcontext->ActiveCursor = -1;
|
|
|
|
newcontext->QueueSize = 10;
|
|
|
|
newcontext->PacketsQueued = 0;
|
|
|
|
newcontext->PacketQueue=HeapAlloc(GetProcessHeap(),0,sizeof(WTPACKET)*10);
|
|
|
|
|
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
newcontext->handle = gTopContext++;
|
|
|
|
newcontext->next = gOpenContexts;
|
|
|
|
gOpenContexts = newcontext;
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
pAttachEventQueueToTablet(hWnd);
|
|
|
|
|
2005-01-24 13:40:01 +01:00
|
|
|
TABLET_PostTabletMessage(newcontext, _WT_CTXOPEN(newcontext->context.lcMsgBase), (WPARAM)newcontext->handle,
|
2004-01-09 01:03:00 +01:00
|
|
|
newcontext->context.lcStatus, TRUE);
|
|
|
|
|
2008-04-29 07:21:30 +02:00
|
|
|
if (fEnable)
|
|
|
|
{
|
|
|
|
newcontext->enabled = TRUE;
|
|
|
|
/* TODO: Add to top of overlap order */
|
|
|
|
newcontext->context.lcStatus = CXS_ONTOP;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newcontext->enabled = FALSE;
|
|
|
|
newcontext->context.lcStatus = CXS_DISABLED;
|
|
|
|
}
|
2004-01-09 01:03:00 +01:00
|
|
|
|
2005-01-24 13:40:01 +01:00
|
|
|
TABLET_PostTabletMessage(newcontext, _WT_CTXOVERLAP(newcontext->context.lcMsgBase),
|
2004-01-09 01:03:00 +01:00
|
|
|
(WPARAM)newcontext->handle,
|
|
|
|
newcontext->context.lcStatus, TRUE);
|
|
|
|
|
|
|
|
return newcontext->handle;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2007-09-20 22:02:10 +02:00
|
|
|
* WTOpenA (WINTAB32.21)
|
2002-12-17 02:49:16 +01:00
|
|
|
*/
|
2007-09-20 22:02:10 +02:00
|
|
|
HCTX WINAPI WTOpenA(HWND hWnd, LPLOGCONTEXTA lpLogCtx, BOOL fEnable)
|
2002-12-17 02:49:16 +01:00
|
|
|
{
|
2007-09-20 22:02:10 +02:00
|
|
|
LOGCONTEXTW logCtxW;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2007-09-20 22:02:10 +02:00
|
|
|
LOGCONTEXTAtoW(lpLogCtx, &logCtxW);
|
|
|
|
return WTOpenW(hWnd, &logCtxW, fEnable);
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTClose (WINTAB32.22)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTClose(HCTX hCtx)
|
|
|
|
{
|
2004-01-09 01:03:00 +01:00
|
|
|
LPOPENCONTEXT context,ptr;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
TRACE("(%p)\n", hCtx);
|
|
|
|
|
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
ptr = context = gOpenContexts;
|
|
|
|
|
|
|
|
while (context && (context->handle != hCtx))
|
|
|
|
{
|
|
|
|
ptr = context;
|
|
|
|
context = context->next;
|
|
|
|
}
|
|
|
|
if (!context)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (context == gOpenContexts)
|
|
|
|
gOpenContexts = context->next;
|
|
|
|
else
|
|
|
|
ptr->next = context->next;
|
|
|
|
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
|
2005-01-24 13:40:01 +01:00
|
|
|
TABLET_PostTabletMessage(context, _WT_CTXCLOSE(context->context.lcMsgBase), (WPARAM)context->handle,
|
2004-01-09 01:03:00 +01:00
|
|
|
context->context.lcStatus,TRUE);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(),0,context->PacketQueue);
|
|
|
|
HeapFree(GetProcessHeap(),0,context);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTPacketsGet (WINTAB32.23)
|
|
|
|
*/
|
|
|
|
int WINAPI WTPacketsGet(HCTX hCtx, int cMaxPkts, LPVOID lpPkts)
|
|
|
|
{
|
2004-01-09 01:03:00 +01:00
|
|
|
int limit;
|
|
|
|
LPOPENCONTEXT context;
|
|
|
|
LPVOID ptr = lpPkts;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
TRACE("(%p, %d, %p)\n", hCtx, cMaxPkts, lpPkts);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-11-28 15:54:26 +01:00
|
|
|
if (!hCtx)
|
|
|
|
return 0;
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
context = TABLET_FindOpenContext(hCtx);
|
2010-07-20 15:20:07 +02:00
|
|
|
if (!context)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
return 0;
|
|
|
|
}
|
2004-11-28 15:54:26 +01:00
|
|
|
|
|
|
|
if (lpPkts != NULL)
|
|
|
|
TABLET_BlankPacketData(context,lpPkts,cMaxPkts);
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
if (context->PacketsQueued == 0)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-11-28 15:54:26 +01:00
|
|
|
limit = min(cMaxPkts,context->PacketsQueued);
|
|
|
|
|
|
|
|
if(ptr != NULL)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
for(i = 0; i < limit; i++)
|
|
|
|
ptr=TABLET_CopyPacketData(context ,ptr, &context->PacketQueue[i]);
|
|
|
|
}
|
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
if (limit < context->PacketsQueued)
|
|
|
|
{
|
2004-11-28 15:54:26 +01:00
|
|
|
memmove(context->PacketQueue, &context->PacketQueue[limit],
|
|
|
|
(context->PacketsQueued - (limit))*sizeof(WTPACKET));
|
2004-01-09 01:03:00 +01:00
|
|
|
}
|
|
|
|
context->PacketsQueued -= limit;
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
TRACE("Copied %i packets\n",limit);
|
|
|
|
|
|
|
|
return limit;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTPacket (WINTAB32.24)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTPacket(HCTX hCtx, UINT wSerial, LPVOID lpPkt)
|
|
|
|
{
|
2004-01-09 01:03:00 +01:00
|
|
|
int rc = 0;
|
|
|
|
LPOPENCONTEXT context;
|
2005-05-24 14:34:29 +02:00
|
|
|
LPWTPACKET wtp = NULL;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
TRACE("(%p, %d, %p)\n", hCtx, wSerial, lpPkt);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-11-28 15:54:26 +01:00
|
|
|
if (!hCtx)
|
2013-11-27 08:52:01 +01:00
|
|
|
return FALSE;
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
context = TABLET_FindOpenContext(hCtx);
|
2010-07-20 15:20:07 +02:00
|
|
|
if (!context)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
2013-11-27 08:52:01 +01:00
|
|
|
return FALSE;
|
2010-07-20 15:20:07 +02:00
|
|
|
}
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
rc = TABLET_FindPacket(context ,wSerial, &wtp);
|
|
|
|
|
|
|
|
if (rc >= 0)
|
|
|
|
{
|
|
|
|
if (lpPkt)
|
|
|
|
TABLET_CopyPacketData(context ,lpPkt, wtp);
|
|
|
|
|
|
|
|
if ((rc+1) < context->QueueSize)
|
|
|
|
{
|
2004-11-28 15:54:26 +01:00
|
|
|
memmove(context->PacketQueue, &context->PacketQueue[rc+1],
|
|
|
|
(context->PacketsQueued - (rc+1))*sizeof(WTPACKET));
|
2004-01-09 01:03:00 +01:00
|
|
|
}
|
|
|
|
context->PacketsQueued -= (rc+1);
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
TRACE("Returning %i\n",rc+1);
|
|
|
|
return rc+1;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTEnable (WINTAB32.40)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTEnable(HCTX hCtx, BOOL fEnable)
|
|
|
|
{
|
2004-01-09 01:03:00 +01:00
|
|
|
LPOPENCONTEXT context;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2008-04-29 07:37:55 +02:00
|
|
|
TRACE("hCtx=%p, fEnable=%u\n", hCtx, fEnable);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2008-04-29 07:37:55 +02:00
|
|
|
if (!hCtx) return FALSE;
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
context = TABLET_FindOpenContext(hCtx);
|
2010-07-20 15:20:07 +02:00
|
|
|
if (!context)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
2013-11-27 08:52:01 +01:00
|
|
|
return FALSE;
|
2010-07-20 15:20:07 +02:00
|
|
|
}
|
|
|
|
|
2008-04-29 07:37:55 +02:00
|
|
|
/* if we want to enable and it is not enabled then */
|
|
|
|
if(fEnable && !context->enabled)
|
|
|
|
{
|
|
|
|
context->enabled = TRUE;
|
|
|
|
/* TODO: Add to top of overlap order */
|
|
|
|
context->context.lcStatus = CXS_ONTOP;
|
2008-10-07 08:05:51 +02:00
|
|
|
TABLET_PostTabletMessage(context,
|
|
|
|
_WT_CTXOVERLAP(context->context.lcMsgBase),
|
|
|
|
(WPARAM)context->handle,
|
|
|
|
context->context.lcStatus, TRUE);
|
2008-04-29 07:37:55 +02:00
|
|
|
}
|
|
|
|
/* if we want to disable and it is not disabled then */
|
|
|
|
else if (!fEnable && context->enabled)
|
|
|
|
{
|
|
|
|
context->enabled = FALSE;
|
|
|
|
/* TODO: Remove from overlap order?? needs a test */
|
|
|
|
context->context.lcStatus = CXS_DISABLED;
|
2005-01-24 14:36:21 +01:00
|
|
|
TABLET_FlushQueue(context);
|
2008-10-07 08:05:51 +02:00
|
|
|
TABLET_PostTabletMessage(context,
|
|
|
|
_WT_CTXOVERLAP(context->context.lcMsgBase),
|
|
|
|
(WPARAM)context->handle,
|
|
|
|
context->context.lcStatus, TRUE);
|
2008-04-29 07:37:55 +02:00
|
|
|
}
|
2004-01-09 01:03:00 +01:00
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
return TRUE;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTOverlap (WINTAB32.41)
|
2008-04-29 07:51:20 +02:00
|
|
|
*
|
|
|
|
* Move context to top or bottom of overlap order
|
2002-12-17 02:49:16 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI WTOverlap(HCTX hCtx, BOOL fToTop)
|
|
|
|
{
|
2008-04-29 07:51:20 +02:00
|
|
|
LPOPENCONTEXT context;
|
|
|
|
|
|
|
|
TRACE("hCtx=%p, fToTop=%u\n", hCtx, fToTop);
|
|
|
|
|
|
|
|
if (!hCtx) return FALSE;
|
|
|
|
|
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
context = TABLET_FindOpenContext(hCtx);
|
2009-01-07 00:46:04 +01:00
|
|
|
if (!context)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-07 08:05:51 +02:00
|
|
|
/* if we want to send to top and it's not already there */
|
|
|
|
if (fToTop && context->context.lcStatus != CXS_ONTOP)
|
2008-04-29 07:51:20 +02:00
|
|
|
{
|
|
|
|
/* TODO: Move context to top of overlap order */
|
|
|
|
FIXME("Not moving context to top of overlap order\n");
|
|
|
|
context->context.lcStatus = CXS_ONTOP;
|
2008-10-07 08:05:51 +02:00
|
|
|
TABLET_PostTabletMessage(context,
|
|
|
|
_WT_CTXOVERLAP(context->context.lcMsgBase),
|
|
|
|
(WPARAM)context->handle,
|
|
|
|
context->context.lcStatus, TRUE);
|
2008-04-29 07:51:20 +02:00
|
|
|
}
|
2008-10-07 08:05:51 +02:00
|
|
|
else if (!fToTop)
|
2008-04-29 07:51:20 +02:00
|
|
|
{
|
|
|
|
/* TODO: Move context to bottom of overlap order */
|
|
|
|
FIXME("Not moving context to bottom of overlap order\n");
|
|
|
|
context->context.lcStatus = CXS_OBSCURED;
|
2008-10-07 08:05:51 +02:00
|
|
|
TABLET_PostTabletMessage(context,
|
|
|
|
_WT_CTXOVERLAP(context->context.lcMsgBase),
|
|
|
|
(WPARAM)context->handle,
|
|
|
|
context->context.lcStatus, TRUE);
|
2008-04-29 07:51:20 +02:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&csTablet);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
return TRUE;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2018-09-13 17:29:22 +02:00
|
|
|
* WTConfig (WINTAB32.60)
|
2002-12-17 02:49:16 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI WTConfig(HCTX hCtx, HWND hWnd)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p): stub\n", hCtx, hWnd);
|
|
|
|
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTGetA (WINTAB32.61)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTGetA(HCTX hCtx, LPLOGCONTEXTA lpLogCtx)
|
|
|
|
{
|
2004-01-09 01:03:00 +01:00
|
|
|
LPOPENCONTEXT context;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
TRACE("(%p, %p)\n", hCtx, lpLogCtx);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2013-11-27 08:52:01 +01:00
|
|
|
if (!hCtx) return FALSE;
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
context = TABLET_FindOpenContext(hCtx);
|
2010-07-20 15:20:07 +02:00
|
|
|
if (!context)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
2013-11-27 08:52:01 +01:00
|
|
|
return FALSE;
|
2010-07-20 15:20:07 +02:00
|
|
|
}
|
|
|
|
|
2007-09-20 22:02:10 +02:00
|
|
|
LOGCONTEXTWtoA(&context->context, lpLogCtx);
|
2004-01-09 01:03:00 +01:00
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
return TRUE;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTGetW (WINTAB32.1061)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTGetW(HCTX hCtx, LPLOGCONTEXTW lpLogCtx)
|
|
|
|
{
|
2007-09-20 22:02:10 +02:00
|
|
|
LPOPENCONTEXT context;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2007-09-20 22:02:10 +02:00
|
|
|
TRACE("(%p, %p)\n", hCtx, lpLogCtx);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2013-11-27 08:52:01 +01:00
|
|
|
if (!hCtx) return FALSE;
|
2007-09-20 22:02:10 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
context = TABLET_FindOpenContext(hCtx);
|
2010-07-20 15:20:07 +02:00
|
|
|
if (!context)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
2013-11-27 08:52:01 +01:00
|
|
|
return FALSE;
|
2010-07-20 15:20:07 +02:00
|
|
|
}
|
|
|
|
|
2007-09-20 22:02:10 +02:00
|
|
|
memmove(lpLogCtx,&context->context,sizeof(LOGCONTEXTW));
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
return TRUE;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTSetA (WINTAB32.62)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSetA(HCTX hCtx, LPLOGCONTEXTA lpLogCtx)
|
|
|
|
{
|
2008-04-10 01:44:36 +02:00
|
|
|
LPOPENCONTEXT context;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2008-04-10 01:44:36 +02:00
|
|
|
TRACE("hCtx=%p, lpLogCtx=%p\n", hCtx, lpLogCtx);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2008-04-10 01:44:36 +02:00
|
|
|
if (!hCtx || !lpLogCtx) return FALSE;
|
|
|
|
|
|
|
|
/* TODO: if cur process not owner of hCtx only modify
|
|
|
|
* attribs not locked by owner */
|
|
|
|
|
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
context = TABLET_FindOpenContext(hCtx);
|
2009-01-07 00:46:04 +01:00
|
|
|
if (!context)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-04-10 01:44:36 +02:00
|
|
|
LOGCONTEXTAtoW(lpLogCtx, &context->context);
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
return TRUE;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTSetW (WINTAB32.1062)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSetW(HCTX hCtx, LPLOGCONTEXTW lpLogCtx)
|
|
|
|
{
|
2008-04-10 01:44:36 +02:00
|
|
|
LPOPENCONTEXT context;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2008-04-10 01:44:36 +02:00
|
|
|
TRACE("hCtx=%p, lpLogCtx=%p\n", hCtx, lpLogCtx);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2008-04-10 01:44:36 +02:00
|
|
|
if (!hCtx || !lpLogCtx) return FALSE;
|
|
|
|
|
|
|
|
/* TODO: if cur process not hCtx owner only modify
|
|
|
|
* attribs not locked by owner */
|
|
|
|
|
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
context = TABLET_FindOpenContext(hCtx);
|
2009-01-07 00:46:04 +01:00
|
|
|
if (!context)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-04-10 01:44:36 +02:00
|
|
|
memmove(&context->context, lpLogCtx, sizeof(LOGCONTEXTW));
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
return TRUE;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTExtGet (WINTAB32.63)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTExtGet(HCTX hCtx, UINT wExt, LPVOID lpData)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %u, %p): stub\n", hCtx, wExt, lpData);
|
|
|
|
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTExtSet (WINTAB32.64)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTExtSet(HCTX hCtx, UINT wExt, LPVOID lpData)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %u, %p): stub\n", hCtx, wExt, lpData);
|
|
|
|
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTSave (WINTAB32.65)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTSave(HCTX hCtx, LPVOID lpSaveInfo)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p): stub\n", hCtx, lpSaveInfo);
|
|
|
|
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTRestore (WINTAB32.66)
|
|
|
|
*/
|
|
|
|
HCTX WINAPI WTRestore(HWND hWnd, LPVOID lpSaveInfo, BOOL fEnable)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %u): stub\n", hWnd, lpSaveInfo, fEnable);
|
|
|
|
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTPacketsPeek (WINTAB32.80)
|
|
|
|
*/
|
|
|
|
int WINAPI WTPacketsPeek(HCTX hCtx, int cMaxPkts, LPVOID lpPkts)
|
|
|
|
{
|
2004-01-09 01:03:00 +01:00
|
|
|
int limit;
|
|
|
|
LPOPENCONTEXT context;
|
|
|
|
LPVOID ptr = lpPkts;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
TRACE("(%p, %d, %p)\n", hCtx, cMaxPkts, lpPkts);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
if (!hCtx || !lpPkts) return 0;
|
|
|
|
|
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
context = TABLET_FindOpenContext(hCtx);
|
|
|
|
|
2010-07-20 15:20:07 +02:00
|
|
|
if (!context || context->PacketsQueued == 0)
|
2004-01-09 01:03:00 +01:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (limit = 0; limit < cMaxPkts && limit < context->PacketsQueued; limit++)
|
|
|
|
ptr = TABLET_CopyPacketData(context ,ptr, &context->PacketQueue[limit]);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
TRACE("Copied %i packets\n",limit);
|
|
|
|
return limit;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTDataGet (WINTAB32.81)
|
|
|
|
*/
|
|
|
|
int WINAPI WTDataGet(HCTX hCtx, UINT wBegin, UINT wEnd,
|
|
|
|
int cMaxPkts, LPVOID lpPkts, LPINT lpNPkts)
|
|
|
|
{
|
2004-01-09 01:03:00 +01:00
|
|
|
LPOPENCONTEXT context;
|
|
|
|
LPVOID ptr = lpPkts;
|
2004-09-22 04:46:38 +02:00
|
|
|
INT bgn = 0;
|
|
|
|
INT end = 0;
|
|
|
|
INT num = 0;
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
TRACE("(%p, %u, %u, %d, %p, %p)\n",
|
2002-12-17 02:49:16 +01:00
|
|
|
hCtx, wBegin, wEnd, cMaxPkts, lpPkts, lpNPkts);
|
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
if (!hCtx) return 0;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
context = TABLET_FindOpenContext(hCtx);
|
|
|
|
|
2010-07-20 15:20:07 +02:00
|
|
|
if (!context || context->PacketsQueued == 0)
|
2004-01-09 01:03:00 +01:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (bgn < context->PacketsQueued &&
|
|
|
|
context->PacketQueue[bgn].pkSerialNumber != wBegin)
|
|
|
|
bgn++;
|
|
|
|
|
|
|
|
end = bgn;
|
|
|
|
while (end < context->PacketsQueued &&
|
|
|
|
context->PacketQueue[end].pkSerialNumber != wEnd)
|
|
|
|
end++;
|
|
|
|
|
2004-08-02 20:25:42 +02:00
|
|
|
if ((bgn == end) && (end == context->PacketsQueued))
|
2004-01-09 01:03:00 +01:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (num = bgn; num <= end; num++)
|
2004-11-28 15:54:26 +01:00
|
|
|
ptr = TABLET_CopyPacketData(context ,ptr, &context->PacketQueue[num]);
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
/* remove read packets */
|
|
|
|
if ((end+1) < context->PacketsQueued)
|
2004-11-28 15:54:26 +01:00
|
|
|
memmove( &context->PacketQueue[bgn], &context->PacketQueue[end+1],
|
|
|
|
(context->PacketsQueued - (end+1)) * sizeof (WTPACKET));
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
context->PacketsQueued -= ((end-bgn)+1);
|
|
|
|
*lpNPkts = ((end-bgn)+1);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
TRACE("Copied %i packets\n",*lpNPkts);
|
|
|
|
return (end - bgn)+1;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTDataPeek (WINTAB32.82)
|
|
|
|
*/
|
|
|
|
int WINAPI WTDataPeek(HCTX hCtx, UINT wBegin, UINT wEnd,
|
|
|
|
int cMaxPkts, LPVOID lpPkts, LPINT lpNPkts)
|
|
|
|
{
|
2004-01-09 01:03:00 +01:00
|
|
|
LPOPENCONTEXT context;
|
|
|
|
LPVOID ptr = lpPkts;
|
2004-09-22 04:46:38 +02:00
|
|
|
INT bgn = 0;
|
|
|
|
INT end = 0;
|
|
|
|
INT num = 0;
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
TRACE("(%p, %u, %u, %d, %p, %p)\n",
|
2002-12-17 02:49:16 +01:00
|
|
|
hCtx, wBegin, wEnd, cMaxPkts, lpPkts, lpNPkts);
|
|
|
|
|
2004-11-28 15:54:26 +01:00
|
|
|
if (!hCtx || !lpPkts) return 0;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
context = TABLET_FindOpenContext(hCtx);
|
|
|
|
|
2010-07-20 15:20:07 +02:00
|
|
|
if (!context || context->PacketsQueued == 0)
|
2004-01-09 01:03:00 +01:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (bgn < context->PacketsQueued &&
|
|
|
|
context->PacketQueue[bgn].pkSerialNumber != wBegin)
|
|
|
|
bgn++;
|
|
|
|
|
|
|
|
end = bgn;
|
|
|
|
while (end < context->PacketsQueued &&
|
|
|
|
context->PacketQueue[end].pkSerialNumber != wEnd)
|
|
|
|
end++;
|
|
|
|
|
|
|
|
if (bgn == context->PacketsQueued || end == context->PacketsQueued)
|
|
|
|
{
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE("%i %i %i\n", bgn, end, context->PacketsQueued);
|
2004-01-09 01:03:00 +01:00
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (num = bgn; num <= end; num++)
|
2004-11-28 15:54:26 +01:00
|
|
|
ptr = TABLET_CopyPacketData(context ,ptr, &context->PacketQueue[num]);
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
*lpNPkts = ((end-bgn)+1);
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
TRACE("Copied %i packets\n",*lpNPkts);
|
|
|
|
return (end - bgn)+1;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTQueuePacketsEx (WINTAB32.200)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTQueuePacketsEx(HCTX hCtx, UINT *lpOld, UINT *lpNew)
|
|
|
|
{
|
2004-01-09 01:03:00 +01:00
|
|
|
LPOPENCONTEXT context;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
TRACE("(%p, %p, %p)\n", hCtx, lpOld, lpNew);
|
|
|
|
|
2013-11-27 08:52:01 +01:00
|
|
|
if (!hCtx) return FALSE;
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
context = TABLET_FindOpenContext(hCtx);
|
|
|
|
|
2010-07-20 15:20:07 +02:00
|
|
|
if (context && context->PacketsQueued)
|
2004-01-09 01:03:00 +01:00
|
|
|
{
|
|
|
|
*lpOld = context->PacketQueue[0].pkSerialNumber;
|
|
|
|
*lpNew = context->PacketQueue[context->PacketsQueued-1].pkSerialNumber;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("No packets\n");
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&csTablet);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTQueueSizeGet (WINTAB32.84)
|
|
|
|
*/
|
|
|
|
int WINAPI WTQueueSizeGet(HCTX hCtx)
|
|
|
|
{
|
2004-01-09 01:03:00 +01:00
|
|
|
LPOPENCONTEXT context;
|
2010-07-20 15:20:07 +02:00
|
|
|
int queueSize = 0;
|
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
TRACE("(%p)\n", hCtx);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
if (!hCtx) return 0;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
context = TABLET_FindOpenContext(hCtx);
|
2010-07-20 15:20:07 +02:00
|
|
|
if (context)
|
|
|
|
queueSize = context->QueueSize;
|
2004-01-09 01:03:00 +01:00
|
|
|
LeaveCriticalSection(&csTablet);
|
2010-07-20 15:20:07 +02:00
|
|
|
return queueSize;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTQueueSizeSet (WINTAB32.85)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WTQueueSizeSet(HCTX hCtx, int nPkts)
|
|
|
|
{
|
2004-01-09 01:03:00 +01:00
|
|
|
LPOPENCONTEXT context;
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2004-01-09 01:03:00 +01:00
|
|
|
TRACE("(%p, %d)\n", hCtx, nPkts);
|
2002-12-17 02:49:16 +01:00
|
|
|
|
2013-11-27 08:52:01 +01:00
|
|
|
if (!hCtx) return FALSE;
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
EnterCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
context = TABLET_FindOpenContext(hCtx);
|
2010-07-20 15:20:07 +02:00
|
|
|
if (!context)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&csTablet);
|
2013-11-27 08:52:01 +01:00
|
|
|
return FALSE;
|
2010-07-20 15:20:07 +02:00
|
|
|
}
|
2004-01-09 01:03:00 +01:00
|
|
|
|
|
|
|
context->PacketQueue = HeapReAlloc(GetProcessHeap(), 0,
|
|
|
|
context->PacketQueue, sizeof(WTPACKET)*nPkts);
|
|
|
|
|
|
|
|
context->QueueSize = nPkts;
|
|
|
|
LeaveCriticalSection(&csTablet);
|
|
|
|
|
|
|
|
return nPkts;
|
2002-12-17 02:49:16 +01:00
|
|
|
}
|