Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

MSMouse Class Reference

#include <msmouse.h>

List of all members.

Public Methods

 MSMouse (void)
 MSMouse (VideoModeType VideoMode)
void Setup (VideoModeType VideoMode)
bool SetupOK (void)
void Hide (void)
void Show (void)
void Move (int Mx, int My)
void TurnOn (void)
void TurnOff (void)
void SetGCursor (const MouseCursor &NewCursor)
void SetMouseCursor (int, int)
void SetSpeed2 ()
Message Event (void)
Message WaitForAnyEvent (void)
Message WaitForEvent (Message &)
void Flush (void)

Protected Methods

bool DriverExists (void)
int PressCnt (unsigned ButtonMask)
int ReleaseCnt (unsigned ButtonMask)
bool Moved (void)
bool Operating (void)
unsigned Status (int &Mx, int &My)
unsigned ButtonStatus (void)

Protected Attributes

int OldX
int OldY
bool OK
bool MouseOff
bool TextMode
bool LowRes
bool HighRes
int X
int Y
int Dx
int Dy


Constructor & Destructor Documentation

MSMouse::MSMouse void   
 

Definition at line 28 of file msmouse.c.

References False, MouseOff, OK, and True.

00029 {
00030   OK    = False;
00031   MouseOff  = True;
00032 }

MSMouse::MSMouse VideoModeType    VideoMode
 

Definition at line 34 of file msmouse.c.

References False, MouseOff, OK, Setup(), True, and VideoModeType.

00035 {
00036   OK = False;  MouseOff = True;
00037   Setup (VideoMode);
00038 }


Member Function Documentation

unsigned MSMouse::ButtonStatus void    [protected]
 

Definition at line 140 of file msmouse.c.

References Operating(), and Status().

00141 {
00142   int Mx, My;
00143 
00144   if (!Operating())
00145     return 0;
00146   else
00147     return Status(Mx, My);
00148 }

bool MSMouse::DriverExists void    [protected]
 

Definition at line 50 of file msmouse.c.

References Iret, and MsCall.

Referenced by Setup().

00051 {
00052   void far *address;
00053   address = getvect(MsCall);
00054   return (bool) ((address != NULL) &&
00055           (*(unsigned char far *)address != Iret));
00056 }

Message MSMouse::Event void   
 

Definition at line 177 of file msmouse.c.

References Idle, LeftButton, LMouseDown, LMouseStillDown, LMouseUp, MouseMsg, Operating(), PressCnt(), ReleaseCnt(), RightButton, RMouseDown, RMouseStillDown, and Status().

Referenced by Flush(), WaitForAnyEvent(), and WaitForEvent().

00178 {
00179   unsigned E;
00180   int Mx, My;
00181 
00182   if (!Operating())
00183     return NullMsg;
00184 
00185   // Get current status of buttons
00186   E = Status(Mx,My);
00187 
00188   // No mouse button downm, but maybe there was a button press that was
00189   // missed.  If not, check to see whether a buttton release was missed.
00190   // Favor the left button
00191 
00192   if (E == 0)  {
00193     if (PressCnt(LeftButton) > 0)
00194       E = LMouseDown;
00195   else
00196     if (PressCnt (RightButton) > 0)
00197       E = RMouseDown;
00198   // Maybe left one was just released
00199   else
00200     if (ReleaseCnt (LeftButton) > 0)
00201       E = LMouseUp;
00202   // Maybe rightr one was just released
00203   else
00204     if (ReleaseCnt(RightButton) > 0)
00205       E = RMouseDown;
00206   else
00207     E = Idle;
00208   }
00209 
00210   else { // a mouse button is down
00211   // was left already down?!?!??!
00212   if (E & LeftButton) {
00213   //not down
00214     if (PressCnt(LeftButton) > 0)
00215       E = LMouseDown;
00216     else
00217       E = LMouseStillDown;
00218   }
00219   else
00220     if (PressCnt(RightButton) > 0)
00221       E = RMouseDown;
00222   else
00223     E = RMouseStillDown;
00224   }
00225 
00226   return Message (MouseMsg, E, Mx, My);
00227 }

void MSMouse::Flush void   
 

Definition at line 349 of file msmouse.c.

References Message::code, Event(), and Idle.

00350 {
00351   Message m;
00352   do {
00353     m = Event ();
00354   } while (m.code != Idle);
00355 }

void MSMouse::Hide void   
 

Definition at line 90 of file msmouse.c.

References MsCall, and Operating().

Referenced by TurnOff().

00091 {
00092   REGS regs;
00093 
00094   if (!Operating())
00095     return;
00096   regs.x.ax = 2;
00097   int86(MsCall, &regs, &regs);
00098 }

void MSMouse::Move int    Mx,
int    My
 

Definition at line 270 of file msmouse.c.

References MsCall, and Operating().

