?? event.c
字號:
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) { if (EVT.count < EVENTQSIZE) { /* Add a new joystick click event */ ps = _EVT_disableInt(); 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_restoreInt(ps); } EVT.joyButState = newButState; } }}/****************************************************************************DESCRIPTION:Calibrates the joystick upper left positionHEADER:event.hREMARKS:This function can be used to zero in on better joystick calibration factors,which may work better than the default simplistic calibration (which assumesthe joystick is centered when the event library is initialised).To use this function, ask the user to hold the stick in the upper leftposition and then have them press a key or button. and then call thisfunction. This function will then read the joystick and update thecalibration factors.Usually, assuming that the stick was centered when the event library wasinitialized, you really only need to call EVT_joySetLowerRight since theupper left position is usually always 0,0 on most joysticks. However, thesafest procedure is to call all three calibration functions.SEE ALSO:EVT_joySetUpperLeft, EVT_joySetLowerRight, EVT_joyIsPresent****************************************************************************/void EVTAPI EVT_joySetUpperLeft(void){ _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyMin);}/****************************************************************************DESCRIPTION:Calibrates the joystick lower right positionHEADER:event.hREMARKS:This function can be used to zero in on better joystick calibration factors,which may work better than the default simplistic calibration (which assumesthe joystick is centered when the event library is initialised).To use this function, ask the user to hold the stick in the lower rightposition and then have them press a key or button. and then call thisfunction. This function will then read the joystick and update thecalibration factors.Usually, assuming that the stick was centered when the event library wasinitialized, you really only need to call EVT_joySetLowerRight since theupper left position is usually always 0,0 on most joysticks. However, thesafest procedure is to call all three calibration functions.SEE ALSO:EVT_joySetUpperLeft, EVT_joySetCenter, EVT_joyIsPresent****************************************************************************/void EVTAPI EVT_joySetLowerRight(void){ _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyMax);}/****************************************************************************DESCRIPTION:Calibrates the joystick center positionHEADER:event.hREMARKS:This function can be used to zero in on better joystick calibration factors,which may work better than the default simplistic calibration (which assumesthe joystick is centered when the event library is initialised).To use this function, ask the user to hold the stick in the centerposition and then have them press a key or button. and then call thisfunction. This function will then read the joystick and update thecalibration factors.Usually, assuming that the stick was centered when the event library wasinitialized, you really only need to call EVT_joySetLowerRight since theupper left position is usually always 0,0 on most joysticks. However, thesafest procedure is to call all three calibration functions.SEE ALSO:EVT_joySetUpperLeft, EVT_joySetLowerRight, EVT_joySetCenter****************************************************************************/void EVTAPI EVT_joySetCenter(void){ _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyCenter);}#endif/****************************************************************************DESCRIPTION:Posts a user defined event to the event queueHEADER:event.hRETURNS:True if event was posted, false if event queue is full.PARAMETERS:what - Type code for message to postmessage - Event specific message to postmodifiers - Event specific modifier flags to postREMARKS:This routine is used to post user defined events to the event queue.SEE ALSO:EVT_flush, EVT_getNext, EVT_peekNext, EVT_halt****************************************************************************/ibool EVTAPI EVT_post( ulong which, ulong what, ulong message, ulong modifiers){ event_t evt; uint ps; if (EVT.count < EVENTQSIZE) { /* Save information in event record */ ps = _EVT_disableInt(); evt.which = which; evt.when = _EVT_getTicks(); evt.what = what; evt.message = message; evt.modifiers = modifiers; addEvent(&evt); /* Add to EVT.tail of event queue */ _EVT_restoreInt(ps); return true; } else return false;}/****************************************************************************DESCRIPTION:Flushes all events of a specified type from the event queue.PARAMETERS:mask - Mask specifying the types of events that should be removedHEADER:event.hREMARKS:Flushes (removes) all pending events of the specified type from the eventqueue. You may combine the masks for different event types with a simplelogical OR.SEE ALSO:EVT_getNext, EVT_halt, EVT_peekNext****************************************************************************/void EVTAPI EVT_flush( ulong mask){ event_t evt; do { /* Flush all events */ EVT_getNext(&evt,mask); } while (evt.what != EVT_NULLEVT);}/****************************************************************************DESCRIPTION:Halts until and event of the specified type is recieved.HEADER:event.hPARAMETERS:evt - Pointer tomask - Mask specifying the types of events that should be removedREMARKS:This functions halts exceution until an event of the specified type isrecieved into the event queue. It does not flush the event queue of eventsbefore performing the busy loop. However this function does throw awayany events other than the ones you have requested via the event mask, toavoid the event queue filling up with unwanted events (like EVT_KEYUP orEVT_MOUSEMOVE events).SEE ALSO:EVT_getNext, EVT_flush, EVT_peekNext****************************************************************************/void EVTAPI EVT_halt( event_t *evt, ulong mask){ do { /* Wait for an event */ if (mask & (EVT_JOYEVT)) EVT_pollJoystick(); EVT_getNext(evt,EVT_EVERYEVT); } while (!(evt->what & mask));}/****************************************************************************DESCRIPTION:Peeks at the next pending event in the event queue.HEADER:event.hRETURNS:True if an event is pending, false if not.PARAMETERS:evt - Pointer to structure to return the event info inmask - Mask specifying the types of events that should be removedREMARKS:Peeks at the next pending event of the specified type in the event queue. Themask parameter is used to specify the type of events to be peeked at, andcan be any logical combination of any of the flags defined by theEVT_eventType enumeration.In contrast to EVT_getNext, the event is not removed from the event queue.You may combine the masks for different event types with a simple logical OR.SEE ALSO:EVT_flush, EVT_getNext, EVT_halt****************************************************************************/ibool EVTAPI EVT_peekNext( event_t *evt, ulong mask){ int evtID; uint ps; if (EVT.heartBeat) EVT.heartBeat(EVT.heartBeatParams); _EVT_pumpMessages(); /* Pump all messages into queue */ EVT.mouseMove(EVT.mx,EVT.my); /* Move the mouse cursor */ evt->what = EVT_NULLEVT; /* Default to null event */ if (EVT.count) { /* It is possible that an event be posted while we are trying * to access the event queue. This would create problems since * we may end up with invalid data for our event queue pointers. To * alleviate this, all interrupts are suspended while we manipulate * our pointers. */ ps = _EVT_disableInt(); /* disable interrupts */ for (evtID = EVT.head; evtID != -1; evtID = EVT.evtq[evtID].next) { if (EVT.evtq[evtID].what & mask) break; /* Found an event */ } if (evtID == -1) { _EVT_restoreInt(ps); return false; /* Event was not found */ } *evt = EVT.evtq[evtID]; /* Return the event */ _EVT_restoreInt(ps); if (evt->what & EVT_KEYEVT) _EVT_maskKeyCode(evt); } return evt->what != EVT_NULLEVT;}/****************************************************************************DESCRIPTION:Retrieves the next pending event from the event queue.PARAMETERS:evt - Pointer to structure to return the event info inmask - Mask specifying the types of events that should be removedHEADER:event.hRETURNS:True if an event was pending, false if not.REMARKS:Retrieves the next pending event from the event queue, and stores it in aevent_t structure. The mask parameter is used to specify the type of eventsto be removed, and can be any logical combination of any of the flags definedby the EVT_eventType enumeration.The what field of the event contains the event code of the event that wasextracted. All application specific events should begin with the EVT_USEREVTcode and build from there. Since the event code is stored in an integer,there is a maximum of 32 different event codes that can be distinguished.You can store extra information about the event in the message field todistinguish between events of the same class (for instance the button used ina EVT_MOUSEDOWN event).If an event of the specified type was not in the event queue, the what fieldof the event will be set to NULLEVT, and the return value will return false.Note: You should /always/ use the EVT_EVERYEVT mask for extracting events from your main event loop handler. Using a mask for only a specific type of event for long periods of time will cause the event queue to fill up with events of the type you are ignoring, eventually causing the application to hang when the event queue becomes full.SEE ALSO:EVT_flush, EVT_halt, EVT_peekNext****************************************************************************/ibool EVTAPI EVT_getNext( event_t *evt, ulong mask){ int evtID,next,prev; uint ps; if (EVT.heartBeat) EVT.heartBeat(EVT.heartBeatParams); _EVT_pumpMessages(); /* Pump all messages into queue */ EVT.mouseMove(EVT.mx,EVT.my); /* Move the mouse cursor */ evt->what = EVT_NULLEVT; /* Default to null event */ if (EVT.count) { /* It is possible that an event be posted while we are trying * to access the event queue. This would create problems since * we may end up with invalid data for our event queue pointers. To * alleviate this, all interrupts are suspended while we manipulate * our pointers. */ ps = _EVT_disableInt(); /* disable interrupts */ for (evtID = EVT.head; evtID != -1; evtID = EVT.evtq[evtID].next) { if (EVT.evtq[evtID].what & mask) break; /* Found an event */ } if (evtID == -1) { _EVT_restoreInt(ps); return false; /* Event was not found */ } next = EVT.evtq[evtID].next; prev = EVT.evtq[evtID].prev; if (prev != -1) EVT.evtq[prev].next = next; else EVT.head = next; if (next != -1) EVT.evtq[next].prev = prev; else EVT.tail = prev;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -