1 /****************************************************************************
3 * SciTech OS Portability Manager Library
5 * ========================================================================
7 * The contents of this file are subject to the SciTech MGL Public
8 * License Version 1.0 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of
10 * the License at http://www.scitechsoft.com/mgl-license.txt
12 * Software distributed under the License is distributed on an
13 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * rights and limitations under the License.
17 * The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
19 * The Initial Developer of the Original Code is SciTech Software, Inc.
20 * All Rights Reserved.
22 * ========================================================================
27 * Description: Main implementation for the SciTech cross platform event
28 * library. This module contains all the generic cross platform
29 * code, and pulls in modules specific to each target OS
32 ****************************************************************************/
43 /*--------------------------- Global variables ----------------------------*/
45 #define EVENTQSIZE 100 /* Number of events in event queue */
46 #define JOY_NUM_AXES 4 /* Number of joystick axes supported */
49 int mx,my; /* Current mouse position */
50 int head; /* Head of event queue */
51 int tail; /* Tail of event queue */
52 int freeHead; /* Head of free list */
53 int count; /* No. of items currently in queue */
54 event_t evtq[EVENTQSIZE]; /* The queue structure itself */
55 int oldMove; /* Previous movement event */
56 int oldKey; /* Previous key repeat event */
57 int oldJoyMove; /* Previous joystick movement event */
58 int joyMask; /* Mask of joystick axes present */
59 int joyMin[JOY_NUM_AXES];
60 int joyCenter[JOY_NUM_AXES];
61 int joyMax[JOY_NUM_AXES];
62 int joyPrev[JOY_NUM_AXES];
68 ulong doubleClickThresh;
73 ulong keyModifiers; /* Current keyboard modifiers */
74 uchar keyTable[128]; /* Table of key up/down flags */
75 ibool allowLEDS; /* True if LEDS should change */
76 _EVT_userEventFilter userEventCallback;
77 _EVT_mouseMoveHandler mouseMove;
78 _EVT_heartBeatCallback heartBeat;
79 void *heartBeatParams;
83 /*---------------------------- Implementation -----------------------------*/
85 #if defined(__REALDOS__) || defined(__SMX32__)
87 void EVTAPI _EVT_cCodeStart(void) {}
90 /* External assembler functions */
92 int EVTAPI _EVT_readJoyAxis(int mask,int *axis);
93 int EVTAPI _EVT_readJoyButtons(void);
95 /* Forward declaration */
97 ulong _EVT_getTicks(void);
99 /****************************************************************************
101 evt - Event to add to the event queue
104 Adds an event to the event queue by tacking it onto the tail of the event
105 queue. This routine assumes that at least one spot is available on the
106 freeList for the event to be inserted.
108 NOTE: Interrupts MUST be OFF while this routine is called to ensure we have
109 mutually exclusive access to our internal data structures for
110 interrupt driven systems (like under DOS).
111 ****************************************************************************/
112 static void addEvent(
117 /* Check for mouse double click events */
118 if (evt->what & EVT_MOUSEEVT) {
119 EVT.autoMouse_x = evt->where_x;
120 EVT.autoMouse_y = evt->where_y;
121 if ((evt->what & EVT_MOUSEDOWN) && !(evt->message & EVT_DBLCLICK)) {
122 /* Determine if the last mouse event was a double click event */
123 uint diff_x = ABS(evt->where_x - EVT.downMouse.where_x);
124 uint diff_y = ABS(evt->where_y - EVT.downMouse.where_y);
125 if ((evt->message == EVT.downMouse.message)
126 && ((evt->when - EVT.downMouse.when) <= EVT.doubleClick)
127 && (diff_x <= EVT.doubleClickThresh)
128 && (diff_y <= EVT.doubleClickThresh)) {
129 evt->message |= EVT_DBLCLICK;
130 EVT.downMouse = *evt;
131 EVT.downMouse.when = 0;
134 EVT.downMouse = *evt;
135 EVT.autoTicks = _EVT_getTicks();
137 else if (evt->what & EVT_MOUSEUP) {
138 EVT.downMouse.what = EVT_NULLEVT;
139 EVT.firstAuto = true;
143 /* Call user supplied callback to modify the event if desired */
144 if (EVT.userEventCallback) {
145 if (!EVT.userEventCallback(evt))
149 /* Get spot to place the event from the free list */
150 evtID = EVT.freeHead;
151 EVT.freeHead = EVT.evtq[EVT.freeHead].next;
153 /* Add to the EVT.tail of the event queue */
155 evt->prev = EVT.tail;
157 EVT.evtq[EVT.tail].next = evtID;
161 EVT.evtq[evtID] = *evt;
165 /****************************************************************************
167 Internal function to initialise the event queue to the empty state.
168 ****************************************************************************/
169 static void initEventQueue(void)
173 /* Build free list, and initialize global data structures */
174 for (i = 0; i < EVENTQSIZE; i++)
175 EVT.evtq[i].next = i+1;
176 EVT.evtq[EVENTQSIZE-1].next = -1; /* Terminate list */
177 EVT.count = EVT.freeHead = 0;
178 EVT.head = EVT.tail = -1;
184 EVT.keyModifiers = 0;
185 EVT.allowLEDS = true;
187 /* Set default values for mouse double click and mouse auto events */
188 EVT.doubleClick = 440;
192 EVT.doubleClickThresh = 5;
193 EVT.firstAuto = true;
194 EVT.autoMouse_x = EVT.autoMouse_y = 0;
195 memset(&EVT.downMouse,0,sizeof(EVT.downMouse));
197 /* Setup default pointers for event library */
198 EVT.userEventCallback = NULL;
199 EVT.codePage = &_CP_US_English;
201 /* Initialise the joystick module and do basic calibration (which assumes
202 * the joystick is centered.
204 EVT.joyMask = EVT_joyIsPresent();
207 #if defined(NEED_SCALE_JOY_AXIS) || !defined(USE_OS_JOYSTICK)
208 /****************************************************************************
210 This function scales a joystick axis value to normalised form.
211 ****************************************************************************/
212 static int scaleJoyAxis(
218 /* Make sure the joystick is calibrated properly */
219 if (EVT.joyCenter[axis] - EVT.joyMin[axis] < 5)
221 if (EVT.joyMax[axis] - EVT.joyCenter[axis] < 5)
224 /* Now scale the coordinates to -128 to 127 */
225 raw -= EVT.joyCenter[axis];
227 range = EVT.joyCenter[axis]-EVT.joyMin[axis];
229 range = EVT.joyMax[axis]-EVT.joyCenter[axis];
230 scaled = (raw * 128) / range;
239 #if defined(__SMX32__)
240 #include "smx/event.c"
241 #elif defined(__RTTARGET__)
242 #include "rttarget/event.c"
243 #elif defined(__REALDOS__)
244 #include "dos/event.c"
245 #elif defined(__WINDOWS32__)
246 #include "win32/event.c"
247 #elif defined(__OS2__)
248 #if defined(__OS2_PM__)
249 #include "os2pm/event.c"
251 #include "os2/event.c"
253 #elif defined(__LINUX__)
254 #if defined(__USE_X11__)
255 #include "x11/event.c"
257 #include "linux/event.c"
259 #elif defined(__QNX__)
260 #if defined(__USE_PHOTON__)
261 #include "photon/event.c"
262 #elif defined(__USE_X11__)
263 #include "x11/event.c"
265 #include "qnx/event.c"
267 #elif defined(__BEOS__)
268 #include "beos/event.c"
270 #error Event library not ported to this platform yet!
273 /*------------------------ Public interface routines ----------------------*/
275 /* If USE_OS_JOYSTICK is defined, the OS specific libraries will implement
276 * the joystick code rather than using the generic OS portable version.
279 #ifndef USE_OS_JOYSTICK
280 /****************************************************************************
282 Returns the mask indicating what joystick axes are attached.
288 This function is used to detect the attached joysticks, and determine
289 what axes are present and functioning. This function will re-detect any
290 attached joysticks when it is called, so if the user forgot to attach
291 the joystick when the application started, you can call this function to
292 re-detect any newly attached joysticks.
295 EVT_joySetLowerRight, EVT_joySetCenter, EVT_joyIsPresent
296 ****************************************************************************/
297 int EVTAPI EVT_joyIsPresent(void)
301 memset(EVT.joyMin,0,sizeof(EVT.joyMin));
302 memset(EVT.joyCenter,0,sizeof(EVT.joyCenter));
303 memset(EVT.joyMax,0,sizeof(EVT.joyMax));
304 memset(EVT.joyPrev,0,sizeof(EVT.joyPrev));
309 mask = _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyCenter);
311 for (i = 0; i < JOY_NUM_AXES; i++)
312 EVT.joyMax[i] = EVT.joyCenter[i]*2;
317 /****************************************************************************
319 Polls the joystick for position and button information.
325 This routine is used to poll analogue joysticks for button and position
326 information. It should be called once for each main loop of the user
327 application, just before processing all pending events via EVT_getNext.
328 All information polled from the joystick will be posted to the event
329 queue for later retrieval.
331 Note: Most analogue joysticks will provide readings that change even
332 though the joystick has not moved. Hence if you call this routine
333 you will likely get an EVT_JOYMOVE event every time through your
337 EVT_getNext, EVT_peekNext, EVT_joySetUpperLeft, EVT_joySetLowerRight,
338 EVT_joySetCenter, EVT_joyIsPresent
339 ****************************************************************************/
340 void EVTAPI EVT_pollJoystick(void)
343 int i,axis[JOY_NUM_AXES],newButState,mask,moved,ps;
346 /* Read joystick axes and post movement events if they have
347 * changed since the last time we polled. Until the events are
348 * actually flushed, we keep modifying the same joystick movement
349 * event, so you won't get multiple movement event
351 mask = _EVT_readJoyAxis(EVT.joyMask,axis);
352 newButState = _EVT_readJoyButtons();
354 for (i = 0; i < JOY_NUM_AXES; i++) {
355 if (mask & (EVT_JOY_AXIS_X1 << i))
356 axis[i] = scaleJoyAxis(axis[i],i);
358 axis[i] = EVT.joyPrev[i];
359 if (axis[i] != EVT.joyPrev[i])
363 memcpy(EVT.joyPrev,axis,sizeof(EVT.joyPrev));
364 ps = _EVT_disableInt();
365 if (EVT.oldJoyMove != -1) {
366 /* Modify the existing joystick movement event */
367 EVT.evtq[EVT.oldJoyMove].message = newButState;
368 EVT.evtq[EVT.oldJoyMove].where_x = EVT.joyPrev[0];
369 EVT.evtq[EVT.oldJoyMove].where_y = EVT.joyPrev[1];
370 EVT.evtq[EVT.oldJoyMove].relative_x = EVT.joyPrev[2];
371 EVT.evtq[EVT.oldJoyMove].relative_y = EVT.joyPrev[3];
373 else if (EVT.count < EVENTQSIZE) {
374 /* Add a new joystick movement event */
375 EVT.oldJoyMove = EVT.freeHead;
376 memset(&evt,0,sizeof(evt));
377 evt.what = EVT_JOYMOVE;
378 evt.message = EVT.joyButState;
379 evt.where_x = EVT.joyPrev[0];
380 evt.where_y = EVT.joyPrev[1];
381 evt.relative_x = EVT.joyPrev[2];
382 evt.relative_y = EVT.joyPrev[3];
388 /* Read the joystick buttons, and post events to reflect the change
389 * in state for the joystick buttons.
391 if (newButState != EVT.joyButState) {
392 if (EVT.count < EVENTQSIZE) {
393 /* Add a new joystick click event */
394 ps = _EVT_disableInt();
395 memset(&evt,0,sizeof(evt));
396 evt.what = EVT_JOYCLICK;
397 evt.message = newButState;
398 EVT.evtq[EVT.oldJoyMove].where_x = EVT.joyPrev[0];
399 EVT.evtq[EVT.oldJoyMove].where_y = EVT.joyPrev[1];
400 EVT.evtq[EVT.oldJoyMove].relative_x = EVT.joyPrev[2];
401 EVT.evtq[EVT.oldJoyMove].relative_y = EVT.joyPrev[3];
405 EVT.joyButState = newButState;
410 /****************************************************************************
412 Calibrates the joystick upper left position
418 This function can be used to zero in on better joystick calibration factors,
419 which may work better than the default simplistic calibration (which assumes
420 the joystick is centered when the event library is initialised).
421 To use this function, ask the user to hold the stick in the upper left
422 position and then have them press a key or button. and then call this
423 function. This function will then read the joystick and update the
426 Usually, assuming that the stick was centered when the event library was
427 initialized, you really only need to call EVT_joySetLowerRight since the
428 upper left position is usually always 0,0 on most joysticks. However, the
429 safest procedure is to call all three calibration functions.
432 EVT_joySetUpperLeft, EVT_joySetLowerRight, EVT_joyIsPresent
433 ****************************************************************************/
434 void EVTAPI EVT_joySetUpperLeft(void)
436 _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyMin);
439 /****************************************************************************
441 Calibrates the joystick lower right position
447 This function can be used to zero in on better joystick calibration factors,
448 which may work better than the default simplistic calibration (which assumes
449 the joystick is centered when the event library is initialised).
450 To use this function, ask the user to hold the stick in the lower right
451 position and then have them press a key or button. and then call this
452 function. This function will then read the joystick and update the
455 Usually, assuming that the stick was centered when the event library was
456 initialized, you really only need to call EVT_joySetLowerRight since the
457 upper left position is usually always 0,0 on most joysticks. However, the
458 safest procedure is to call all three calibration functions.
461 EVT_joySetUpperLeft, EVT_joySetCenter, EVT_joyIsPresent
462 ****************************************************************************/
463 void EVTAPI EVT_joySetLowerRight(void)
465 _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyMax);
468 /****************************************************************************
470 Calibrates the joystick center position
476 This function can be used to zero in on better joystick calibration factors,
477 which may work better than the default simplistic calibration (which assumes
478 the joystick is centered when the event library is initialised).
479 To use this function, ask the user to hold the stick in the center
480 position and then have them press a key or button. and then call this
481 function. This function will then read the joystick and update the
484 Usually, assuming that the stick was centered when the event library was
485 initialized, you really only need to call EVT_joySetLowerRight since the
486 upper left position is usually always 0,0 on most joysticks. However, the
487 safest procedure is to call all three calibration functions.
490 EVT_joySetUpperLeft, EVT_joySetLowerRight, EVT_joySetCenter
491 ****************************************************************************/
492 void EVTAPI EVT_joySetCenter(void)
494 _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyCenter);
498 /****************************************************************************
500 Posts a user defined event to the event queue
506 True if event was posted, false if event queue is full.
509 what - Type code for message to post
510 message - Event specific message to post
511 modifiers - Event specific modifier flags to post
514 This routine is used to post user defined events to the event queue.
517 EVT_flush, EVT_getNext, EVT_peekNext, EVT_halt
518 ****************************************************************************/
519 ibool EVTAPI EVT_post(
528 if (EVT.count < EVENTQSIZE) {
529 /* Save information in event record */
530 ps = _EVT_disableInt();
532 evt.when = _EVT_getTicks();
534 evt.message = message;
535 evt.modifiers = modifiers;
536 addEvent(&evt); /* Add to EVT.tail of event queue */
544 /****************************************************************************
546 Flushes all events of a specified type from the event queue.
549 mask - Mask specifying the types of events that should be removed
555 Flushes (removes) all pending events of the specified type from the event
556 queue. You may combine the masks for different event types with a simple
560 EVT_getNext, EVT_halt, EVT_peekNext
561 ****************************************************************************/
562 void EVTAPI EVT_flush(
567 do { /* Flush all events */
568 EVT_getNext(&evt,mask);
569 } while (evt.what != EVT_NULLEVT);
572 /****************************************************************************
574 Halts until and event of the specified type is recieved.
581 mask - Mask specifying the types of events that should be removed
584 This functions halts exceution until an event of the specified type is
585 recieved into the event queue. It does not flush the event queue of events
586 before performing the busy loop. However this function does throw away
587 any events other than the ones you have requested via the event mask, to
588 avoid the event queue filling up with unwanted events (like EVT_KEYUP or
589 EVT_MOUSEMOVE events).
592 EVT_getNext, EVT_flush, EVT_peekNext
593 ****************************************************************************/
594 void EVTAPI EVT_halt(
598 do { /* Wait for an event */
599 if (mask & (EVT_JOYEVT))
601 EVT_getNext(evt,EVT_EVERYEVT);
602 } while (!(evt->what & mask));
605 /****************************************************************************
607 Peeks at the next pending event in the event queue.
613 True if an event is pending, false if not.
616 evt - Pointer to structure to return the event info in
617 mask - Mask specifying the types of events that should be removed
620 Peeks at the next pending event of the specified type in the event queue. The
621 mask parameter is used to specify the type of events to be peeked at, and
622 can be any logical combination of any of the flags defined by the
623 EVT_eventType enumeration.
625 In contrast to EVT_getNext, the event is not removed from the event queue.
626 You may combine the masks for different event types with a simple logical OR.
629 EVT_flush, EVT_getNext, EVT_halt
630 ****************************************************************************/
631 ibool EVTAPI EVT_peekNext(
639 EVT.heartBeat(EVT.heartBeatParams);
640 _EVT_pumpMessages(); /* Pump all messages into queue */
641 EVT.mouseMove(EVT.mx,EVT.my); /* Move the mouse cursor */
642 evt->what = EVT_NULLEVT; /* Default to null event */
644 /* It is possible that an event be posted while we are trying
645 * to access the event queue. This would create problems since
646 * we may end up with invalid data for our event queue pointers. To
647 * alleviate this, all interrupts are suspended while we manipulate
650 ps = _EVT_disableInt(); /* disable interrupts */
651 for (evtID = EVT.head; evtID != -1; evtID = EVT.evtq[evtID].next) {
652 if (EVT.evtq[evtID].what & mask)
653 break; /* Found an event */
657 return false; /* Event was not found */
659 *evt = EVT.evtq[evtID]; /* Return the event */
661 if (evt->what & EVT_KEYEVT)
662 _EVT_maskKeyCode(evt);
664 return evt->what != EVT_NULLEVT;
667 /****************************************************************************
669 Retrieves the next pending event from the event queue.
672 evt - Pointer to structure to return the event info in
673 mask - Mask specifying the types of events that should be removed
679 True if an event was pending, false if not.
682 Retrieves the next pending event from the event queue, and stores it in a
683 event_t structure. The mask parameter is used to specify the type of events
684 to be removed, and can be any logical combination of any of the flags defined
685 by the EVT_eventType enumeration.
687 The what field of the event contains the event code of the event that was
688 extracted. All application specific events should begin with the EVT_USEREVT
689 code and build from there. Since the event code is stored in an integer,
690 there is a maximum of 32 different event codes that can be distinguished.
691 You can store extra information about the event in the message field to
692 distinguish between events of the same class (for instance the button used in
693 a EVT_MOUSEDOWN event).
695 If an event of the specified type was not in the event queue, the what field
696 of the event will be set to NULLEVT, and the return value will return false.
698 Note: You should /always/ use the EVT_EVERYEVT mask for extracting events
699 from your main event loop handler. Using a mask for only a specific
700 type of event for long periods of time will cause the event queue to
701 fill up with events of the type you are ignoring, eventually causing
702 the application to hang when the event queue becomes full.
705 EVT_flush, EVT_halt, EVT_peekNext
706 ****************************************************************************/
707 ibool EVTAPI EVT_getNext(
715 EVT.heartBeat(EVT.heartBeatParams);
716 _EVT_pumpMessages(); /* Pump all messages into queue */
717 EVT.mouseMove(EVT.mx,EVT.my); /* Move the mouse cursor */
718 evt->what = EVT_NULLEVT; /* Default to null event */
720 /* It is possible that an event be posted while we are trying
721 * to access the event queue. This would create problems since
722 * we may end up with invalid data for our event queue pointers. To
723 * alleviate this, all interrupts are suspended while we manipulate
726 ps = _EVT_disableInt(); /* disable interrupts */
727 for (evtID = EVT.head; evtID != -1; evtID = EVT.evtq[evtID].next) {
728 if (EVT.evtq[evtID].what & mask)
729 break; /* Found an event */
733 return false; /* Event was not found */
735 next = EVT.evtq[evtID].next;
736 prev = EVT.evtq[evtID].prev;
738 EVT.evtq[prev].next = next;
742 EVT.evtq[next].prev = prev;
745 *evt = EVT.evtq[evtID]; /* Return the event */
746 EVT.evtq[evtID].next = EVT.freeHead; /* and return to free list */
747 EVT.freeHead = evtID;
749 if (evt->what == EVT_MOUSEMOVE)
751 if (evt->what == EVT_KEYREPEAT)
753 if (evt->what == EVT_JOYMOVE)
755 _EVT_restoreInt(ps); /* enable interrupts */
756 if (evt->what & EVT_KEYEVT)
757 _EVT_maskKeyCode(evt);
760 /* If there is no event pending, check if we should generate an auto
761 * mouse down event if the mouse is still currently down.
763 if (evt->what == EVT_NULLEVT && EVT.autoRepeat && (mask & EVT_MOUSEAUTO) && (EVT.downMouse.what & EVT_MOUSEDOWN)) {
764 ulong ticks = _EVT_getTicks();
765 if ((ticks - EVT.autoTicks) >= (EVT.autoRepeat + (EVT.firstAuto ? EVT.autoDelay : 0))) {
766 evt->what = EVT_MOUSEAUTO;
767 evt->message = EVT.downMouse.message;
768 evt->modifiers = EVT.downMouse.modifiers;
769 evt->where_x = EVT.autoMouse_x;
770 evt->where_y = EVT.autoMouse_y;
773 EVT.autoTicks = evt->when = ticks;
774 EVT.firstAuto = false;
777 return evt->what != EVT_NULLEVT;
780 /****************************************************************************
782 Installs a user supplied event filter callback for event handling.
788 userEventFilter - Address of user supplied event filter callback
791 This function allows the application programmer to install an event filter
792 callback for event handling. Once you install your callback, the MGL
793 event handling routines will call your callback with a pointer to the
794 new event that will be placed into the event queue. Your callback can the
795 modify the contents of the event before it is placed into the queue (for
796 instance adding custom information or perhaps high precision timing
799 If your callback returns FALSE, the event will be ignore and will not be
800 posted to the event queue. You should always return true from your event
801 callback unless you plan to use the events immediately that they are
804 Note: Your event callback may be called in response to a hardware
805 interrupt and will be executing in the context of the hardware
806 interrupt handler under MSDOS (ie: keyboard interrupt or mouse
807 interrupt). For this reason the code pages for the callback that
808 you register must be locked in memory with the PM_lockCodePages
809 function. You must also lock down any data pages that your function
810 needs to reference as well.
812 Note: You can also use this filter callback to process events at the
813 time they are activated by the user (ie: when the user hits the
814 key or moves the mouse), but make sure your code runs as fast as
815 possible as it will be executing inside the context of an interrupt
816 handler on some systems.
819 EVT_getNext, EVT_peekNext
820 ****************************************************************************/
821 void EVTAPI EVT_setUserEventFilter(
822 _EVT_userEventFilter filter)
824 EVT.userEventCallback = filter;
827 /****************************************************************************
829 Installs a user supplied event heartbeat callback function.
835 callback - Address of user supplied event heartbeat callback
836 params - Parameters to pass to the event heartbeat function
839 This function allows the application programmer to install an event heatbeat
840 function that gets called every time that EVT_getNext or EVT_peekNext
841 is called. This is primarily useful for simulating text mode cursors inside
842 event handling code when running in graphics modes as opposed to hardware
846 EVT_getNext, EVT_peekNext, EVT_getHeartBeatCallback
847 ****************************************************************************/
848 void EVTAPI EVT_setHeartBeatCallback(
849 _EVT_heartBeatCallback callback,
852 EVT.heartBeat = callback;
853 EVT.heartBeatParams = params;
857 /****************************************************************************
859 Returns the current user supplied event heartbeat callback function.
865 callback - Place to store the address of user supplied event heartbeat callback
866 params - Place to store the parameters to pass to the event heartbeat function
869 This function retrieves the current event heatbeat function that gets called
870 every time that EVT_getNext or EVT_peekNext is called.
873 EVT_getNext, EVT_peekNext, EVT_setHeartBeatCallback
874 ****************************************************************************/
875 void EVTAPI EVT_getHeartBeatCallback(
876 _EVT_heartBeatCallback *callback,
879 *callback = EVT.heartBeat;
880 *params = EVT.heartBeatParams;
883 /****************************************************************************
885 Determines if a specified key is currently down.
888 scanCode - Scan code to test
891 True of the specified key is currently held down.
897 This function determines if a specified key is currently down at the
898 time that the call is made. You simply need to pass in the scan code of
899 the key that you wish to test, and the MGL will tell you if it is currently
900 down or not. The MGL does this by keeping track of the up and down state
902 ****************************************************************************/
903 ibool EVTAPI EVT_isKeyDown(
906 return _EVT_isKeyDown(scanCode);
909 /****************************************************************************
911 Set the mouse position for the event module
914 x - X coordinate to move the mouse cursor position to
915 y - Y coordinate to move the mouse cursor position to
921 This function moves the mouse cursor position for the event module to the
926 ****************************************************************************/
927 void EVTAPI EVT_setMousePos(
933 _EVT_setMousePos(&EVT.mx,&EVT.my);
934 EVT.mouseMove(EVT.mx,EVT.my);
937 /****************************************************************************
939 Returns the current mouse cursor location.
945 x - Place to store value for mouse x coordinate (screen coordinates)
946 y - Place to store value for mouse y coordinate (screen coordinates)
949 Obtains the current mouse cursor position in screen coordinates. Normally the
950 mouse cursor location is tracked using the mouse movement events that are
951 posted to the event queue when the mouse moves, however this routine
952 provides an alternative method of polling the mouse cursor location.
956 ****************************************************************************/
957 void EVTAPI EVT_getMousePos(
965 /****************************************************************************
967 Returns the currently active code page for translation of keyboard characters.
973 Pointer to the currently active code page translation table.
976 This function is returns a pointer to the currently active code page
977 translation table. See EVT_setCodePage for more information.
981 ****************************************************************************/
982 codepage_t * EVTAPI EVT_getCodePage(void)
987 /****************************************************************************
989 Sets the currently active code page for translation of keyboard characters.
995 page - New code page to make active
998 This function is used to set a new code page translation table that is used
999 to translate virtual scan code values to ASCII characters for different
1000 keyboard configurations. The default is usually US English, although if
1001 possible the PM library will auto-detect the correct code page translation
1002 for the target OS if OS services are available to determine what type of
1003 keyboard is currently attached.
1007 ****************************************************************************/
1008 void EVTAPI EVT_setCodePage(
1011 EVT.codePage = page;
1014 /* The following contains fake C prototypes and documentation for the
1015 * macro functions in the event.h header file. These exist soley so
1016 * that DocJet will correctly pull in the documentation for these functions.
1018 #ifdef INCLUDE_DOC_FUNCTIONS
1020 /****************************************************************************
1022 Macro to extract the ASCII code from a message.
1025 message - Message to extract ASCII code from
1028 ASCII code extracted from the message.
1034 Macro to extract the ASCII code from the message field of the event_t
1035 structure. You pass the message field to the macro as the parameter and
1036 the ASCII code is the result, for example:
1038 event_t EVT.myEvent;
1040 code = EVT_asciiCode(EVT.myEvent.message);
1043 EVT_scanCode, EVT_repeatCount
1044 ****************************************************************************/
1045 uchar EVT_asciiCode(
1048 /****************************************************************************
1050 Macro to extract the keyboard scan code from a message.
1056 message - Message to extract scan code from
1059 Keyboard scan code extracted from the message.
1062 Macro to extract the keyboard scan code from the message field of the event
1063 structure. You pass the message field to the macro as the parameter and
1064 the scan code is the result, for example:
1066 event_t EVT.myEvent;
1068 code = EVT_scanCode(EVT.myEvent.message);
1070 NOTE: Scan codes in the event library are not really hardware scan codes,
1071 but rather virtual scan codes as generated by a low level keyboard
1072 interface driver. All virtual scan code values are defined by the
1073 EVT_scanCodesType enumeration, and will be identical across all
1074 supports OS'es and platforms.
1077 EVT_asciiCode, EVT_repeatCount
1078 ****************************************************************************/
1082 /****************************************************************************
1084 Macro to extract the repeat count from a message.
1090 message - Message to extract repeat count from
1093 Repeat count extracted from the message.
1096 Macro to extract the repeat count from the message field of the event
1097 structure. The repeat count is the number of times that the key repeated
1098 before there was another keyboard event to be place in the queue, and
1099 allows the event handling code to avoid keyboard buffer overflow
1100 conditions when a single key is held down by the user. If you are processing
1101 a key repeat code, you will probably want to check this field to see how
1102 many key repeats you should process for this message.
1105 EVT_asciiCode, EVT_repeatCount
1106 ****************************************************************************/
1107 short EVT_repeatCount(
1110 #endif /* DOC FUNCTIONS */
1112 #if defined(__REALDOS__) || defined(__SMX32__)
1114 void EVTAPI _EVT_cCodeEnd(void) {}