Referenced by Setup().

00271 {
00272   REGS regs;
00273 
00274   if (!Operating())
00275     return;
00276 
00277   regs.x.ax = 4;
00278   regs.x.cx = Mx;
00279   regs.x.dx = My;
00280 
00281   if (TextMode) {
00282     regs.x.cx <<= 3;
00283     regs.x.dx <<= 3;
00284   }
00285 
00286   if (LowRes)
00287     regs.x.cx <<= 1;
00288   if (HighRes)
00289     regs.x.cx <<= 1;
00290 
00291   int86 (MsCall, &regs, &regs);
00292 }

bool MSMouse::Moved void    [protected]
 

Definition at line 257 of file msmouse.c.

References Dx, Dy, False, OldX, OldY, Operating(), Status(), X, and Y.

00258 {
00259   if (!Operating())
00260     return False;
00261   OldX = X;
00262   OldY = Y;
00263   Status(X,Y);
00264   Dx = X - OldX;
00265   Dy = Y - OldY;
00266 
00267   return (bool) ((Dx != 0) || (Dy != 0));
00268 }

bool MSMouse::Operating void    [inline, protected]
 

Definition at line 66 of file msmouse.h.

References MouseOff.

Referenced by ButtonStatus(), Event(), Hide(), Move(), Moved(), PressCnt(), ReleaseCnt(), SetGCursor(), Show(), WaitForAnyEvent(), and WaitForEvent().

00066 { return (bool) (!MouseOff); }

int MSMouse::PressCnt unsigned    ButtonMask [protected]
 

Definition at line 150 of file msmouse.c.

References MsCall, and Operating().

Referenced by Event().

00151 {
00152   REGS regs;
00153   if (!Operating())
00154     return 0;
00155 
00156   regs.x.ax = 5;
00157   regs.x.bx = ButtonMask >> 1; // Button selector
00158   int86(MsCall, &regs, &regs);
00159 
00160   return regs.x.bx;
00161 }

int MSMouse::ReleaseCnt unsigned    ButtonMask [protected]
 

Definition at line 163 of file msmouse.c.

References MsCall, and Operating().

Referenced by Event().

00164 {
00165   REGS regs;
00166 
00167   if (!Operating())
00168     return 0;
00169 
00170   regs.x.ax = 6;
00171   regs.x.bx = ButtonMask >> 1;
00172   int86(MsCall, &regs, &regs);
00173 
00174   return regs.x.bx;
00175 }

void MSMouse::SetGCursor const MouseCursor   NewCursor
 

Definition at line 310 of file msmouse.c.

References MouseCursor::HotSpot, MsCall, Operating(), MouseCursor::ScreenMask, HotSpotStruct::X, and HotSpotStruct::Y.

00311 {
00312   REGS regs;
00313   SREGS sregs;
00314 
00315   if (!Operating())
00316     return;
00317 
00318   regs.x.ax = 9;
00319   regs.x.bx = NewCursor.HotSpot.X;
00320   regs.x.cx = NewCursor.HotSpot.Y;
00321   regs.x.dx = FP_OFF(NewCursor.ScreenMask);
00322   sregs.es = FP_SEG(NewCursor.ScreenMask);
00323 
00324   int86x(MsCall, &regs, &regs, &sregs);
00325 }

void MSMouse::SetMouseCursor int   ,
int   
 

Definition at line 327 of file msmouse.c.

References MsCall.

00328 {
00329   REGS regs;
00330 
00331   regs.x.ax = 0x4;
00332   regs.x.cx = Mx;
00333   regs.x.dx = My;
00334 
00335   int86(MsCall, &regs, &regs);
00336 }

void MSMouse::SetSpeed2  
 

Definition at line 338 of file msmouse.c.

References MsCall, and THRESHOLD.

Referenced by Setup().

00339 {
00340   REGS regs;
00341 
00342   regs.x.ax = 0x13;
00343   regs.x.dx = THRESHOLD;
00344 
00345   int86(MsCall, &regs, &regs);
00346 }

void MSMouse::Setup VideoModeType    VideoMode
 

Definition at line 59 of file msmouse.c.

References DriverExists(), Dx, Dy, False, HighRes, HighResGr, LowRes, LowResGr, Move(), MsCall, OK, OldX, OldY, SetSpeed2(), TextMode, TextScrn, True, TurnOff(), TurnOn(), VideoModeType, X, and Y.

Referenced by MSMouse().

