/**************************************************************************** PARAMETERS: mask - Event mask butstate - Button state x - Mouse x coordinate y - Mouse y coordinate REMARKS: Mouse event handling routine. This gets called when a mouse event occurs, and we call the addMouseEvent() routine to add the appropriate mouse event to the event queue. Note: Interrupts are ON when this routine is called by the mouse driver code. ****************************************************************************/ static void EVTAPI mouseISR( uint mask, uint butstate, int x, int y, int mickeyX, int mickeyY) { RMREGS regs; uint ps; if (mask & 1) { /* Save the current mouse coordinates */ _EVT_mx = x; _EVT_my = y; /* Call mouse function 11 to clear the motion counters */ regs.x.ax = 11; PM_int86(0x33,®s,®s); mickeyX = (short)regs.x.cx; mickeyY = (short)regs.x.dx; /* If the last event was a movement event, then modify the last * event rather than post a new one, so that the queue will not * become saturated. Before we modify the data structures, we * MUST ensure that interrupts are off. */ ps = _EVT_disableInt(); if (oldMove != -1) { evtq[oldMove].where_x = x; /* Modify existing one */ evtq[oldMove].where_y = y; evtq[oldMove].relative_x += mickeyX; evtq[oldMove].relative_y += mickeyY; } else { oldMove = freeHead; /* Save id of this move event */ addMouseEvent(EVT_MOUSEMOVE,0,x,y,mickeyX,mickeyY,butstate); } _EVT_restoreInt(ps); } if (mask & 0x2A) { ps = _EVT_disableInt(); addMouseEvent(EVT_MOUSEDOWN,mask >> 1,x,y,0,0,butstate); oldMove = -1; _EVT_restoreInt(ps); }
/*AM: be installed until it is. */ ****************************************************************************/ static void EVTAPI mouseISR( uint mask, uint butstate, int x, int y, int mickeyX, int mickeyY) { RMREGS regs; uint ps; if (mask & 1) { /* Save the current mouse coordinates */ EVT.mx = x; EVT.my = y; /* If the last event was a movement event, then modify the last * event rather than post a new one, so that the queue will not * become saturated. Before we modify the data structures, we * MUST ensure that interrupts are off. */ ps = _EVT_disableInt(); if (EVT.oldMove != -1) { EVT.evtq[EVT.oldMove].where_x = x; /* Modify existing one */ EVT.evtq[EVT.oldMove].where_y = y; EVT.evtq[EVT.oldMove].relative_x += mickeyX; EVT.evtq[EVT.oldMove].relative_y += mickeyY; } else { EVT.oldMove = EVT.freeHead; /* Save id of this move event */ addMouseEvent(EVT_MOUSEMOVE,0,x,y,mickeyX,mickeyY,butstate); } _EVT_restoreInt(ps); } if (mask & 0x2A) { ps = _EVT_disableInt(); addMouseEvent(EVT_MOUSEDOWN,mask >> 1,x,y,0,0,butstate); EVT.oldMove = -1; _EVT_restoreInt(ps); }
/**************************************************************************** DESCRIPTION: Polls the joystick for position and button information. HEADER: event.h REMARKS: This routine is used to poll analogue joysticks for button and position information. It should be called once for each main loop of the user application, just before processing all pending events via EVT_getNext. All information polled from the joystick will be posted to the event queue for later retrieval. Note: Most analogue joysticks will provide readings that change even though the joystick has not moved. Hence if you call this routine you will likely get an EVT_JOYMOVE event every time through your event loop. SEE ALSO: EVT_getNext, EVT_peekNext, EVT_joySetUpperLeft, EVT_joySetLowerRight, EVT_joySetCenter, EVT_joyIsPresent ****************************************************************************/ void EVTAPI EVT_pollJoystick(void) { event_t evt; int i,axis[JOY_NUM_AXES],newButState,mask,moved,ps; /* TODO: Can this be removed and/or put in a separate thread eventually? */ if ((js_version & ~0xFFFF) == 0 && EVT.joyMask) { /* Read joystick axes and post movement events if they have * changed since the last time we polled. Until the events are * actually flushed, we keep modifying the same joystick movement * event, so you won't get multiple movement event */ mask = _EVT_readJoyAxis(EVT.joyMask,axis); newButState = _EVT_readJoyButtons(); moved = false; for (i = 0; i < JOY_NUM_AXES; i++) { if (mask & (EVT_JOY_AXIS_X1 << i)) axis[i] = scaleJoyAxis(axis[i],i); else axis[i] = EVT.joyPrev[i]; if (axis[i] != EVT.joyPrev[i]) moved = true; } if (moved) { ps = _EVT_disableInt(); memcpy(EVT.joyPrev,axis,sizeof(EVT.joyPrev)); if (EVT.oldJoyMove != -1) { /* Modify the existing joystick movement event */ EVT.evtq[EVT.oldJoyMove].message = newButState; EVT.evtq[EVT.oldJoyMove].where_x = EVT.joyPrev[0]; EVT.evtq[EVT.oldJoyMove].where_y = EVT.joyPrev[1]; EVT.evtq[EVT.oldJoyMove].relative_x = EVT.joyPrev[2]; EVT.evtq[EVT.oldJoyMove].relative_y = EVT.joyPrev[3]; } else if (EVT.count < EVENTQSIZE) { /* Add a new joystick movement event */ EVT.oldJoyMove = EVT.freeHead; memset(&evt,0,sizeof(evt)); evt.what = EVT_JOYMOVE; evt.message = EVT.joyButState; evt.where_x = EVT.joyPrev[0]; evt.where_y = EVT.joyPrev[1]; evt.relative_x = EVT.joyPrev[2]; evt.relative_y = EVT.joyPrev[3]; addEvent(&evt); } _EVT_restoreInt(ps); } /* Read the joystick buttons, and post events to reflect the change * in state for the joystick buttons. */ if (newButState != EVT.joyButState) { ps = _EVT_disableInt(); if (EVT.count < EVENTQSIZE) { /* Add a new joystick movement event */ memset(&evt,0,sizeof(evt)); evt.what = EVT_JOYCLICK; evt.message = newButState; EVT.evtq[EVT.oldJoyMove].where_x = EVT.joyPrev[0]; EVT.evtq[EVT.oldJoyMove].where_y = EVT.joyPrev[1]; EVT.evtq[EVT.oldJoyMove].relative_x = EVT.joyPrev[2]; EVT.evtq[EVT.oldJoyMove].relative_y = EVT.joyPrev[3]; addEvent(&evt); } EVT.joyButState = newButState; _EVT_restoreInt(ps); } } }