⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 event.c

📁 BIOS emulator and interface to Realmode X86 Emulator Library Can emulate a PCI Graphic Controller V
💻 C
📖 第 1 页 / 共 3 页
字号:
{	int     evtID,next,prev;	uint	ps;	_EVT_pumpMessages();				/* Pump all messages into queue	*/	_mouseMove(_EVT_mx,_EVT_my);		/* Move the mouse cursor		*/	evt->what = EVT_NULLEVT;           	/* Default to null event    	*/	if (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 = head; evtID != -1; evtID = evtq[evtID].next) {			if (evtq[evtID].what & mask)				break;                      /* Found an event           */			}		if (evtID == -1) {			_EVT_restoreInt(ps);			return false;                   /* Event was not found      */			}		next = evtq[evtID].next;		prev = evtq[evtID].prev;		if (prev != -1)			evtq[prev].next = next;		else			head = next;		if (next != -1)			evtq[next].prev = prev;		else			tail = prev;		*evt = evtq[evtID];                 /* Return the event         */		evtq[evtID].next = freeHead;        /* and return to free list  */		freeHead = evtID;		count--;		if (evt->what == EVT_MOUSEMOVE)			oldMove = -1;		if (evt->what == EVT_KEYREPEAT)			oldKey = -1;		if (evt->what == EVT_JOYMOVE)			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 && autoRepeat && (mask & EVT_MOUSEAUTO) && (downMouse.what & EVT_MOUSEDOWN)) {		ulong ticks = _EVT_getTicks();		if ((ticks - autoTicks) >= (autoRepeat + (firstAuto ? autoDelay : 0))) {			evt->what = EVT_MOUSEAUTO;			evt->message = downMouse.message;			evt->modifiers = downMouse.modifiers;			evt->where_x = autoMouse_x;			evt->where_y = autoMouse_y;			evt->relative_x = 0;			evt->relative_y = 0;			autoTicks = evt->when = ticks;			firstAuto = false;			}		}	return evt->what != EVT_NULLEVT;}/****************************************************************************DESCRIPTION:Installs a user supplied event filter callback for event handling.HEADER:mgldos.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){	_userEventCallback = filter;}/****************************************************************************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);	_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 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){	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 + -