00060 {
00061   REGS regs;
00062 
00063   OK = DriverExists();
00064   if (OK) {
00065     regs.x.ax = 0;
00066     int86(MsCall, &regs, &regs);
00067     if (regs.x.ax == 0)
00068       OK = False;
00069   }
00070   if (!OK) {  // Mouse initialization failed. Set
00071     TurnOff();  // the mouse state off and return.
00072     return;
00073 
00074   }
00075   TurnOn();   // Set the mouse state on
00076 
00077   if (VideoMode == TextScrn) TextMode = True; else TextMode = False;
00078   if (VideoMode == LowResGr) LowRes = True; else LowRes = False;
00079   if (VideoMode == HighResGr) HighRes = True; else HighRes = False;
00080 
00081   OldX = 0;  OldY = 0;
00082   X = 0;   Y = 0;
00083   Dx = 0;  Dy = 0;
00084   Move (0,0);
00085 
00086   SetSpeed2();
00087 }

bool MSMouse::SetupOK void    [inline]
 

Definition at line 74 of file msmouse.h.

References OK.

Referenced by main().

00074 { return OK; }

void MSMouse::Show void   
 

Definition at line 100 of file msmouse.c.

References MsCall, and Operating().

Referenced by TurnOn().

00101 {
00102   REGS regs;
00103 
00104   if (!Operating())
00105     return;
00106   regs.x.ax = 1;
00107   int86 (MsCall, &regs, &regs);
00108 }

unsigned MSMouse::Status int &    Mx,
int &    My
[protected]
 

Definition at line 111 of file msmouse.c.

References MsCall.

Referenced by ButtonStatus(), Event(), and Moved().

00114 {
00115   REGS regs;
00116 
00117   if (!Operating()) {
00118     Mx = My = 0;
00119     return 0;
00120   }
00121 
00122   regs.x.ax = 3;
00123   int86(MsCall, &regs, &regs);
00124 
00125   Mx = regs.x.cx;
00126   My = regs.x.dx;
00127 
00128   if (TextMode)  {
00129     Mx >>= 3;  // Adjusts for text coordinates
00130     My >>= 3;
00131   }
00132 
00133   if (LowRes)
00134     Mx >>= 1;
00135 
00136   return regs.x.bx;
00137 }

void MSMouse::TurnOff void   
 

Definition at line 302 of file msmouse.c.

References Hide(), MouseOff, OK, and True.

Referenced by Setup().

00303 {
00304   if (OK && !MouseOff) {
00305     Hide();
00306     MouseOff = True;
00307   }
00308 }

void MSMouse::TurnOn void   
 

Definition at line 294 of file msmouse.c.

References False, MouseOff, OK, and Show().

Referenced by Setup().

00295 {
00296   if (OK && MouseOff) {
00297     MouseOff = False;
00298     Show();
00299   }
00300 }

Message MSMouse::WaitForAnyEvent void   
 

Definition at line 229 of file msmouse.c.

References Message::code, Event(), Idle, and Operating().

00230 {
00231   Message msg;
00232 
00233   if (!Operating()) return NullMsg;
00234 
00235   do {
00236     msg = Event();
00237   } while (msg.code == Idle);
00238 
00239   return msg;
00240 }

Message MSMouse::WaitForEvent Message  
 

Definition at line 243 of file msmouse.c.

References Message::code, Event(), and Operating().

00244 {
00245   Message try;
00246 
00247   if (!Operating()) return NullMsg;
00248 
00249   do {
00250      try = Event ();
00251   } while (try.code != msg.code);
00252 
00253   return try;
00254 }


Member Data Documentation

int MSMouse::Dx [protected]
 

Definition at line 69 of file msmouse.h.

Referenced by Moved(), and Setup().

int MSMouse::Dy [protected]
 

Definition at line 69 of file msmouse.h.

Referenced by Moved(), and Setup().

bool MSMouse::HighRes [protected]
 

Definition at line 60 of file msmouse.h.

Referenced by Setup().

bool MSMouse::LowRes [protected]
 

Definition at line 59 of file msmouse.h.

Referenced by Setup().

bool MSMouse::MouseOff [protected]
 

Definition at line 57 of file msmouse.h.

Referenced by MSMouse(), Operating(), TurnOff(), and TurnOn().

bool MSMouse::OK [protected]
 

Definition at line 56 of file msmouse.h.

Referenced by MSMouse(), Setup(), SetupOK(), TurnOff(), and TurnOn().

int MSMouse::OldX [protected]
 

Definition at line 55 of file msmouse.h.

Referenced by Moved(), and Setup().

int MSMouse::OldY [protected]
 

Definition at line 55 of file msmouse.h.

Referenced by Moved(), and Setup().

bool MSMouse::TextMode [protected]
 

Definition at line 58 of file msmouse.h.

Referenced by Setup().

int MSMouse::X [protected]
 

Definition at line 69 of file msmouse.h.

Referenced by Moved(), and Setup().

int MSMouse::Y [protected]
 

Definition at line 69 of file msmouse.h.

Referenced by Moved(), and Setup().


The documentation for this class was generated from the following files:
Generated on Sun Jul 6 23:07:17 2003 for Scotland Yard by doxygen1.2.15