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

📄 event.c

📁 gumstiz u-boot loader in linux
💻 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:  32-bit DOS** Description:  32-bit DOS implementation for the SciTech cross platform*               event library.*****************************************************************************//*--------------------------- Global variables ----------------------------*/ibool _VARAPI   _EVT_useEvents = true;  /* True to use event handling   */ibool _VARAPI   _EVT_installed = 0;     /* Event handers installed?     */uchar _VARAPI   *_EVT_biosPtr = NULL;   /* Pointer to the BIOS data area */static ibool    haveMouse = false;      /* True if we have a mouse      *//*---------------------------- Implementation -----------------------------*//* External assembler functions */void    EVTAPI _EVT_pollJoystick(void);uint    EVTAPI _EVT_disableInt(void);uint    EVTAPI _EVT_restoreInt(uint flags);void    EVTAPI _EVT_codeStart(void);void    EVTAPI _EVT_codeEnd(void);void    EVTAPI _EVT_cCodeStart(void);void    EVTAPI _EVT_cCodeEnd(void);int     EVTAPI _EVT_getKeyCode(void);void    EVTAPI _EVT_pumpMessages(void);int     EVTAPI EVT_rdinx(int port,int index);void    EVTAPI EVT_wrinx(int port,int index,int value);#ifdef NO_KEYBOARD_INTERRUPT/****************************************************************************REMARKS:This function is used to pump all keyboard messages from the BIOS keyboardhandler into our event queue. This can be used to avoid using theinstallable keyboard handler if this is causing problems.****************************************************************************/static void EVTAPI _EVT_pumpMessages(void){    RMREGS  regs;	uint    key,ps;	/* Since the keyboard ISR has not been installed if NO_IDE_BUG has	 * been defined, we first check for any pending keyboard events	 * here, and if there are some insert them into the event queue to	 * be picked up later - what a kludge.	 */	while ((key = _EVT_getKeyCode()) != 0) {		ps = _EVT_disableInt();		addKeyEvent(EVT_KEYDOWN, key);		_EVT_restoreInt(ps);		}    regs.x.ax = 0x0B;           /* Reset Move Mouse */    PM_int86(0x33,&regs,&regs);}#endif/****************************************************************************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){    return (ulong)PM_getLong(_EVT_biosPtr+0x6C) * 55UL;}/****************************************************************************REMARKS:Reboots the machine from DOS (warm boot)****************************************************************************/static void Reboot(void){    PMREGS  regs;    PMSREGS sregs;    ushort *rebootType = PM_mapRealPointer(0x40,0x72);    *rebootType = 0x1234;    PM_callRealMode(0xFFFF,0x0000,&regs,&sregs);}/****************************************************************************REMARKS:Include generic raw scancode keyboard module.****************************************************************************/#define SUPPORT_CTRL_ALT_DEL#include "common/keyboard.c"/****************************************************************************REMARKS:This function fools the DOS mouse driver into thinking that it is runningin graphics mode, rather than text mode so we always get virtual coordinatescorrectly rather than character coordinates.****************************************************************************/int _EVT_foolMouse(void){    int oldmode = PM_getByte(_EVT_biosPtr+0x49);    PM_setByte(_EVT_biosPtr+0x49,0x10);    oldmode |= (EVT_rdinx(0x3C4,0x2) << 8);    return oldmode;}/****************************************************************************REMARKS:This function unfools the DOS mouse driver after we have finished calling it.****************************************************************************/void _EVT_unfoolMouse(    int oldmode){    PM_setByte(_EVT_biosPtr+0x49,oldmode);    /* Some mouse drivers reset the plane mask register for VGA plane 4     * modes, which screws up the display on some VGA compatible controllers     * in SuperVGA modes. We reset the value back again in here to solve     * the problem.     */    EVT_wrinx(0x3C4,0x2,oldmode >> 8);}/****************************************************************************REMARKS:Determines if we have a mouse attached and functioning.****************************************************************************/static ibool detectMouse(void){    RMREGS  regs;    RMSREGS sregs;    uchar   *p;    ibool   retval;    regs.x.ax = 0x3533;                 /* Get interrupt vector 0x33    */    PM_int86x(0x21,&regs,&regs,&sregs);    /* Check that interrupt vector 0x33 is not a zero, and that the first     * instruction in the interrupt vector is not an IRET instruction     */    p = PM_mapRealPointer(sregs.es, regs.x.bx);    retval = ((sregs.es != 0) || (regs.x.bx != 0)) && (PM_getByte(p) != 207);    return retval;}/****************************************************************************PARAMETERS:what        - Event codemessage     - Event messagex,y         - Mouse position at time of eventbut_stat    - Mouse button status at time of eventREMARKS:Adds a new mouse event to the event queue. This routine is called from withinthe mouse interrupt subroutine, so it must be efficient.NOTE:   Interrupts MUST be OFF while this routine is called to ensure we have	mutually exclusive access to our internal data structures for	interrupt driven systems (like under DOS).****************************************************************************/static void addMouseEvent(    uint what,    uint message,    int x,    int y,    int mickeyX,    int mickeyY,    uint but_stat){    event_t evt;    if (EVT.count < EVENTQSIZE) {	/* Save information in event record. */	evt.when = _EVT_getTicks();	evt.what = what;	evt.message = message;	evt.modifiers = but_stat;	evt.where_x = x;                /* Save mouse event position    */	evt.where_y = y;	evt.relative_x = mickeyX;	evt.relative_y = mickeyY;	evt.modifiers |= EVT.keyModifiers;	addEvent(&evt);                 /* Add to tail of event queue   */	}}/****************************************************************************PARAMETERS:mask        - Event maskbutstate    - Button statex           - Mouse x coordinatey           - Mouse y coordinateREMARKS:Mouse event handling routine. This gets called when a mouse event occurs,and we call the addMouseEvent() routine to add the appropriate mouse eventto 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){    uint    ps;    uint    buttonMask;    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;

⌨️ 快捷键说明

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