/*
**	$VER: prefs.c 39.11 (5.2.95)
**
**	Small program to reset tablet to driver's required status.
**	Example of external module for Sketch Driver v39+
**	Suggestion: Make it available with a hot key.
**
**	(C) Copyright 1995 Miguel Fides (Dior/Darkness)
**	    All Rights Reserved
**
*/

#include <intuition/intuition.h>
#include <proto/intuition.h>
#include <proto/exec.h>
#include <sketch.h>

char	PortName[]="SketchPort";
struct	MsgPort	*DriverPort;
struct	MsgPort	*MyPort;

void ResetDriver(void);

void main(void)
{
if (MyPort=CreateMsgPort())
	{
	if (DriverPort=FindPort(PortName))
		{
		ResetDriver();
		}
	DeleteMsgPort(MyPort);
	}
}

void ResetDriver()
{
struct	SketchMessage sm;
struct	SketchMessage *rm;
struct	EasyStruct es={
	sizeof(struct EasyStruct),
	0,"Sketch Reset",
	"Sketch Driver version 39.11\n"
	"Copyright ©1995 by Miguel Fides\n"
	"All Rights Reserved\n\n"
	"See source included to\n"
	"build external modules.",
	"Ok"
	};

sm.Message.mn_ReplyPort=MyPort;
sm.Command=SM_RESET;
sm.Extension=NULL;
PutMsg(DriverPort,(struct Message *)&sm);
do	{
	WaitPort(MyPort);
	while (rm=(struct SketchMessage *)GetMsg(MyPort))
		if (rm==&sm) break;
	} while (rm==NULL);

/*	Here you could get your command's return values.
**	First you must check the Error field,
**	then you could copy the desired data fields for your use.
**	As you can see, you need to use the "Reply" method
**	to obtain data as you can't get back your message
**	in 'Quick' mode.
*/

EasyRequest(NULL,&es,NULL,NULL);
}
