home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / gchsrc31 / atarilib / mousepos.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-27  |  1.3 KB  |  67 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  This file is part of the Atari Machine Specific Library,
  4. //  and is Copyright 1992 by Warwick W. Allison.
  5. //
  6. //  You are free to copy and modify these sources, provided you acknoledge
  7. //  the origin by retaining this notice, and adhere to the conditions
  8. //  described in the file COPYING.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11.  
  12. #include "MousePosition.h"
  13. #include <osbind.h>
  14.  
  15. MousePosition Mouse;
  16.  
  17. void MousePosition::Bind()
  18. {
  19.     if (x<minx) x=minx;
  20.     else if (x>maxx) x=maxx;
  21.     if (y<miny) y=miny;
  22.     else if (y>maxy) y=maxy;
  23. }
  24.  
  25. struct Packet
  26. {
  27.     short Header:8;
  28.     short x:8;
  29.     short y:8;
  30. };
  31.  
  32. void MyInt(Packet* Data)
  33. {
  34.     Mouse.SetLeft(!!(Data->Header&2));
  35.     Mouse.SetRight(!!(Data->Header&1));
  36.     Mouse.MoveBy(Data->x,Data->y);
  37. }
  38.  
  39. MousePosition::MousePosition() :
  40.     x(0),
  41.     y(0),
  42.     Left(FALSE),
  43.     Right(FALSE)
  44. {
  45.     struct _KBDVECS *Base=Kbdvbase();
  46.  
  47.     Ikbdws(1,"\010");
  48.     OldVec=Base->mousevec;
  49.     Base->mousevec=MyInt;
  50. }
  51.  
  52. void MousePosition::Speed(short x, short y)
  53. {
  54.     char *T="\013??";
  55.     T[1]=x;
  56.     T[2]=y;
  57.     Ikbdws(3,T);
  58. }
  59.  
  60. MousePosition::~MousePosition()
  61. {
  62.     struct _KBDVECS *Base=Kbdvbase();
  63.  
  64.     Base->mousevec=OldVec;
  65.     Ikbdws(3,"\013\01\01");
  66. }
  67.