]> git.ipfire.org Git - u-boot.git/blame - board/MAI/bios_emulator/scitech/src/pm/beos/event.c
* Code cleanup:
[u-boot.git] / board / MAI / bios_emulator / scitech / src / pm / beos / event.c
CommitLineData
c7de829c
WD
1/****************************************************************************
2*
3* SciTech OS Portability Manager Library
4*
5* ========================================================================
6*
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
11*
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.
16*
17* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
18*
19* The Initial Developer of the Original Code is SciTech Software, Inc.
20* All Rights Reserved.
21*
22* ========================================================================
23*
24* Language: ANSI C
25* Environment: BeOS
26*
27* Description: BeOS implementation for the SciTech cross platform
28* event library.
29*
30****************************************************************************/
31
32/*---------------------------- Global Variables ---------------------------*/
33
34static ushort keyUpMsg[256] = {0};/* Table of key up messages */
35static int rangeX,rangeY; /* Range of mouse coordinates */
36
37/*---------------------------- Implementation -----------------------------*/
38
39/* These are not used under non-DOS systems */
40#define _EVT_disableInt() 1
41#define _EVT_restoreInt(flags)
42
43/****************************************************************************
44PARAMETERS:
45scanCode - Scan code to test
46
47REMARKS:
48This macro determines if a specified key is currently down at the
49time that the call is made.
50****************************************************************************/
51#define _EVT_isKeyDown(scanCode) (keyUpMsg[scanCode] != 0)
52
53/****************************************************************************
54REMARKS:
55This function is used to return the number of ticks since system
56startup in milliseconds. This should be the same value that is placed into
57the time stamp fields of events, and is used to implement auto mouse down
58events.
59****************************************************************************/
60ulong _EVT_getTicks(void)
61{
8bde7f77 62 /* TODO: Implement this for your OS! */
c7de829c
WD
63}
64
65/****************************************************************************
66REMARKS:
67Pumps all messages in the application message queue into our event queue.
68****************************************************************************/
69static void _EVT_pumpMessages(void)
70{
8bde7f77
WD
71 /* TODO: The purpose of this function is to read all keyboard and mouse */
72 /* events from the OS specific event queue, translate them and post */
73 /* them into the SciTech event queue. */
74 /* */
75 /* NOTE: There are a couple of important things that this function must */
76 /* take care of: */
77 /* */
78 /* 1. Support for KEYDOWN, KEYREPEAT and KEYUP is required. */
79 /* */
80 /* 2. Support for reading hardware scan code as well as ASCII */
81 /* translated values is required. Games use the scan codes rather */
82 /* than ASCII values. Scan codes go into the high order byte of the */
83 /* keyboard message field. */
84 /* */
85 /* 3. Support for at least reading mouse motion data (mickeys) from the */
86 /* mouse is required. Using the mickey values, we can then translate */
87 /* to mouse cursor coordinates scaled to the range of the current */
88 /* graphics display mode. Mouse values are scaled based on the */
89 /* global 'rangeX' and 'rangeY'. */
90 /* */
91 /* 4. Support for a timestamp for the events is required, which is */
92 /* defined as the number of milliseconds since some event (usually */
93 /* system startup). This is the timestamp when the event occurred */
94 /* (ie: at interrupt time) not when it was stuff into the SciTech */
95 /* event queue. */
96 /* */
97 /* 5. Support for mouse double click events. If the OS has a native */
98 /* mechanism to determine this, it should be used. Otherwise the */
99 /* time stamp information will be used by the generic event code */
100 /* to generate double click events. */
c7de829c
WD
101}
102
103/****************************************************************************
104REMARKS:
105This macro/function is used to converts the scan codes reported by the
106keyboard to our event libraries normalised format. We only have one scan
107code for the 'A' key, and use shift modifiers to determine if it is a
108Ctrl-F1, Alt-F1 etc. The raw scan codes from the keyboard work this way,
109but the OS gives us 'cooked' scan codes, we have to translate them back
110to the raw format.
111****************************************************************************/
112#define _EVT_maskKeyCode(evt)
113
114/****************************************************************************
115REMARKS:
116Safely abort the event module upon catching a fatal error.
117****************************************************************************/
118void _EVT_abort()
119{
120 EVT_exit();
121 PM_fatalError("Unhandled exception!");
122}
123
124/****************************************************************************
125PARAMETERS:
126mouseMove - Callback function to call wheneve the mouse needs to be moved
127
128REMARKS:
129Initiliase the event handling module. Here we install our mouse handling ISR
130to be called whenever any button's are pressed or released. We also build
131the free list of events in the event queue.
132
133We use handler number 2 of the mouse libraries interrupt handlers for our
134event handling routines.
135****************************************************************************/
136void EVTAPI EVT_init(
137 _EVT_mouseMoveHandler mouseMove)
138{
139 /* Initialise the event queue */
140 _mouseMove = mouseMove;
141 initEventQueue();
142 memset(keyUpMsg,0,sizeof(keyUpMsg));
143
8bde7f77 144 /* TODO: Do any OS specific initialisation here */
c7de829c
WD
145
146 /* Catch program termination signals so we can clean up properly */
147 signal(SIGABRT, _EVT_abort);
148 signal(SIGFPE, _EVT_abort);
149 signal(SIGINT, _EVT_abort);
150}
151
152/****************************************************************************
153REMARKS
154Changes the range of coordinates returned by the mouse functions to the
155specified range of values. This is used when changing between graphics
156modes set the range of mouse coordinates for the new display mode.
157****************************************************************************/
158void EVTAPI EVT_setMouseRange(
159 int xRes,
160 int yRes)
161{
162 rangeX = xRes;
163 rangeY = yRes;
164}
165
166/****************************************************************************
167REMARKS:
168Initiailises the internal event handling modules. The EVT_suspend function
169can be called to suspend event handling (such as when shelling out to DOS),
170and this function can be used to resume it again later.
171****************************************************************************/
172void EVT_resume(void)
173{
8bde7f77 174 /* Do nothing for non DOS systems */
c7de829c
WD
175}
176
177/****************************************************************************
178REMARKS
179Suspends all of our event handling operations. This is also used to
180de-install the event handling code.
181****************************************************************************/
182void EVT_suspend(void)
183{
8bde7f77 184 /* Do nothing for non DOS systems */
c7de829c
WD
185}
186
187/****************************************************************************
188REMARKS
189Exits the event module for program terminatation.
190****************************************************************************/
191void EVT_exit(void)
192{
193 /* Restore signal handlers */
194 signal(SIGABRT, SIG_DFL);
195 signal(SIGFPE, SIG_DFL);
196 signal(SIGINT, SIG_DFL);
197
8bde7f77 198 /* TODO: Do any OS specific cleanup in here */
c7de829c 199}