//===========================================================================// // File: PCmouse.cc // // Project: MUNGA Brick: Platform-specific IO // // Contents: PC mouse interface // //---------------------------------------------------------------------------// // Date Who Modification // // -------- --- -----------------------------------------------------------// // 01/24/95 CPB Initial coding. // //---------------------------------------------------------------------------// // Copyright (C) 1995, Virtual World Entertainment, Inc. All rights reserved // // PROPRIETARY and CONFIDENTIAL // //===========================================================================// #include #pragma hdrstop #if !defined(L4MOUSE_HPP) # include #endif #define MOUSEINT 0x33 // //############################################################################ // Creator - reset the driver and check for existence // //############################################################################ // Mouse::Mouse() { Check_Pointer(this); // //----------------------------------------------- // Reset driver and read status //----------------------------------------------- // _AX = 0; geninterrupt(MOUSEINT); // //----------------------------------------------- // AX will be zero if error, 0xFFFF if ok. // BX is the number of buttons. //----------------------------------------------- // if (_AX == 0xFFFF) { ButtonCount = _BX; Errors = 0; } else { Errors = 1; ButtonCount = 0; } Check_Fpu(); } Logical Mouse::TestInstance() const { return True; } // //############################################################################ // ReadCounters - return how many 'mickeys' the mouse has moved // since the last call //############################################################################ // void Mouse::ReadCounters(int *xp, int *yp) { Check(this); Check_Pointer(xp); Check_Pointer(yp); if (Errors) { *xp = 0; *yp = 0; } else { // //----------------------------------------------- // Read motion counters //----------------------------------------------- // _AX = 0x000B; geninterrupt(MOUSEINT); // //----------------------------------------------- // CX = UNSIGNED x counter, // DX = UNSIGNED y counter. // These must be converted to signed values. //----------------------------------------------- // int a = _CX; int b = _DX; if (a & 0x8000) { a |= (int)(~65535L); } if (b & 0x8000) { b |= (int)(~65535L); } *xp = a; *yp = b; } Check_Fpu(); } // //############################################################################ // ButtonPressed - return the number of times a given button was pressed // since the last call //############################################################################ // int Mouse::ButtonPressed(int buttonNum) { Check(this); if (Errors) { return 0; } else { // //----------------------------------------------- // Read button press data //----------------------------------------------- // _AX = 0x0005; _BX = (unsigned short) buttonNum; geninterrupt(MOUSEINT); // //----------------------------------------------- // AX = current button states // BX = number of times pressed since last call //----------------------------------------------- // return (int) _BX; } } // //############################################################################ // ButtonReleased - return the number of times a given button was released // since the last call //############################################################################ // int Mouse::ButtonReleased(int buttonNum) { Check(this); if (Errors) { return 0; } else { // //----------------------------------------------- // Read button press data //----------------------------------------------- // _AX = 0x0006; _BX = (unsigned short) buttonNum; geninterrupt(MOUSEINT); // //----------------------------------------------- // AX = current button states // BX = number of times pressed since last call //----------------------------------------------- // return _BX; } }