home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 648a.lha / MTRD_Library_v0.99゚ / Mouse.c < prev    next >
C/C++ Source or Header  |  1992-06-11  |  1KB  |  64 lines

  1. /*** Test the mouse ***/
  2.  
  3. #include "MTRD.h"
  4. #include "MTRDTypes.h"
  5.  
  6. struct MtrdBase *MtrdBase;
  7.  
  8.  
  9. struct NewWindow newwindow = {
  10.     40,20,180,60,0,1,
  11.     MOUSEMOVE|MOUSEBUTTONS,WINDOWDRAG|REPORTMOUSE|RMBTRAP|ACTIVATE,
  12.     NULL,NULL,(UBYTE *)"Test Mouse",
  13.     NULL,NULL,0,0,0,0,WBENCHSCREEN
  14. };
  15.  
  16. void *IntuitionBase;
  17. char myBuffer[20],Com[32];
  18. struct FileID myID = { MTT_MOUSE,MTS_RELMOUSE|MTS_CHAR,20,
  19.                                 myBuffer,"MyMouseCoordsBuffer",0,0,0,0 };
  20.  
  21.  
  22. main()
  23. {
  24.     struct MFile *File;
  25.     struct MUser *User;
  26.     int out=FALSE;
  27.     ULONG class;
  28.     UWORD code;
  29.     SHORT mx,my;
  30.     struct Window *win;
  31.     struct IntuiMessage *msg;
  32.     char t[20];
  33.  
  34.     IntuitionBase=OpenLibrary("intuition.library",0);
  35.     MtrdBase=OpenLibrary("mtrd.library",0);
  36.     File=OpenMFile(NULL,&myID,0);
  37.     GETMUSER(File,User);
  38.  
  39.     win=OpenWindow(&newwindow);
  40.     while (!out) {
  41.         WaitPort(win->UserPort);
  42.         while (msg=(struct IntuiMessage *)GetMsg(win->UserPort)) {
  43.             class=msg->Class;
  44.             code=msg->Code;
  45.             mx=msg->MouseX;
  46.             my=msg->MouseY;
  47.             ReplyMsg((struct Message *)msg);
  48.             if (class==MOUSEMOVE) {
  49.                 InitData(Com);
  50.                 sprintf(t,"%d,%d",mx,my);
  51.                 AddBytes(Com,0,20,t);
  52.                 WriteData(File,User,Com);
  53.             }
  54.             if (class==MOUSEBUTTONS)
  55.                 if (code==MENUDOWN)
  56.                     out=TRUE;
  57.         }
  58.     }
  59.     CloseMFile(File,User);
  60.     CloseWindow(win);
  61.     CloseLibrary(MtrdBase);
  62.     CloseLibrary(IntuitionBase);
  63. }
  64.