home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Workbench / dosdrivers / Wacom_116.lha / Wacom_1.16 / Develop / get_pressure.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-31  |  10.3 KB  |  261 lines

  1. /***********************************************************************/
  2. /* WACOM-Digitizer Driver            (C) 1993-1994 by ROLAND SCHWINGEL */
  3. /***********************************************************************/
  4. /* Demoprogram for obtaining Pressure Data from the Driver             */
  5. /*                                                                     */
  6. /* Prints all Data which is provided by the Driver in a Window         */
  7. /* (only if Window is activated)                                       */
  8. /***********************************************************************/
  9.  
  10. /* INCLUDES ************/
  11. #include <stdio.h>
  12.  
  13. #include <exec/exec.h>
  14. #include <proto/exec.h>
  15. #include <clib/exec_protos.h>
  16.  
  17. #include <intuition/intuition.h>
  18. #include <intuition/IntuitionBase.h>
  19. #include <proto/intuition.h>
  20. #include <clib/intuition_protos.h>
  21.  
  22. #include "Wacom.h"             /* here is all the Wacomdata defined */
  23.  
  24. /* global Variables ****/
  25. /* external */
  26. extern struct ExecBase           *SysBase;
  27.  
  28. /* local */
  29. struct IntuitionBase             *IntuitionBase;
  30.  
  31. char *ITexts[]=
  32. {
  33.  "Sync             = %d",
  34.  "Driver_running   = %d",
  35.  "Wacom_Series     = %d",
  36.  "Beeper           = %d",
  37.  "Mode             = %d",
  38.  "MB_Emu           = %d",
  39.  "Pressure_Limit   = %03d",
  40.  "Pressure         = %04d",
  41.  "input_device     = %d",
  42.  "Buttons          = %02d",
  43.  "Tablett_Max_X    = %06ld",
  44.  "Tablett_Max_Y    = %06ld",
  45.  "Tablett_X        = %06ld",
  46.  "Tablett_Y        = %06ld",
  47.  "Set_Mouse        = %d",
  48.  "Commandset       = %d",
  49.  "Multi_Mode       = %d",
  50.  "Multi_Mouse      = %d",
  51.  "Macrokey         = %02d",
  52.  "MM_Dig_Buttons   = %02d",
  53.  "MM_Dig_X         = %06ld",
  54.  "MM_Dig_Y         = %06ld",
  55.  "Proximity        = %d",
  56.  "MM_Dig_Proximity = %d"
  57. };
  58.  
  59. struct TextAttr DefFont={(STRPTR)"topaz.font",TOPAZ_EIGHTY,FS_NORMAL     ,FPF_ROMFONT};
  60. struct IntuiText IText={1,0,JAM2,0,0,&DefFont, NULL,NULL};
  61.  
  62. /* Version-Tag ***************************/
  63. UBYTE *vers="$VER:Get_Pressure 1.4 ("__DATE__" "__TIME__") by Roland Schwingel.";
  64.  
  65. /* Prototypes **********/
  66.  
  67. int                   main(void);
  68.  
  69. /***********************************************************************/
  70. /* main()                                                              */
  71. /***********************************************************************/
  72. int main (void)
  73. {
  74. int                         retval=21;
  75. struct MsgPort             *Wacom_data_Port;         /* This is the way where we get the Data */
  76. struct MsgPort             *Our_Port;
  77. struct WacomMSG             WMess;
  78. struct Window              *Win;
  79. struct RastPort            *WinRP;
  80. struct IntuiMessage        *IMess;
  81. int                         offy;
  82. BOOL                        cont=TRUE;
  83. ULONG                       class,Sigrcvd;
  84. char                        buffer[80];
  85.  
  86.  /* First check if our MsgPort is here - means if Wacom Driver program is running */
  87.  if(FindPort(WACOM_PORT_NAME))
  88.  {
  89.   /* Now open intution.library */
  90.   if(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",37L))
  91.   {
  92.    /* Get Offset for Textprinting */
  93.    offy=IntuitionBase->ActiveScreen->RastPort.TxHeight+
  94.         IntuitionBase->ActiveScreen->WBorTop +2;
  95.  
  96.    /* open the Window */
  97.    if(Win=OpenWindowTags(NULL,WA_Left,0,WA_Top,offy,WA_Width,226,WA_Height,24*9+offy+IntuitionBase->ActiveScreen->WBorBottom,
  98.                               WA_IDCMP,  IDCMP_CLOSEWINDOW|IDCMP_INTUITICKS,
  99.                               WA_Flags,  WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  100.                               WA_Title,  "How to get the Data", TAG_DONE))
  101.    {
  102.     /* Get the Rastport */
  103.     WinRP=Win->RPort;
  104.  
  105.     /* Install our MessagePort */
  106.     if(Our_Port=CreateMsgPort())
  107.     {
  108.      /* Set up the Message */
  109.      WMess.Mess.mn_Node.ln_Type=NT_MESSAGE;
  110.      WMess.Mess.mn_Length=sizeof(struct WacomMSG);
  111.      WMess.Mess.mn_ReplyPort=Our_Port;
  112.  
  113.      IText.IText=buffer;         /* Pointer to Text */
  114.      while(cont)
  115.      {
  116.       /* Wait for Window or CTRL-C Event */
  117.       Sigrcvd=Wait(1L << Win->UserPort->mp_SigBit|SIGBREAKF_CTRL_C);
  118.       {
  119.        /* Check CTRL-C */
  120.        if(Sigrcvd & SIGBREAKF_CTRL_C)
  121.         cont=FALSE;
  122.  
  123.        /* Check Event from Window */
  124.        if(Sigrcvd & 1L << Win->UserPort->mp_SigBit)
  125.        {
  126.         while(IMess=(struct IntuiMessage *)GetMsg(Win->UserPort))
  127.         {
  128.          class=IMess->Class;
  129.          ReplyMsg((struct Message *)IMess);     /* Send Msg back to Intuition */
  130.  
  131.          switch(class)
  132.          {
  133.           case IDCMP_CLOSEWINDOW:     cont=FALSE;      /* Somebody pushed the Closebutton */
  134.                                       retval=0;
  135.                                       break;
  136.  
  137.           case IDCMP_INTUITICKS:      /* This is only a Demo Programm in YOUR Porgramm you shouldn't use
  138.                                          INTUITICKS to read the Wacom Infos. */
  139.  
  140.                                       /* Send Request for Data */
  141.                                       Wacom_data_Port=FindPort(WACOM_PORT_NAME);
  142.                                       if(Wacom_data_Port)
  143.                                       {
  144.                                        PutMsg(Wacom_data_Port,(struct Message *)&WMess);
  145.  
  146.                                        /* Wait for Reply */
  147.                                        WaitPort(Our_Port);
  148.  
  149.                                        /* Print all inquired Data */
  150.                                        if(GetMsg(Our_Port))
  151.                                        {
  152.                                         /* Wacom_Driver writes its response directly into WMess */
  153.                                         sprintf(buffer,ITexts[0],WMess.WacomInfo.Sync);
  154.                                         PrintIText(WinRP,&IText,10,(long)offy);
  155.  
  156.                                         sprintf(buffer,ITexts[1],WMess.WacomInfo.Driver_running);
  157.                                         PrintIText(WinRP,&IText,10,(long)offy+9);
  158.  
  159.                                         sprintf(buffer,ITexts[2],WMess.WacomInfo.Wacom_Series);
  160.                                         PrintIText(WinRP,&IText,10,(long)offy+2*9);
  161.  
  162.                                         sprintf(buffer,ITexts[3],WMess.WacomInfo.Beeper);
  163.                                         PrintIText(WinRP,&IText,10,(long)offy+3*9);
  164.  
  165.                                         sprintf(buffer,ITexts[4],WMess.WacomInfo.Mode);
  166.                                         PrintIText(WinRP,&IText,10,(long)offy+4*9);
  167.  
  168.                                         sprintf(buffer,ITexts[5],WMess.WacomInfo.MB_Emu);
  169.                                         PrintIText(WinRP,&IText,10,(long)offy+5*9);
  170.  
  171.                                         sprintf(buffer,ITexts[6],WMess.WacomInfo.Pressure_Limit);
  172.                                         PrintIText(WinRP,&IText,10,(long)offy+6*9);
  173.  
  174.                                         sprintf(buffer,ITexts[7],WMess.WacomInfo.Pressure);
  175.                                         PrintIText(WinRP,&IText,10,(long)offy+7*9);
  176.  
  177.                                         sprintf(buffer,ITexts[8],WMess.WacomInfo.input_device);
  178.                                         PrintIText(WinRP,&IText,10,(long)offy+8*9);
  179.  
  180.                                         sprintf(buffer,ITexts[9],WMess.WacomInfo.Buttons);
  181.                                         PrintIText(WinRP,&IText,10,(long)offy+9*9);
  182.  
  183.                                         sprintf(buffer,ITexts[10],WMess.WacomInfo.Tablett_Max_X);
  184.                                         PrintIText(WinRP,&IText,10,(long)offy+10*9);
  185.  
  186.                                         sprintf(buffer,ITexts[11],WMess.WacomInfo.Tablett_Max_Y);
  187.                                         PrintIText(WinRP,&IText,10,(long)offy+11*9);
  188.  
  189.                                         sprintf(buffer,ITexts[12],WMess.WacomInfo.Tablett_X);
  190.                                         PrintIText(WinRP,&IText,10,(long)offy+12*9);
  191.  
  192.                                         sprintf(buffer,ITexts[13],WMess.WacomInfo.Tablett_Y);
  193.                                         PrintIText(WinRP,&IText,10,(long)offy+13*9);
  194.  
  195.                                         sprintf(buffer,ITexts[14],WMess.WacomInfo.Set_Mouse);
  196.                                         PrintIText(WinRP,&IText,10,(long)offy+14*9);
  197.  
  198.                                         sprintf(buffer,ITexts[15],WMess.WacomInfo.Commandset);
  199.                                         PrintIText(WinRP,&IText,10,(long)offy+15*9);
  200.  
  201.                                         sprintf(buffer,ITexts[16],WMess.WacomInfo.Multi_Mode);
  202.                                         PrintIText(WinRP,&IText,10,(long)offy+16*9);
  203.  
  204.                                         sprintf(buffer,ITexts[17],WMess.WacomInfo.Multi_Mouse);
  205.                                         PrintIText(WinRP,&IText,10,(long)offy+17*9);
  206.  
  207.                                         sprintf(buffer,ITexts[18],WMess.WacomInfo.Macrokey);
  208.                                         PrintIText(WinRP,&IText,10,(long)offy+18*9);
  209.  
  210.                                         sprintf(buffer,ITexts[19],WMess.WacomInfo.MM_Dig_Buttons);
  211.                                         PrintIText(WinRP,&IText,10,(long)offy+19*9);
  212.  
  213.                                         sprintf(buffer,ITexts[20],WMess.WacomInfo.MM_Dig_X);
  214.                                         PrintIText(WinRP,&IText,10,(long)offy+20*9);
  215.  
  216.                                         sprintf(buffer,ITexts[21],WMess.WacomInfo.MM_Dig_Y);
  217.                                         PrintIText(WinRP,&IText,10,(long)offy+21*9);
  218.  
  219.                                         sprintf(buffer,ITexts[22],WMess.WacomInfo.Proximity);
  220.                                         PrintIText(WinRP,&IText,10,(long)offy+22*9);
  221.  
  222.                                         sprintf(buffer,ITexts[23],WMess.WacomInfo.MM_Dig_Proximity);
  223.                                         PrintIText(WinRP,&IText,10,(long)offy+23*9);
  224.                                        }
  225.                                       }
  226.                                       break;
  227.  
  228.          }
  229.  
  230.         }
  231.        }
  232.       }
  233.      }
  234.  
  235.      /* get rid of our port */
  236.      DeleteMsgPort(Our_Port);
  237.     }
  238.     else
  239.      printf("Unable to install a Message Port !!\n");
  240.  
  241.     /* Close Window */
  242.     CloseWindow(Win);
  243.    }
  244.    else
  245.     printf("Can't open Window !!\n");
  246.  
  247.    /* Close Intution */
  248.    CloseLibrary((struct Library *)IntuitionBase);
  249.   }
  250.   else
  251.    printf("Unable to open intuition.library V37+!!!\n");
  252.  }
  253.  else
  254.   printf("Sorry... Can't find " WACOM_PORT_NAME "\n" );
  255.  
  256.  /* exit to Shell/WB */
  257.  return(retval);
  258. }
  259.  
  260.  
  261.