home *** CD-ROM | disk | FTP | other *** search
- /***********************************************************************/
- /* WACOM-Digitizer Driver (C) 1993-1994 by ROLAND SCHWINGEL */
- /***********************************************************************/
- /* Demoprogram for obtaining Pressure Data from the Driver */
- /* */
- /* Prints all Data which is provided by the Driver in a Window */
- /* (only if Window is activated) */
- /***********************************************************************/
-
- /* INCLUDES ************/
- #include <stdio.h>
-
- #include <exec/exec.h>
- #include <proto/exec.h>
- #include <clib/exec_protos.h>
-
- #include <intuition/intuition.h>
- #include <proto/intuition.h>
- #include <clib/intuition_protos.h>
-
- #include "Wacom.h" /* here is all the Wacomdata defined */
-
- /* global Variables ****/
- /* external */
- extern struct ExecBase *SysBase;
-
- /* local */
- struct IntuitionBase *IntuitionBase;
-
- char *ITexts[]=
- {
- "Sync = %d",
- "Driver_running = %d",
- "Wacom_Series = %d",
- "Beeper = %d",
- "Mode = %d",
- "MB_Emu = %d",
- "Pressure_Limit = %03d",
- "Pressure = %03d",
- "input_device = %d",
- "Buttons = %02d",
- "Tablett_Max_X = %06ld",
- "Tablett_Max_Y = %06ld",
- "Tablett_X = %06ld",
- "Tablett_Y = %06ld",
- "Set_Mouse = %d",
- "Commandset = %d",
- "Multi_Mode = %d",
- "Multi_Mouse = %d",
- "Macrokey = %02d",
- "MM_Dig_Buttons = %02d",
- "MM_Dig_X = %06ld",
- "MM_Dig_Y = %06ld"
- };
-
- struct TextAttr DefFont={(STRPTR)"topaz.font",TOPAZ_EIGHTY,FS_NORMAL ,FPF_ROMFONT};
- struct IntuiText IText={1,0,JAM2,0,0,&DefFont, NULL,NULL};
-
- /* Version-Tag ***************************/
- UBYTE *vers="$VER: Get_Pressure V1.2 ("__TIME__" "__DATE__") by Roland Schwingel.";
-
- /* Prototypes **********/
-
- #ifdef __SASC
- void __regargs __chkabort(void); /* Disable SAS/C CTRL-C Check */
- #endif
- int main(void);
-
- /***********************************************************************/
- /* main() */
- /***********************************************************************/
- int main (void)
- {
- int retval=21;
- struct MsgPort *Wacom_data_Port; /* This is the way where we get the Data */
- struct MsgPort *Our_Port;
- struct WacomMSG WMess;
- struct Window *Win;
- struct RastPort *WinRP;
- struct IntuiMessage *IMess;
- BOOL cont=TRUE;
- ULONG class,Sigrcvd;
- char buffer[80];
-
- /* First check if our MsgPort is here - means if Wacom Driver program is running */
- if(FindPort(WACOM_PORT_NAME))
- {
- /* Now open intution.library */
- if(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",37L))
- {
- /* open the Window */
- if(Win=OpenWindowTags(NULL,WA_Left,0,WA_Top,12,WA_Width,220,WA_Height,215,
- WA_IDCMP, IDCMP_CLOSEWINDOW|IDCMP_INTUITICKS,
- WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
- WA_Title, "How to get the Data", TAG_DONE))
- {
- /* Get the Rastport */
- WinRP=Win->RPort;
-
- /* Install our MessagePort */
- if(Our_Port=CreateMsgPort())
- {
- /* Set up the Message */
- WMess.Mess.mn_Node.ln_Type=NT_MESSAGE;
- WMess.Mess.mn_Length=sizeof(struct WacomMSG);
- WMess.Mess.mn_ReplyPort=Our_Port;
-
- IText.IText=buffer; /* Pointer to Text */
- while(cont)
- {
- /* Wait for Window or CTRL-C Event */
- Sigrcvd=Wait(1L << Win->UserPort->mp_SigBit|SIGBREAKF_CTRL_C);
- {
- /* Check CTRL-C */
- if(Sigrcvd & SIGBREAKF_CTRL_C)
- cont=FALSE;
-
- /* Check Event from Window */
- if(Sigrcvd & 1L << Win->UserPort->mp_SigBit)
- {
- while(IMess=(struct IntuiMessage *)GetMsg(Win->UserPort))
- {
- class=IMess->Class;
- ReplyMsg((struct Message *)IMess); /* Send Msg back to Intuition */
-
- switch(class)
- {
- case IDCMP_CLOSEWINDOW: cont=FALSE; /* Somebody pushed the Closebutton */
- break;
-
- case IDCMP_INTUITICKS: /* This is only a Demo Programm in YOUR Porgramm you shouldn't use
- INTUITICKS to read the Wacom Infos. */
-
- /* Send Request for Data */
- Wacom_data_Port=FindPort(WACOM_PORT_NAME);
- if(Wacom_data_Port)
- {
- PutMsg(Wacom_data_Port,(struct Message *)&WMess);
-
- /* Wait for Reply */
- WaitPort(Our_Port);
-
- /* Print all inquired Data */
- if(GetMsg(Our_Port))
- {
- /* Wacom_Driver writes its response directly into WMess */
- sprintf(buffer,ITexts[0],WMess.WacomInfo.Sync);
- PrintIText(WinRP,&IText,10,12);
-
- sprintf(buffer,ITexts[1],WMess.WacomInfo.Driver_running);
- PrintIText(WinRP,&IText,10,21);
-
- sprintf(buffer,ITexts[2],WMess.WacomInfo.Wacom_Series);
- PrintIText(WinRP,&IText,10,30);
-
- sprintf(buffer,ITexts[3],WMess.WacomInfo.Beeper);
- PrintIText(WinRP,&IText,10,39);
-
- sprintf(buffer,ITexts[4],WMess.WacomInfo.Mode);
- PrintIText(WinRP,&IText,10,48);
-
- sprintf(buffer,ITexts[5],WMess.WacomInfo.MB_Emu);
- PrintIText(WinRP,&IText,10,57);
-
- sprintf(buffer,ITexts[6],WMess.WacomInfo.Pressure_Limit);
- PrintIText(WinRP,&IText,10,66);
-
- sprintf(buffer,ITexts[7],WMess.WacomInfo.Pressure);
- PrintIText(WinRP,&IText,10,75);
-
- sprintf(buffer,ITexts[8],WMess.WacomInfo.input_device);
- PrintIText(WinRP,&IText,10,84);
-
- sprintf(buffer,ITexts[9],WMess.WacomInfo.Buttons);
- PrintIText(WinRP,&IText,10,93);
-
- sprintf(buffer,ITexts[10],WMess.WacomInfo.Tablett_Max_X);
- PrintIText(WinRP,&IText,10,102);
-
- sprintf(buffer,ITexts[11],WMess.WacomInfo.Tablett_Max_Y);
- PrintIText(WinRP,&IText,10,111);
-
- sprintf(buffer,ITexts[12],WMess.WacomInfo.Tablett_X);
- PrintIText(WinRP,&IText,10,120);
-
- sprintf(buffer,ITexts[13],WMess.WacomInfo.Tablett_Y);
- PrintIText(WinRP,&IText,10,129);
-
- sprintf(buffer,ITexts[14],WMess.WacomInfo.Set_Mouse);
- PrintIText(WinRP,&IText,10,138);
-
- sprintf(buffer,ITexts[15],WMess.WacomInfo.Commandset);
- PrintIText(WinRP,&IText,10,147);
-
- sprintf(buffer,ITexts[16],WMess.WacomInfo.Multi_Mode);
- PrintIText(WinRP,&IText,10,156);
-
- sprintf(buffer,ITexts[17],WMess.WacomInfo.Multi_Mouse);
- PrintIText(WinRP,&IText,10,165);
-
- sprintf(buffer,ITexts[18],WMess.WacomInfo.Macrokey);
- PrintIText(WinRP,&IText,10,174);
-
- sprintf(buffer,ITexts[19],WMess.WacomInfo.MM_Dig_Buttons);
- PrintIText(WinRP,&IText,10,183);
-
- sprintf(buffer,ITexts[20],WMess.WacomInfo.MM_Dig_X);
- PrintIText(WinRP,&IText,10,192);
-
- sprintf(buffer,ITexts[21],WMess.WacomInfo.MM_Dig_Y);
- PrintIText(WinRP,&IText,10,201);
- }
- }
- break;
-
- }
-
- }
- }
- }
- }
-
- /* get rid of our port */
- DeleteMsgPort(Our_Port);
- }
- else
- printf("Unable to install a Message Port !!\n");
-
- /* Close Window */
- CloseWindow(Win);
- }
- else
- printf("Can't open Window !!\n");
-
- /* Close Intution */
- CloseLibrary((struct Library *)IntuitionBase);
- }
- else
- printf("Unable to open intuition.library V37+!!!\n");
- }
- else
- printf("Sorry... Can't find " WACOM_PORT_NAME "\n" );
-
- /* exit to Shell/WB */
- return(retval);
- }
-
- /***********************************************************************/
- /* __chkabort(): Disable CTRL-C Handling (SAS/C 6.x) */
- /***********************************************************************/
- #ifdef __SASC
- void __chkabort(void){}
- #endif
-
-