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 * ========================================================================
25 * Environment: IBM PC (OS/2)
27 * Description: OS/2 implementation for the SciTech cross platform
30 ****************************************************************************/
32 /*---------------------------- Global Variables ---------------------------*/
34 static int oldMouseState; /* Old mouse state */
35 static ulong oldKeyMessage; /* Old keyboard state */
36 static ushort keyUpMsg[256] = {0};/* Table of key up messages */
37 static int rangeX,rangeY; /* Range of mouse coordinates */
38 HMOU _EVT_hMouse; /* Handle to the mouse driver */
40 /*---------------------------- Implementation -----------------------------*/
42 /* These are not used under OS/2 */
43 #define _EVT_disableInt() 1
44 #define _EVT_restoreInt(flags)
46 /****************************************************************************
48 scanCode - Scan code to test
51 This macro determines if a specified key is currently down at the
52 time that the call is made.
53 ****************************************************************************/
54 #define _EVT_isKeyDown(scanCode) (keyUpMsg[scanCode] != 0)
56 /****************************************************************************
58 Pumps all messages in the message queue from OS/2 into our event queue.
59 ****************************************************************************/
60 static void _EVT_pumpMessages(void)
62 /* TODO: Implement this for OS/2 Presentation Manager apps! */
65 /****************************************************************************
67 This macro/function is used to converts the scan codes reported by the
68 keyboard to our event libraries normalised format. We only have one scan
69 code for the 'A' key, and use shift modifiers to determine if it is a
70 Ctrl-F1, Alt-F1 etc. The raw scan codes from the keyboard work this way,
71 but the OS gives us 'cooked' scan codes, we have to translate them back
73 ****************************************************************************/
74 #define _EVT_maskKeyCode(evt)
76 /****************************************************************************
78 Safely abort the event module upon catching a fatal error.
79 ****************************************************************************/
83 PM_fatalError("Unhandled exception!");
86 /****************************************************************************
88 mouseMove - Callback function to call wheneve the mouse needs to be moved
91 Initiliase the event handling module. Here we install our mouse handling ISR
92 to be called whenever any button's are pressed or released. We also build
93 the free list of events in the event queue.
95 We use handler number 2 of the mouse libraries interrupt handlers for our
96 event handling routines.
97 ****************************************************************************/
99 _EVT_mouseMoveHandler mouseMove)
101 /* Initialise the event queue */
102 EVT.mouseMove = mouseMove;
106 memset(keyUpMsg,0,sizeof(keyUpMsg));
108 /* TODO: OS/2 PM specific initialisation code! */
110 /* Catch program termination signals so we can clean up properly */
111 signal(SIGABRT, _EVT_abort);
112 signal(SIGFPE, _EVT_abort);
113 signal(SIGINT, _EVT_abort);
116 /****************************************************************************
118 Changes the range of coordinates returned by the mouse functions to the
119 specified range of values. This is used when changing between graphics
120 modes set the range of mouse coordinates for the new display mode.
121 ****************************************************************************/
122 void EVTAPI EVT_setMouseRange(
130 /****************************************************************************
132 Initiailises the internal event handling modules. The EVT_suspend function
133 can be called to suspend event handling (such as when shelling out to DOS),
134 and this function can be used to resume it again later.
135 ****************************************************************************/
136 void EVT_resume(void)
138 /* Do nothing for OS/2 */
141 /****************************************************************************
143 Suspends all of our event handling operations. This is also used to
144 de-install the event handling code.
145 ****************************************************************************/
146 void EVT_suspend(void)
148 /* Do nothing for OS/2 */
151 /****************************************************************************
153 Exits the event module for program terminatation.
154 ****************************************************************************/
157 /* Restore signal handlers */
158 signal(SIGABRT, SIG_DFL);
159 signal(SIGFPE, SIG_DFL);
160 signal(SIGINT, SIG_DFL);
162 /* TODO: OS/2 PM specific exit code */
165 /****************************************************************************
167 Modifes the mouse coordinates as necessary if scaling to OS coordinates,
168 and sets the OS mouse cursor position.
169 ****************************************************************************/
170 #define _EVT_setMousePos(x,y)