event.c
来自「适合KS8695X」· C语言 代码 · 共 460 行 · 第 1/2 页
C
460 行
EVT_exit();
PM_fatalError("Unhandled exception!");
}
/****************************************************************************
PARAMETERS:
mouseMove - Callback function to call wheneve the mouse needs to be moved
REMARKS:
Initiliase the event handling module. Here we install our mouse handling ISR
to be called whenever any button's are pressed or released. We also build
the free list of events in the event queue.
We use handler number 2 of the mouse libraries interrupt handlers for our
event handling routines.
****************************************************************************/
void EVTAPI EVT_init(
_EVT_mouseMoveHandler mouseMove)
{
/* Initialise the event queue */
EVT.mouseMove = mouseMove;
initEventQueue();
memset(keyUpMsg,0,sizeof(keyUpMsg));
/* Catch program termination signals so we can clean up properly */
signal(SIGABRT, _EVT_abort);
signal(SIGFPE, _EVT_abort);
signal(SIGINT, _EVT_abort);
}
/****************************************************************************
REMARKS
Changes the range of coordinates returned by the mouse functions to the
specified range of values. This is used when changing between graphics
modes set the range of mouse coordinates for the new display mode.
****************************************************************************/
void EVTAPI EVT_setMouseRange(
int xRes,
int yRes)
{
rangeX = xRes;
rangeY = yRes;
}
/****************************************************************************
REMARKS
Modifes the mouse coordinates as necessary if scaling to OS coordinates,
and sets the OS mouse cursor position.
****************************************************************************/
void _EVT_setMousePos(
int *x,
int *y)
{
/* Scale coordinates up to desktop coordinates first */
int scaledX = (*x * _PM_deskX) / rangeX;
int scaledY = (*y * _PM_deskY) / rangeY;
/* Scale coordinates back to screen coordinates again */
*x = (scaledX * rangeX) / _PM_deskX;
*y = (scaledY * rangeY) / _PM_deskY;
SetCursorPos(scaledX,scaledY);
}
/****************************************************************************
REMARKS:
Initiailises the internal event handling modules. The EVT_suspend function
can be called to suspend event handling (such as when shelling out to DOS),
and this function can be used to resume it again later.
****************************************************************************/
void EVT_resume(void)
{
/* Do nothing for Win32 */
}
/****************************************************************************
REMARKS
Suspends all of our event handling operations. This is also used to
de-install the event handling code.
****************************************************************************/
void EVT_suspend(void)
{
/* Do nothing for Win32 */
}
/****************************************************************************
REMARKS
Exits the event module for program terminatation.
****************************************************************************/
void EVT_exit(void)
{
/* Restore signal handlers */
signal(SIGABRT, SIG_DFL);
signal(SIGFPE, SIG_DFL);
signal(SIGINT, SIG_DFL);
}
/****************************************************************************
DESCRIPTION:
Returns the mask indicating what joystick axes are attached.
HEADER:
event.h
REMARKS:
This function is used to detect the attached joysticks, and determine
what axes are present and functioning. This function will re-detect any
attached joysticks when it is called, so if the user forgot to attach
the joystick when the application started, you can call this function to
re-detect any newly attached joysticks.
SEE ALSO:
EVT_joySetLowerRight, EVT_joySetCenter, EVT_joyIsPresent
****************************************************************************/
int EVTAPI EVT_joyIsPresent(void)
{
/* TODO: Implement joystick code based on DirectX! */
return 0;
}
/****************************************************************************
DESCRIPTION:
Polls the joystick for position and button information.
HEADER:
event.h
REMARKS:
This routine is used to poll analogue joysticks for button and position
information. It should be called once for each main loop of the user
application, just before processing all pending events via EVT_getNext.
All information polled from the joystick will be posted to the event
queue for later retrieval.
Note: Most analogue joysticks will provide readings that change even
though the joystick has not moved. Hence if you call this routine
you will likely get an EVT_JOYMOVE event every time through your
event loop.
SEE ALSO:
EVT_getNext, EVT_peekNext, EVT_joySetUpperLeft, EVT_joySetLowerRight,
EVT_joySetCenter, EVT_joyIsPresent
****************************************************************************/
void EVTAPI EVT_pollJoystick(void)
{
}
/****************************************************************************
DESCRIPTION:
Calibrates the joystick upper left position
HEADER:
event.h
REMARKS:
This function can be used to zero in on better joystick calibration factors,
which may work better than the default simplistic calibration (which assumes
the joystick is centered when the event library is initialised).
To use this function, ask the user to hold the stick in the upper left
position and then have them press a key or button. and then call this
function. This function will then read the joystick and update the
calibration factors.
Usually, assuming that the stick was centered when the event library was
initialized, you really only need to call EVT_joySetLowerRight since the
upper left position is usually always 0,0 on most joysticks. However, the
safest procedure is to call all three calibration functions.
SEE ALSO:
EVT_joySetUpperLeft, EVT_joySetLowerRight, EVT_joyIsPresent
****************************************************************************/
void EVTAPI EVT_joySetUpperLeft(void)
{
}
/****************************************************************************
DESCRIPTION:
Calibrates the joystick lower right position
HEADER:
event.h
REMARKS:
This function can be used to zero in on better joystick calibration factors,
which may work better than the default simplistic calibration (which assumes
the joystick is centered when the event library is initialised).
To use this function, ask the user to hold the stick in the lower right
position and then have them press a key or button. and then call this
function. This function will then read the joystick and update the
calibration factors.
Usually, assuming that the stick was centered when the event library was
initialized, you really only need to call EVT_joySetLowerRight since the
upper left position is usually always 0,0 on most joysticks. However, the
safest procedure is to call all three calibration functions.
SEE ALSO:
EVT_joySetUpperLeft, EVT_joySetCenter, EVT_joyIsPresent
****************************************************************************/
void EVTAPI EVT_joySetLowerRight(void)
{
}
/****************************************************************************
DESCRIPTION:
Calibrates the joystick center position
HEADER:
event.h
REMARKS:
This function can be used to zero in on better joystick calibration factors,
which may work better than the default simplistic calibration (which assumes
the joystick is centered when the event library is initialised).
To use this function, ask the user to hold the stick in the center
position and then have them press a key or button. and then call this
function. This function will then read the joystick and update the
calibration factors.
Usually, assuming that the stick was centered when the event library was
initialized, you really only need to call EVT_joySetLowerRight since the
upper left position is usually always 0,0 on most joysticks. However, the
safest procedure is to call all three calibration functions.
SEE ALSO:
EVT_joySetUpperLeft, EVT_joySetLowerRight, EVT_joySetCenter
****************************************************************************/
void EVTAPI EVT_joySetCenter(void)
{
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?