Blame gdk/win32/pktdef.h

Packit Service fb6fa5
/* -------------------------------- pktdef.h -------------------------------- */
Packit Service fb6fa5
/* Combined 16 & 32-bit version. */
Packit Service fb6fa5
Packit Service fb6fa5
/*------------------------------------------------------------------------------
Packit Service fb6fa5
The text and information contained in this file may be freely used,
Packit Service fb6fa5
copied, or distributed without compensation or licensing restrictions.
Packit Service fb6fa5
Packit Service fb6fa5
This file is copyright 1991-1998 by LCS/Telegraphics.
Packit Service fb6fa5
------------------------------------------------------------------------------*/
Packit Service fb6fa5
/*------------------------------------------------------------------------------
Packit Service fb6fa5
Packit Service fb6fa5
How to use pktdef.h:
Packit Service fb6fa5
Packit Service fb6fa5
1. Include wintab.h
Packit Service fb6fa5
2. if using just one packet format:
Packit Service fb6fa5
	a. Define PACKETDATA and PACKETMODE as or'ed combinations of WTPKT bits
Packit Service fb6fa5
	   (use the PK_* identifiers).
Packit Service fb6fa5
	b. Include pktdef.h.
Packit Service fb6fa5
	c. The generated structure typedef will be called PACKET.  Use PACKETDATA
Packit Service fb6fa5
	   and PACKETMODE to fill in the LOGCONTEXT structure.
Packit Service fb6fa5
3. If using multiple packet formats, for each one:
Packit Service fb6fa5
	a. Define PACKETNAME. Its text value will be a prefix for this packet's
Packit Service fb6fa5
	   parameters and names.
Packit Service fb6fa5
	b. Define <PACKETNAME>PACKETDATA and <PACKETNAME>PACKETMODE similar to
Packit Service fb6fa5
	   2.a. above.
Packit Service fb6fa5
	c. Include pktdef.h.
Packit Service fb6fa5
	d. The generated structure typedef will be called
Packit Service fb6fa5
	   <PACKETNAME>PACKET. Compare with 2.c. above and example #2 below.
Packit Service fb6fa5
4. If using extension packet data, do the following additional steps
Packit Service fb6fa5
   for each extension:
Packit Service fb6fa5
	a. Before including pktdef.h, define <PACKETNAME>PACKET<EXTENSION>
Packit Service fb6fa5
	   as either PKEXT_ABSOLUTE or PKEXT_RELATIVE.
Packit Service fb6fa5
	b. The generated structure typedef will contain a field for the
Packit Service fb6fa5
	   extension data.
Packit Service fb6fa5
	c. Scan the WTI_EXTENSION categories to find the extension's
Packit Service fb6fa5
	   packet mask bit.
Packit Service fb6fa5
	d. OR the packet mask bit with <PACKETNAME>PACKETDATA and use the
Packit Service fb6fa5
	   result in the lcPktData field of the LOGCONTEXT structure.
Packit Service fb6fa5
	e. If <PACKETNAME>PACKET<EXTENSION> was PKEXT_RELATIVE, OR the
Packit Service fb6fa5
	   packet mask bit with <PACKETNAME>PACKETMODE and use the result
Packit Service fb6fa5
	   in the lcPktMode field of the LOGCONTEXT structure.
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
Example #1.	-- single packet format
Packit Service fb6fa5
Packit Service fb6fa5
#include <wintab.h>
Packit Service fb6fa5
#define PACKETDATA	PK_X | PK_Y | PK_BUTTONS	/@ x, y, buttons @/
Packit Service fb6fa5
#define PACKETMODE	PK_BUTTONS					/@ buttons relative mode @/
Packit Service fb6fa5
#include <pktdef.h>
Packit Service fb6fa5
...
Packit Service fb6fa5
	lc.lcPktData = PACKETDATA;
Packit Service fb6fa5
	lc.lcPktMode = PACKETMODE;
Packit Service fb6fa5
Packit Service fb6fa5
Example #2. -- multiple formats
Packit Service fb6fa5
Packit Service fb6fa5
#include <wintab.h>
Packit Service fb6fa5
#define PACKETNAME		MOE
Packit Service fb6fa5
#define MOEPACKETDATA	PK_X | PK_Y | PK_BUTTONS	/@ x, y, buttons @/
Packit Service fb6fa5
#define MOEPACKETMODE	PK_BUTTONS					/@ buttons relative mode @/
Packit Service fb6fa5
#include <pktdef.h>
Packit Service fb6fa5
#define PACKETNAME		LARRY
Packit Service fb6fa5
#define LARRYPACKETDATA	PK_Y | PK_Z | PK_BUTTONS	/@ y, z, buttons @/
Packit Service fb6fa5
#define LARRYPACKETMODE	PK_BUTTONS					/@ buttons relative mode @/
Packit Service fb6fa5
#include <pktdef.h>
Packit Service fb6fa5
#define PACKETNAME		CURLY
Packit Service fb6fa5
#define CURLYPACKETDATA	PK_X | PK_Z | PK_BUTTONS	/@ x, z, buttons @/
Packit Service fb6fa5
#define CURLYPACKETMODE	PK_BUTTONS					/@ buttons relative mode @/
Packit Service fb6fa5
#include <pktdef.h>
Packit Service fb6fa5
...
Packit Service fb6fa5
	lcMOE.lcPktData = MOEPACKETDATA;
Packit Service fb6fa5
	lcMOE.lcPktMode = MOEPACKETMODE;
Packit Service fb6fa5
...
Packit Service fb6fa5
	lcLARRY.lcPktData = LARRYPACKETDATA;
Packit Service fb6fa5
	lcLARRY.lcPktMode = LARRYPACKETMODE;
Packit Service fb6fa5
...
Packit Service fb6fa5
	lcCURLY.lcPktData = CURLYPACKETDATA;
Packit Service fb6fa5
	lcCURLY.lcPktMode = CURLYPACKETMODE;
Packit Service fb6fa5
Packit Service fb6fa5
Example #3. -- extension packet data "XFOO".
Packit Service fb6fa5
	
Packit Service fb6fa5
#include <wintab.h>
Packit Service fb6fa5
#define PACKETDATA	PK_X | PK_Y | PK_BUTTONS	/@ x, y, buttons @/
Packit Service fb6fa5
#define PACKETMODE	PK_BUTTONS					/@ buttons relative mode @/
Packit Service fb6fa5
#define PACKETXFOO	PKEXT_ABSOLUTE				/@ XFOO absolute mode @/
Packit Service fb6fa5
#include <pktdef.h>
Packit Service fb6fa5
...
Packit Service fb6fa5
UINT ScanExts(UINT wTag)
Packit Service fb6fa5
{
Packit Service fb6fa5
	UINT i;
Packit Service fb6fa5
	UINT wScanTag;
Packit Service fb6fa5
Packit Service fb6fa5
	/@ scan for wTag's info category. @/
Packit Service fb6fa5
	for (i = 0; WTInfo(WTI_EXTENSIONS + i, EXT_TAG, &wScanTag); i++) {
Packit Service fb6fa5
		 if (wTag == wScanTag) {
Packit Service fb6fa5
			/@ return category offset from WTI_EXTENSIONS. @/
Packit Service fb6fa5
			return i;
Packit Service fb6fa5
		}
Packit Service fb6fa5
	}
Packit Service fb6fa5
	/@ return error code. @/
Packit Service fb6fa5
	return 0xFFFF;
Packit Service fb6fa5
}
Packit Service fb6fa5
...
Packit Service fb6fa5
	lc.lcPktData = PACKETDATA;
Packit Service fb6fa5
	lc.lcPktMode = PACKETMODE;
Packit Service fb6fa5
#ifdef PACKETXFOO
Packit Service fb6fa5
	categoryXFOO = ScanExts(WTX_XFOO);
Packit Service fb6fa5
	WTInfo(WTI_EXTENSIONS + categoryXFOO, EXT_MASK, &maskXFOO);
Packit Service fb6fa5
	lc.lcPktData |= maskXFOO;
Packit Service fb6fa5
#if PACKETXFOO == PKEXT_RELATIVE
Packit Service fb6fa5
	lc.lcPktMode |= maskXFOO;
Packit Service fb6fa5
#endif
Packit Service fb6fa5
#endif
Packit Service fb6fa5
	WTOpen(hWnd, &lc, TRUE);
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
------------------------------------------------------------------------------*/
Packit Service fb6fa5
#ifdef __cplusplus
Packit Service fb6fa5
extern "C" {
Packit Service fb6fa5
#endif	/* __cplusplus */
Packit Service fb6fa5
Packit Service fb6fa5
#ifndef PACKETNAME
Packit Service fb6fa5
	/* if no packet name prefix */
Packit Service fb6fa5
	#define __PFX(x)	x
Packit Service fb6fa5
	#define __IFX(x,y)	x ## y
Packit Service fb6fa5
#else
Packit Service fb6fa5
	/* add prefixes and infixes to packet format names */
Packit Service fb6fa5
	#define __PFX(x)		__PFX2(PACKETNAME,x)
Packit Service fb6fa5
	#define __PFX2(p,x)		__PFX3(p,x)
Packit Service fb6fa5
	#define __PFX3(p,x)		p ## x
Packit Service fb6fa5
	#define __IFX(x,y)		__IFX2(x,PACKETNAME,y)
Packit Service fb6fa5
	#define __IFX2(x,i,y)	__IFX3(x,i,y)
Packit Service fb6fa5
	#define __IFX3(x,i,y)	x ## i ## y
Packit Service fb6fa5
#endif
Packit Service fb6fa5
Packit Service fb6fa5
#define __SFX2(x,s)		__SFX3(x,s)
Packit Service fb6fa5
#define __SFX3(x,s)		x ## s
Packit Service fb6fa5
Packit Service fb6fa5
#define __TAG  	__IFX(tag,PACKET)
Packit Service fb6fa5
#define __TYPES	__PFX(PACKET), * __IFX(P,PACKET), NEAR * __IFX(NP,PACKET), \
Packit Service fb6fa5
					FAR * __IFX(LP,PACKET)
Packit Service fb6fa5
Packit Service fb6fa5
#define __DATA		(__PFX(PACKETDATA))
Packit Service fb6fa5
#define __MODE		(__PFX(PACKETMODE))
Packit Service fb6fa5
#define __EXT(x)	__SFX2(__PFX(PACKET),x)
Packit Service fb6fa5
Packit Service fb6fa5
	
Packit Service fb6fa5
typedef struct __TAG {
Packit Service fb6fa5
	#if (__DATA & PK_CONTEXT)
Packit Service fb6fa5
		HCTX			pkContext;
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
	#if (__DATA & PK_STATUS)
Packit Service fb6fa5
		UINT			pkStatus;
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
	#if (__DATA & PK_TIME)
Packit Service fb6fa5
		DWORD			pkTime;
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
	#if (__DATA & PK_CHANGED)
Packit Service fb6fa5
		WTPKT			pkChanged;
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
	#if (__DATA & PK_SERIAL_NUMBER)
Packit Service fb6fa5
		UINT			pkSerialNumber;
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
	#if (__DATA & PK_CURSOR)
Packit Service fb6fa5
		UINT			pkCursor;
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
	#if (__DATA & PK_BUTTONS)
Packit Service fb6fa5
		DWORD			pkButtons;
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
	#if (__DATA & PK_X)
Packit Service fb6fa5
		LONG			pkX;
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
	#if (__DATA & PK_Y)
Packit Service fb6fa5
		LONG			pkY;
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
	#if (__DATA & PK_Z)
Packit Service fb6fa5
		LONG			pkZ;
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
	#if (__DATA & PK_NORMAL_PRESSURE)
Packit Service fb6fa5
		#if (__MODE & PK_NORMAL_PRESSURE)
Packit Service fb6fa5
			/* relative */
Packit Service fb6fa5
			int			pkNormalPressure;
Packit Service fb6fa5
		#else
Packit Service fb6fa5
			/* absolute */
Packit Service fb6fa5
			UINT		pkNormalPressure;
Packit Service fb6fa5
		#endif
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
	#if (__DATA & PK_TANGENT_PRESSURE)
Packit Service fb6fa5
		#if (__MODE & PK_TANGENT_PRESSURE)
Packit Service fb6fa5
			/* relative */
Packit Service fb6fa5
			int			pkTangentPressure;
Packit Service fb6fa5
		#else
Packit Service fb6fa5
			/* absolute */
Packit Service fb6fa5
			UINT		pkTangentPressure;
Packit Service fb6fa5
		#endif
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
	#if (__DATA & PK_ORIENTATION)
Packit Service fb6fa5
		ORIENTATION		pkOrientation;
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
	#if (__DATA & PK_ROTATION)
Packit Service fb6fa5
		ROTATION		pkRotation; /* 1.1 */
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
Packit Service fb6fa5
#ifndef NOWTEXTENSIONS
Packit Service fb6fa5
	/* extensions begin here. */
Packit Service fb6fa5
	#if (__EXT(FKEYS) == PKEXT_RELATIVE) || (__EXT(FKEYS) == PKEXT_ABSOLUTE)
Packit Service fb6fa5
		UINT			pkFKeys;
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
	#if (__EXT(TILT) == PKEXT_RELATIVE) || (__EXT(TILT) == PKEXT_ABSOLUTE)
Packit Service fb6fa5
		TILT			pkTilt;
Packit Service fb6fa5
	#endif
Packit Service fb6fa5
#endif
Packit Service fb6fa5
Packit Service fb6fa5
} __TYPES ;
Packit Service fb6fa5
Packit Service fb6fa5
#undef PACKETNAME
Packit Service fb6fa5
#undef __TAG
Packit Service fb6fa5
#undef __TAG2
Packit Service fb6fa5
#undef __TYPES
Packit Service fb6fa5
#undef __TYPES2
Packit Service fb6fa5
#undef __DATA
Packit Service fb6fa5
#undef __MODE
Packit Service fb6fa5
#undef __PFX
Packit Service fb6fa5
#undef __PFX2
Packit Service fb6fa5
#undef __PFX3
Packit Service fb6fa5
#undef __IFX
Packit Service fb6fa5
#undef __IFX2
Packit Service fb6fa5
#undef __IFX3
Packit Service fb6fa5
#undef __SFX2
Packit Service fb6fa5
#undef __SFX3
Packit Service fb6fa5
Packit Service fb6fa5
#ifdef __cplusplus
Packit Service fb6fa5
}
Packit Service fb6fa5
#endif	/* __cplusplus */