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

📄 event.c

📁 自己修改的U-boot1.1.4For AT91RM9200DK. 请用armgcc3.3.2编译。
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************                   SciTech OS Portability Manager Library**  ========================================================================**    The contents of this file are subject to the SciTech MGL Public*    License Version 1.0 (the "License"); you may not use this file*    except in compliance with the License. You may obtain a copy of*    the License at http://www.scitechsoft.com/mgl-license.txt**    Software distributed under the License is distributed on an*    "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or*    implied. See the License for the specific language governing*    rights and limitations under the License.**    The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.**    The Initial Developer of the Original Code is SciTech Software, Inc.*    All Rights Reserved.**  ========================================================================** Language:     ANSI C* Environment:  IBM PC (OS/2)** Description:  OS/2 implementation for the SciTech cross platform*               event library.*****************************************************************************//*---------------------------- Global Variables ---------------------------*//* Define generous keyboard monitor circular buffer size to minimize * the danger of losing keystrokes */#define KEYBUFSIZE  (EVENTQSIZE + 10)static int      oldMouseState;          /* Old mouse state               */static ulong    oldKeyMessage;          /* Old keyboard state            */static ushort   keyUpMsg[256] = {0};    /* Table of key up messages      */static int      rangeX,rangeY;          /* Range of mouse coordinates    */HMOU            _EVT_hMouse;            /* Handle to the mouse driver    */HMONITOR        _EVT_hKbdMon;           /* Handle to the keyboard driver */TID             kbdMonTID = 0;          /* Keyboard monitor thread ID    */HEV             hevStart;               /* Start event semaphore handle  */BOOL            bMonRunning;            /* Flag set if monitor thread OK */HMTX            hmtxKeyBuf;             /* Mutex protecting key buffer   */KEYPACKET       keyMonPkts[KEYBUFSIZE]; /* Array of monitor key packets  */int             kpHead = 0;             /* Key packet buffer head        */int             kpTail = 0;             /* Key packet buffer tail        *//*---------------------------- Implementation -----------------------------*//* These are not used under OS/2 */#define _EVT_disableInt()       1#define _EVT_restoreInt(flags)/****************************************************************************PARAMETERS:scanCode    - Scan code to testREMARKS:This macro determines if a specified key is currently down at thetime that the call is made.****************************************************************************/#define _EVT_isKeyDown(scanCode)    (keyUpMsg[scanCode] != 0)/****************************************************************************REMARKS:This function is used to return the number of ticks since systemstartup in milliseconds. This should be the same value that is placed intothe time stamp fields of events, and is used to implement auto mouse downevents.****************************************************************************/ulong _EVT_getTicks(void){    ULONG   count;    DosQuerySysInfo( QSV_MS_COUNT, QSV_MS_COUNT, &count, sizeof(ULONG) );    return count;}/****************************************************************************REMARKS:Converts a mickey movement value to a pixel adjustment value.****************************************************************************/static int MickeyToPixel(    int mickey){    /* TODO: We can add some code in here to handle 'acceleration' for */    /*       the mouse cursor. For now just use the mickeys. */    return mickey;}/* Some useful defines any typedefs used in the keyboard handling */#define KEY_RELEASE             0x40/****************************************************************************REMARKS:Pumps all messages in the message queue from OS/2 into our event queue.****************************************************************************/static void _EVT_pumpMessages(void){    KBDINFO         keyInfo;        /* Must not cross a 64K boundary */    KBDKEYINFO      key;            /* Must not cross a 64K boundary */    MOUQUEINFO      mqueue;         /* Must not cross a 64K boundary */    MOUEVENTINFO    mouse;          /* Must not cross a 64K boundary */    ushort          mWait;          /* Must not cross a 64K boundary */    KEYPACKET       kp;             /* Must not cross a 64K boundary */    event_t         evt;    int             scan;    ibool           noInput = TRUE; /* Flag to determine if any input was available */    /* First of all, check if we should do any session switch work */    __PM_checkConsoleSwitch();    /* Pump all keyboard messages from our circular buffer */    for (;;) {	/* Check that the monitor thread is still running */	if (!bMonRunning)	    PM_fatalError("Keyboard monitor thread died!");	/* Protect keypacket buffer with mutex */	DosRequestMutexSem(hmtxKeyBuf, SEM_INDEFINITE_WAIT);	if (kpHead == kpTail) {	    DosReleaseMutexSem(hmtxKeyBuf);	    break;	    }	noInput = FALSE;	/* Read packet from circular buffer and remove it */	memcpy(&kp, &keyMonPkts[kpTail], sizeof(KEYPACKET));	if (++kpTail == KEYBUFSIZE)	    kpTail = 0;	DosReleaseMutexSem(hmtxKeyBuf);	/* Compensate for the 0xE0 character */	if (kp.XlatedScan && kp.XlatedChar == 0xE0)	    kp.XlatedChar = 0;	/* Determine type of keyboard event */	memset(&evt,0,sizeof(evt));	if (kp.KbdDDFlagWord & KEY_RELEASE)	    evt.what = EVT_KEYUP;	else	    evt.what = EVT_KEYDOWN;	/* Convert keyboard codes */	scan = kp.MonFlagWord >> 8;	if (evt.what == EVT_KEYUP) {	    /* Get message for keyup code from table of cached down values */	    evt.message = keyUpMsg[scan];	    keyUpMsg[scan] = 0;	    oldKeyMessage = -1;	    }	else {	    evt.message = ((ulong)scan << 8) | kp.XlatedChar;	    if (evt.message == keyUpMsg[scan]) {		evt.what = EVT_KEYREPEAT;		evt.message |= 0x10000;		}	    oldKeyMessage = evt.message & 0x0FFFF;	    keyUpMsg[scan] = (ushort)evt.message;	    }	 /* Convert shift state modifiers */	 if (kp.u.ShiftState & 0x0001)	     evt.modifiers |= EVT_RIGHTSHIFT;	 if (kp.u.ShiftState & 0x0002)	     evt.modifiers |= EVT_LEFTSHIFT;	 if (kp.u.ShiftState & 0x0100)	     evt.modifiers |= EVT_LEFTCTRL;	 if (kp.u.ShiftState & 0x0200)	     evt.modifiers |= EVT_LEFTALT;	 if (kp.u.ShiftState & 0x0400)	     evt.modifiers |= EVT_RIGHTCTRL;	 if (kp.u.ShiftState & 0x0800)	     evt.modifiers |= EVT_RIGHTALT;	 EVT.oldMove = -1;	 /* Add time stamp and add the event to the queue */	 evt.when = key.time;	 if (EVT.count < EVENTQSIZE)	     addEvent(&evt);	 }    /* Don't just flush because that terminally confuses the monitor */    do {	KbdCharIn(&key, IO_NOWAIT, 0);	} while (key.fbStatus & KBDTRF_FINAL_CHAR_IN);    /* Pump all mouse messages */    KbdGetStatus(&keyInfo,0);    /* Check return code - mouse may not be operational!! */    if (MouGetNumQueEl(&mqueue,_EVT_hMouse) == NO_ERROR) {	while (mqueue.cEvents) {	    while (mqueue.cEvents--) {		memset(&evt,0,sizeof(evt));		mWait = MOU_NOWAIT;		MouReadEventQue(&mouse,&mWait,_EVT_hMouse);		/* Update the mouse position. We get the mouse coordinates		 * in mickeys so we have to translate these into pixels and		 * move our mouse position. If we don't do this, OS/2 gives		 * us the coordinates in character positions since it still		 * thinks we are in text mode!		 */		EVT.mx += MickeyToPixel(mouse.col);		EVT.my += MickeyToPixel(mouse.row);		if (EVT.mx < 0) EVT.mx = 0;		if (EVT.my < 0) EVT.my = 0;		if (EVT.mx > rangeX)    EVT.mx = rangeX;		if (EVT.my > rangeY)    EVT.my = rangeY;		evt.where_x = EVT.mx;		evt.where_y = EVT.my;		evt.relative_x = mouse.col;		evt.relative_y = mouse.row;		evt.when = key.time;		if (mouse.fs & (MOUSE_BN1_DOWN | MOUSE_MOTION_WITH_BN1_DOWN))		    evt.modifiers |= EVT_LEFTBUT;		if (mouse.fs & (MOUSE_BN2_DOWN | MOUSE_MOTION_WITH_BN2_DOWN))		    evt.modifiers |= EVT_RIGHTBUT;		if (mouse.fs & (MOUSE_BN3_DOWN | MOUSE_MOTION_WITH_BN3_DOWN))		    evt.modifiers |= EVT_MIDDLEBUT;		if (keyInfo.fsState & 0x0001)		    evt.modifiers |= EVT_RIGHTSHIFT;		if (keyInfo.fsState & 0x0002)		    evt.modifiers |= EVT_LEFTSHIFT;		if (keyInfo.fsState & 0x0100)		    evt.modifiers |= EVT_LEFTCTRL;		if (keyInfo.fsState & 0x0200)		    evt.modifiers |= EVT_LEFTALT;		if (keyInfo.fsState & 0x0400)		    evt.modifiers |= EVT_RIGHTCTRL;		if (keyInfo.fsState & 0x0800)		    evt.modifiers |= EVT_RIGHTALT;		/* Check for left mouse click events */		/* 0x06 == (MOUSE_BN1_DOWN | MOUSE_MOTION_WITH_BN1_DOWN) */		if (((mouse.fs & 0x0006) && !(oldMouseState & 0x0006))			|| (!(mouse.fs & 0x0006) && (oldMouseState & 0x0006))) {		    if (mouse.fs & 0x0006)			evt.what = EVT_MOUSEDOWN;		    else			evt.what = EVT_MOUSEUP;		    evt.message = EVT_LEFTBMASK;		    EVT.oldMove = -1;		    if (EVT.count < EVENTQSIZE)			addEvent(&evt);		    }		/* Check for right mouse click events */		/* 0x0018 == (MOUSE_BN2_DOWN | MOUSE_MOTION_WITH_BN2_DOWN) */		if (((mouse.fs & 0x0018) && !(oldMouseState & 0x0018))			|| (!(mouse.fs & 0x0018) && (oldMouseState & 0x0018))) {		    if (mouse.fs & 0x0018)			evt.what = EVT_MOUSEDOWN;		    else			evt.what = EVT_MOUSEUP;		    evt.message = EVT_RIGHTBMASK;		    EVT.oldMove = -1;		    if (EVT.count < EVENTQSIZE)			addEvent(&evt);		    }		/* Check for middle mouse click events */		/* 0x0060 == (MOUSE_BN3_DOWN | MOUSE_MOTION_WITH_BN3_DOWN) */		if (((mouse.fs & 0x0060) && !(oldMouseState & 0x0060))			|| (!(mouse.fs & 0x0060) && (oldMouseState & 0x0060))) {		    if (mouse.fs & 0x0060)			evt.what = EVT_MOUSEDOWN;		    else			evt.what = EVT_MOUSEUP;		    evt.message = EVT_MIDDLEBMASK;		    EVT.oldMove = -1;		    if (EVT.count < EVENTQSIZE)			addEvent(&evt);		    }		/* Check for mouse movement event */		if (mouse.fs & 0x002B) {		    evt.what = EVT_MOUSEMOVE;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -