/*---------------------------------------------------------------------------------
  File TabletMPC.h: this file contains definition of constants and structures used
  by programs that want to use GTDriver directly.
  ---------------------------------------------------------------------------------*/


#define GTDPUBPORTNAME	"GTDPubPort"	/* name of GTDriver public message port		*/

/* GTDriver expect to receive the following type of messages at its public port.
 * Command must be one of the following MPC definitions, while Data depend on the
 * command.
 * When you PutMsg() the command you must Wait at your replyport. when the reply is
 * back you must check at the Command field: if it is COMMAND_OK your request has been
 * satisfied otherwise Command == COMMAND_FAILED and you may find some more details in
 * Data field.
 */

struct TabletCommand{
	struct Message msg;
	UWORD  Command;
	APTR   Data;
};

/* Here are the commands. If not mentioned, Data is ignored by GTDriver				*/
#define MPC_QUIT 			0	/* Quit GTDriver ! 									*/
								/* The following 4 are used mainly by GTDOptions	*/
#define MPC_NEWPREFS 		1	/* Load again prefs from "ENV:GTD.Prefs" 			*/
#define MPC_TESTPREFS 		2	/* Load prefs from "T:GTD.temp" but hold old values */
#define MPC_NOTESTPREFS		3	/* Exit from test (resume old values)				*/
#define MPC_NEWBUTTONS		4	/* Get new buttons definition. Data must point		*/
								/*   to the name of the ".but" file.					*/
#define MPC_SERVERMODE		5	/* Switch to server mode: Data is the address of the*/
								/* MsgPort of your program where GTDriver has to 	*/
								/*   send events									*/
#define MPC_DRIVERMODE		6	/* Switch to driver mode							*/
#define MPC_GETPREFS		7   /* Data must point to an istance of GTDPrefs 		*/
								/*   structure. when the command is replied to your	*/
								/*   program (if no error occurs) the structure will*/
								/*   be filled with GTDriver settings. structure	*/
								/*   GTDPrefs is defined later in this file.		*/

/* Values for the Command field when you get the reply								*/

#define COMMAND_OK		0
#define COMMAND_FAILED	1

/* Values for the Data field if Command == COMMAND_ERROR							*/

#define CMDERR_SERVER 		  0 /* The driver is already in server mode (if you sent*/
                                /* CMD_SERVER) or you are not the client			*/
								/*   already a server 								*/
#define CMDERR_PREFS_ERROR	  1 /* Error while parsing a prefs file 				*/
#define CMDERR_PORT_ERROR	  2 /* unable to allocate msg port */
#define NO_PUBPORT			 -1	/* you can use this if you don't find the GTDPUBPORT*/


struct GTDPrefs
{
	float Version;			/* Version of the driver					*/
	short Mode;				/* Working mode (see below)					*/
	char  Emulation[64];	/* Name of the emulation in use				*/
	short Baud;				/* Baud rate								*/
	char  InitString[256];	/* String sent to the tablet at the start	*/
	short Priority;			/* Priority of the driver process			*/
	short Pressure;			/* Pressure threshold for left mouse button */
							/*   emulation (Wacom emulation only)		*/
	short DPI;				/* Dot per inch								*/
	short Metric;			/* (See below)								*/
	float XDim;				/* X and Y dimension (expressed in Metric)	*/
	float YDim;
	float ULC_x;			/* Upper Left and Lower Right corner of the	*/
	float ULC_y;			/* clip rectangle (expressed in metric)		*/
	float LRC_x;
	float LRC_y;
	BOOL SwapXY;			/* If TRUE X and Y axes are swapped			*/
	BOOL MirrorX;			/* If TRUE X axis is mirrored				*/
	BOOL MirrorY;			/* If TRUE Y axis is mirrored				*/
};

/* These values are  for field "Metric" and "Mode" of truct GTDPrefs	*/

#define METRIC_CM		0
#define METRIC_INCHES	1
#define MODE_DRIVER		0
#define MODE_SERVER		1


/* You can use these two factor to convert inches to a cm value and vice versa */

#define CONV_INCHES2CM	2.54417
#define CONV_CM2INCHES	0.393055


/* When the driver is switched to SERVER mode it start sending tablet events to the	*/
/* message port specified in the Data field of the command MPC_SERVER				*/
/* Events are struct TabletMessage. First of all you must check the type field:		*/
/* If type ==  TMTYPE_COORDS it has been generated by moving the stylus on the 		*/
/* tablet. 																			*/
/* If type == TMTYPE_PBUTTON a pseudo-button has been pressed on the tablet and you	*/
/* can find the associated key in the key field (WARNING: only non-special key are	*/
/* copied to the key field															*/

#define TMTYPE_COORDS 	1
#define TMTYPE_PBUTTON 	2

struct TabletMessage{
	struct Message msg;
	UWORD type;
	UWORD x,y;
	ULONG buttons;
	char  key;
	WORD  pressure;
};


