///////////////////////////////////////////////////////////////////// // // MEVT.CPP // // class NODE // // RomaNets Text Windows Library (RTWL) // // version 0.60 // // David G. Roberts // #include "mevt.h" // =================================================================== int ResetMouse( void) { // =================================================================== union REGS regs; regs.x.ax = FC_RESET_MOUSE; int86( MOUSE_INT, ®s, ®s); if ( regs.x.ax == 0xFFFF) { return regs.x.bx; } else { return 0; } } // =================================================================== void ShowMouseCursor( void) { // =================================================================== union REGS regs; regs.x.ax = FC_SHOW_CURSOR; int86( MOUSE_INT, ®s, ®s); } // =================================================================== void HideMouseCursor( void) { // =================================================================== union REGS regs; regs.x.ax = FC_HIDE_CURSOR; int86( MOUSE_INT, ®s, ®s); } // =================================================================== void SetMouseEventHandler( UINT16 EventMask, void far *Handler) { // =================================================================== union REGS regs; struct SREGS sregs; regs.x.ax = FC_SET_EVENT_HANDLER; regs.x.cx = EventMask; regs.x.dx = FP_OFF(Handler); sregs.es = FP_SEG(Handler); int86x( MOUSE_INT, ®s, ®s, &sregs); } // =================================================================== static void far _loadds _saveregs MouseEventQueueHandler( void) { // =================================================================== UINT16 Event; UINT16 ButtonState; UINT16 X; UINT16 Y; UINT16 XMickeys; UINT16 YMickeys; MOUSE_EVENT far *EventQueueEntry; UINT16 EventBit; Event = _AX; ButtonState = _BX; X = _CX; Y = _DX; XMickeys = _SI; YMickeys = _DI; EventBit = 1; while ( EventBit & ALL_EVENTS) { if ( Event & EventBit) { EventQueueEntry = &(mq.Queue[mq.Write]); if ( EventQueueEntry->InUse == TRUE) { return; } EventQueueEntry->Event = Event & EventBit; EventQueueEntry->ButtonState = ButtonState; EventQueueEntry->X = X; EventQueueEntry->Y = Y; EventQueueEntry->XMickeys = XMickeys; EventQueueEntry->YMickeys = YMickeys; EventQueueEntry->InUse = TRUE; mq.Write++; if ( mq.Write >= mq.Length) { mq.Write = 0; } } EventBit <<= 1; } } // end MouseEventQueueHandler // =================================================================== int InstallMouseEventQueue( UINT16 Length, UINT16 EventMask) { // =================================================================== UINT16 i; mq.Queue = (MOUSE_EVENT far*)farmalloc( Length * sizeof( MOUSE_EVENT)); if ( mq.Queue == NULL) { return FALSE; } mq.Length = Length; mq.Write = 0; mq.Read = 0; for ( i = 0; i < Length; i++) { mq.Queue[i].InUse = FALSE; } SetMouseEventHandler( EventMask, MouseEventQueueHandler); HandlerInstalled = TRUE; return TRUE; } // =================================================================== void RemoveMouseEventQueue( void) { // =================================================================== SetMouseEventHandler( 0, NULL); farfree( mq.Queue); HandlerInstalled = FALSE; } // =================================================================== BOOL QueryMouseEventWaiting( void) { // =================================================================== if ( mq.Queue[mq.Read].InUse == TRUE) { return TRUE; } else { return FALSE; } } // =================================================================== int PeekMouseEvent( MOUSE_EVENT *me) { // =================================================================== MOUSE_EVENT far *CurrentEvent; CurrentEvent = &(mq.Queue[mq.Read]); me->InUse = CurrentEvent->InUse; me->Event = CurrentEvent->Event; me->ButtonState = CurrentEvent->ButtonState; me->X = CurrentEvent->X; me->Y = CurrentEvent->Y; me->XMickeys = CurrentEvent->XMickeys; me->YMickeys = CurrentEvent->YMickeys; return CurrentEvent->InUse; } // =================================================================== int GetMouseEvent( MOUSE_EVENT *me) { // =================================================================== PeekMouseEvent( me); if ( me->InUse == TRUE) { mq.Queue[mq.Read].InUse = FALSE; mq.Read++; if (mq.Read >= mq.Length) { mq.Read = 0; } } return me->InUse; } /* // ========================================================= void SetMousePos( UINT16 x, UINT16 y) { // ========================================================= x = (x << 3) -1; y = (y << 3) -1; asm { mov ax,0x04 mov cx,x mov dx,y int 0x33 } } */