/*=========================================================================== * * File: DosMouse.H * Author: Dave Humphrey (uesp@m0use.net) * Created On: Sunday, May 20, 2001 * * Defines the CDosMouse class for handling a mouse cursor in a DOS * based system. Uses 8086 specific assemmbly code to access the * mouse driver at interrupt 0x33. * *=========================================================================*/ #ifndef __DOSMOUSE_H #define __DOSMOUSE_H /*=========================================================================== * * Begin Required Include Files * *=========================================================================*/ #include "dl_err.h" /*=========================================================================== * End of Required Include Files *=========================================================================*/ /*=========================================================================== * * Begin Definitions * *=========================================================================*/ /* Values for use with the button status routines */ #define MOUSE_LEFTBUTTON_MASK 1 #define MOUSE_RIGHTBUTTON_MASK 2 #define MOUSE_MIDDLEBUTTON_MASK 4 #define MOUSE_LEFTBUTTON 0 #define MOUSE_RIGHTBUTTON 1 #define MOUSE_MIDDLEBUTTON 2 /*=========================================================================== * End of Definitions *=========================================================================*/ /*=========================================================================== * * Begin Type Definitions * *=========================================================================*/ /* Used to identify mouse buttons */ typedef short mouse_button_t; /* Used for holding the button status of the mouse */ typedef union { struct tagMouseButtons { ushort LeftButton : 1; ushort RightButton : 1; ushort MiddleButton : 1; }; ushort Status; } mouse_status_t; /* Holds information on the state of a button */ typedef struct { mouse_status_t ButtonStatus; short EventCount; short EventXPos; short EventYPos; } mouse_buttonstate_t; /*=========================================================================== * End of Type Definitions *=========================================================================*/ /*=========================================================================== * * Begin Class CDosMouse Definition * * Class for handling a mouse cursor under DOS. Supports a variety of * text and video modes. * *=========================================================================*/ class CDosMouse { /*---------- Begin Private Class Members ----------------------*/ private: boolean m_Initialized; /* Initialized state of mouse */ boolean m_CursorVisible; /* Is cursor hidden or visible */ static boolean m_HandlerInstalled; /* Is the custom handler installed? */ /*---------- Begin Protected Class Methods --------------------*/ protected: /* Used to register a mouse not initialized error message */ void RegisterNotInitError (void) { ErrorHandler.AddError(ERR_BADINPUT, "Mouse has not been initialized!"); } /*---------- Begin Public Class Methods -----------------------*/ public: /* Class Constructors/Destructors */ CDosMouse(); virtual ~CDosMouse() { Destroy(); } virtual void Destroy (void); /* Get properties of the mouse */ boolean GetButtonStatus (mouse_status_t& ButtonStatus); boolean GetPosition (short& XPos, short& YPos); boolean GetPressStatus (mouse_buttonstate_t& ButtonState, const mouse_button_t Button); boolean GetReleaseStatus (mouse_buttonstate_t& ButtonState, const mouse_button_t Button); boolean GetCounters (short& XCount, short& YCount); /* Attempt to hide the mouse cursor */ void Hide (void); /* Attempt to initialize the mouse handler */ boolean Initialize (void); /* Installs the custom mouse handler */ boolean InstallHandler (void); /* Check the various states of the mouse */ static boolean IsHandlerInstalled (void); boolean IsInitialized (void); boolean IsVisible (void); /* Removes the custom mouse handler */ void RemoveHandler (void); /* Set properties of the mouse */ boolean SetPosition (const short XPos, const short YPos); boolean SetWindow (const short Left, const short Top, const short Right, const short Bottom); /* Show the mouse cursor */ void Show (void); }; /*=========================================================================== * End of Class CDosMouse Definition *=========================================================================*/ /*=========================================================================== * * Begin Class CDosMouse Inline Methods * *=========================================================================*/ inline boolean CDosMouse::IsHandlerInstalled (void) { return (m_HandlerInstalled); } inline boolean CDosMouse::IsInitialized (void) { return (m_Initialized); } inline boolean CDosMouse::IsVisible (void) { return (m_CursorVisible); } /*=========================================================================== * End of Class CDosMouse Inline Methods *=========================================================================*/ /*=========================================================================== * * External Variable Definitions * *=========================================================================*/ extern short g_DosMouseX; extern short g_DosMouseY; extern short g_DosMouseStatus; extern short g_DosMouseXCount; extern short g_DosMouseYCount; /*=========================================================================== * End of External Variable Definitions *=========================================================================*/ #endif /*=========================================================================== * End of File Dosmouse.H *=========================================================================*/