📄 event.c
字号:
*evt = EVT.evtq[evtID]; /* Return the event */ EVT.evtq[evtID].next = EVT.freeHead; /* and return to free list */ EVT.freeHead = evtID; EVT.count--; if (evt->what == EVT_MOUSEMOVE) EVT.oldMove = -1; if (evt->what == EVT_KEYREPEAT) EVT.oldKey = -1; if (evt->what == EVT_JOYMOVE) EVT.oldJoyMove = -1; _EVT_restoreInt(ps); /* enable interrupts */ if (evt->what & EVT_KEYEVT) _EVT_maskKeyCode(evt); } /* If there is no event pending, check if we should generate an auto * mouse down event if the mouse is still currently down. */ if (evt->what == EVT_NULLEVT && EVT.autoRepeat && (mask & EVT_MOUSEAUTO) && (EVT.downMouse.what & EVT_MOUSEDOWN)) { ulong ticks = _EVT_getTicks(); if ((ticks - EVT.autoTicks) >= (EVT.autoRepeat + (EVT.firstAuto ? EVT.autoDelay : 0))) { evt->what = EVT_MOUSEAUTO; evt->message = EVT.downMouse.message; evt->modifiers = EVT.downMouse.modifiers; evt->where_x = EVT.autoMouse_x; evt->where_y = EVT.autoMouse_y; evt->relative_x = 0; evt->relative_y = 0; EVT.autoTicks = evt->when = ticks; EVT.firstAuto = false; } } return evt->what != EVT_NULLEVT;}/****************************************************************************DESCRIPTION:Installs a user supplied event filter callback for event handling.HEADER:event.hPARAMETERS:userEventFilter - Address of user supplied event filter callbackREMARKS:This function allows the application programmer to install an event filtercallback for event handling. Once you install your callback, the MGLevent handling routines will call your callback with a pointer to thenew event that will be placed into the event queue. Your callback can themodify the contents of the event before it is placed into the queue (forinstance adding custom information or perhaps high precision timinginformation).If your callback returns FALSE, the event will be ignore and will not beposted to the event queue. You should always return true from your eventcallback unless you plan to use the events immediately that they arerecieved.Note: Your event callback may be called in response to a hardware interrupt and will be executing in the context of the hardware interrupt handler under MSDOS (ie: keyboard interrupt or mouse interrupt). For this reason the code pages for the callback that you register must be locked in memory with the PM_lockCodePages function. You must also lock down any data pages that your function needs to reference as well.Note: You can also use this filter callback to process events at the time they are activated by the user (ie: when the user hits the key or moves the mouse), but make sure your code runs as fast as possible as it will be executing inside the context of an interrupt handler on some systems.SEE ALSO:EVT_getNext, EVT_peekNext****************************************************************************/void EVTAPI EVT_setUserEventFilter( _EVT_userEventFilter filter){ EVT.userEventCallback = filter;}/****************************************************************************DESCRIPTION:Installs a user supplied event heartbeat callback function.HEADER:event.hPARAMETERS:callback - Address of user supplied event heartbeat callbackparams - Parameters to pass to the event heartbeat functionREMARKS:This function allows the application programmer to install an event heatbeatfunction that gets called every time that EVT_getNext or EVT_peekNextis called. This is primarily useful for simulating text mode cursors insideevent handling code when running in graphics modes as opposed to hardwaretext modes.SEE ALSO:EVT_getNext, EVT_peekNext, EVT_getHeartBeatCallback****************************************************************************/void EVTAPI EVT_setHeartBeatCallback( _EVT_heartBeatCallback callback, void *params){ EVT.heartBeat = callback; EVT.heartBeatParams = params;}/****************************************************************************DESCRIPTION:Returns the current user supplied event heartbeat callback function.HEADER:event.hPARAMETERS:callback - Place to store the address of user supplied event heartbeat callbackparams - Place to store the parameters to pass to the event heartbeat functionREMARKS:This function retrieves the current event heatbeat function that gets calledevery time that EVT_getNext or EVT_peekNext is called.SEE ALSO:EVT_getNext, EVT_peekNext, EVT_setHeartBeatCallback****************************************************************************/void EVTAPI EVT_getHeartBeatCallback( _EVT_heartBeatCallback *callback, void **params){ *callback = EVT.heartBeat; *params = EVT.heartBeatParams;}/****************************************************************************DESCRIPTION:Determines if a specified key is currently down.PARAMETERS:scanCode - Scan code to testRETURNS:True of the specified key is currently held down.HEADER:event.hREMARKS:This function determines if a specified key is currently down at thetime that the call is made. You simply need to pass in the scan code ofthe key that you wish to test, and the MGL will tell you if it is currentlydown or not. The MGL does this by keeping track of the up and down stateof all the keys.****************************************************************************/ibool EVTAPI EVT_isKeyDown( uchar scanCode){ return _EVT_isKeyDown(scanCode);}/****************************************************************************DESCRIPTION:Set the mouse position for the event modulePARAMETERS:x - X coordinate to move the mouse cursor position toy - Y coordinate to move the mouse cursor position toHEADER:event.hREMARKS:This function moves the mouse cursor position for the event module to thespecified location.SEE ALSO:EVT_getMousePos****************************************************************************/void EVTAPI EVT_setMousePos( int x, int y){ EVT.mx = x; EVT.my = y; _EVT_setMousePos(&EVT.mx,&EVT.my); EVT.mouseMove(EVT.mx,EVT.my);}/****************************************************************************DESCRIPTION:Returns the current mouse cursor location.HEADER:event.hPARAMETERS:x - Place to store value for mouse x coordinate (screen coordinates)y - Place to store value for mouse y coordinate (screen coordinates)REMARKS:Obtains the current mouse cursor position in screen coordinates. Normally themouse cursor location is tracked using the mouse movement events that areposted to the event queue when the mouse moves, however this routineprovides an alternative method of polling the mouse cursor location.SEE ALSO:EVT_setMousePos****************************************************************************/void EVTAPI EVT_getMousePos( int *x, int *y){ *x = EVT.mx; *y = EVT.my;}/****************************************************************************DESCRIPTION:Returns the currently active code page for translation of keyboard characters.HEADER:event.hRETURNS:Pointer to the currently active code page translation table.REMARKS:This function is returns a pointer to the currently active code pagetranslation table. See EVT_setCodePage for more information.SEE ALSO:EVT_setCodePage****************************************************************************/codepage_t * EVTAPI EVT_getCodePage(void){ return EVT.codePage;}/****************************************************************************DESCRIPTION:Sets the currently active code page for translation of keyboard characters.HEADER:event.hPARAMETERS:page - New code page to make activeREMARKS:This function is used to set a new code page translation table that is usedto translate virtual scan code values to ASCII characters for differentkeyboard configurations. The default is usually US English, although ifpossible the PM library will auto-detect the correct code page translationfor the target OS if OS services are available to determine what type ofkeyboard is currently attached.SEE ALSO:EVT_getCodePage****************************************************************************/void EVTAPI EVT_setCodePage( codepage_t *page){ EVT.codePage = page;}/* The following contains fake C prototypes and documentation for the * macro functions in the event.h header file. These exist soley so * that DocJet will correctly pull in the documentation for these functions. */#ifdef INCLUDE_DOC_FUNCTIONS/****************************************************************************DESCRIPTION:Macro to extract the ASCII code from a message.PARAMETERS:message - Message to extract ASCII code fromRETURNS:ASCII code extracted from the message.HEADER:event.hREMARKS:Macro to extract the ASCII code from the message field of the event_tstructure. You pass the message field to the macro as the parameter andthe ASCII code is the result, for example: event_t EVT.myEvent; uchar code; code = EVT_asciiCode(EVT.myEvent.message);SEE ALSO:EVT_scanCode, EVT_repeatCount****************************************************************************/uchar EVT_asciiCode( ulong message);/****************************************************************************DESCRIPTION:Macro to extract the keyboard scan code from a message.HEADER:event.hPARAMETERS:message - Message to extract scan code fromRETURNS:Keyboard scan code extracted from the message.REMARKS:Macro to extract the keyboard scan code from the message field of the eventstructure. You pass the message field to the macro as the parameter andthe scan code is the result, for example: event_t EVT.myEvent; uchar code; code = EVT_scanCode(EVT.myEvent.message);NOTE: Scan codes in the event library are not really hardware scan codes, but rather virtual scan codes as generated by a low level keyboard interface driver. All virtual scan code values are defined by the EVT_scanCodesType enumeration, and will be identical across all supports OS'es and platforms.SEE ALSO:EVT_asciiCode, EVT_repeatCount****************************************************************************/uchar EVT_scanCode( ulong message);/****************************************************************************DESCRIPTION:Macro to extract the repeat count from a message.HEADER:event.hPARAMETERS:message - Message to extract repeat count fromRETURNS:Repeat count extracted from the message.REMARKS:Macro to extract the repeat count from the message field of the eventstructure. The repeat count is the number of times that the key repeatedbefore there was another keyboard event to be place in the queue, andallows the event handling code to avoid keyboard buffer overflowconditions when a single key is held down by the user. If you are processinga key repeat code, you will probably want to check this field to see howmany key repeats you should process for this message.SEE ALSO:EVT_asciiCode, EVT_repeatCount****************************************************************************/short EVT_repeatCount( ulong message);#endif /* DOC FUNCTIONS */#if defined(__REALDOS__) || defined(__SMX32__)/* {secret} */void EVTAPI _EVT_cCodeEnd(void) {}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -