]> icculus.org git repositories - taylor/freespace2.git/blob - src/osapi/os_unix.cpp
Initial revision
[taylor/freespace2.git] / src / osapi / os_unix.cpp
1 /*
2  * $Logfile: /Freespace2/code/OsApi/OsApi.cpp $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Low level Windows code
8  *
9  * $Log$
10  * Revision 1.1  2002/05/03 03:28:10  root
11  * Initial revision
12  * 
13  * 
14  * 7     6/30/99 5:53p Dave
15  * Put in new anti-camper code.
16  * 
17  * 6     6/03/99 6:37p Dave
18  * More TNT fun. Made perspective bitmaps more flexible.
19  * 
20  * 5     6/02/99 6:18p Dave
21  * Fixed TNT lockup problems! Wheeeee!
22  * 
23  * 4     12/18/98 1:13a Dave
24  * Rough 1024x768 support for Direct3D. Proper detection and usage through
25  * the launcher.
26  * 
27  * 3     10/09/98 2:57p Dave
28  * Starting splitting up OS stuff.
29  * 
30  * 2     10/08/98 2:38p Dave
31  * Cleanup up OsAPI code significantly. Removed old functions, centralized
32  * registry functions.
33  * 
34  * 118   7/10/98 5:04p Dave
35  * Fix connection speed bug on standalone server.
36  * 
37  * 117   5/24/98 2:28p Hoffoss
38  * Because we never really care about if the left or the right shift or
39  * alt key was used, but rather than either shift or alt was used, made
40  * both map to the left one.  Solves some problems, causes none.
41  * 
42  * 116   5/18/98 9:22p John
43  * Took out the annoying tab check.
44  * 
45  * 115   5/18/98 11:17a John
46  * Fixed some bugs with software window and output window.
47  * 
48  * 114   5/16/98 2:20p John
49  * Changed the os_suspend and resume to use a critical section to prevent
50  * threads from executing rather than just suspending the thread.  Had to
51  * make sure gr_close was called before os_close.
52  * 
53  * 113   5/15/98 4:49p John
54  * 
55  * 112   5/15/98 3:36p John
56  * Fixed bug with new graphics window code and standalone server.  Made
57  * hwndApp not be a global anymore.
58  * 
59  * 111   5/14/98 5:42p John
60  * Revamped the whole window position/mouse code for the graphics windows.
61  * 
62  * 110   5/04/98 11:08p Hoffoss
63  * Expanded on Force Feedback code, and moved it all into Joy_ff.cpp.
64  * Updated references everywhere to it.
65  *
66  * $NoKeywords: $
67  */
68
69 #include "pstypes.h"
70 #include "osapi.h"
71 #include "key.h"
72 #include "palman.h"
73 #include "mouse.h"
74 #include "outwnd.h"
75 #include "2d.h"
76 #include "cfile.h"
77 #include "sound.h"
78 #include "freespaceresource.h"
79 #include "managepilot.h"
80 #include "joy.h"
81 #include "joy_ff.h"
82 #include "gamesequence.h"
83 #include "freespace.h"
84 #include "osregistry.h"
85 #include "cmdline.h"
86
87 // ----------------------------------------------------------------------------------------------------
88 // OSAPI DEFINES/VARS
89 //
90
91 // os-wide globals
92 static int                      fAppActive = 0;
93 static int                      main_window_inited = 0;
94 static char                     szWinTitle[128];
95 static char                     szWinClass[128];
96 static int                      WinX, WinY, WinW, WinH;
97 static int                      Os_inited = 0;
98
99 static CRITICAL_SECTION Os_lock;
100
101 int Os_debugger_running = 0;
102
103 // ----------------------------------------------------------------------------------------------------
104 // OSAPI FORWARD DECLARATIONS
105 //
106
107 #ifdef THREADED
108         // thread handler for the main message thread
109         DWORD win32_process(DWORD lparam);
110 #else
111         DWORD win32_process1(DWORD lparam);
112         DWORD win32_process1(DWORD lparam);
113 #endif
114
115 // Fills in the Os_debugger_running with non-zero if debugger detected.
116 void os_check_debugger();
117
118 // called at shutdown. Makes sure all thread processing terminates.
119 void os_deinit();
120
121
122 // ----------------------------------------------------------------------------------------------------
123 // OSAPI FUNCTIONS
124 //
125
126 // initialization/shutdown functions -----------------------------------------------
127
128 // If app_name is NULL or ommited, then TITLE is used
129 // for the app name, which is where registry keys are stored.
130 void os_init(char * wclass, char * title, char *app_name, char *version_string )
131 {
132         STUB_FUNCTION;
133
134         Os_inited = 1;
135
136         // check to see if we're running under msdev
137         os_check_debugger();
138
139         atexit(os_deinit);
140 }
141
142 // set the main window title
143 void os_set_title( char * title )
144 {
145         STUB_FUNCTION;
146 }
147
148 // call at program end
149 void os_cleanup()
150 {
151         STUB_FUNCTION;
152         
153         #ifndef NDEBUG
154                 outwnd_close();
155         #endif
156 }
157
158
159 // window management -----------------------------------------------------------------
160
161 // Returns 1 if app is not the foreground app.
162 int os_foreground()
163 {
164         STUB_FUNCTION;
165         return 0;
166 }
167
168 // Returns the handle to the main window
169 uint os_get_window()
170 {
171         STUB_FUNCTION;
172         return 0;
173 }
174
175
176 // process management -----------------------------------------------------------------
177
178 // Sleeps for n milliseconds or until app becomes active.
179 void os_sleep(int ms)
180 {
181         usleep(ms*1000);
182 }
183
184 // Used to stop message processing
185 void os_suspend()
186 {
187         ENTER_CRITICAL_SECTION(&Os_lock);       
188 }
189
190 // resume message processing
191 void os_resume()
192 {
193         LEAVE_CRITICAL_SECTION(&Os_lock);       
194 }
195
196
197 // ----------------------------------------------------------------------------------------------------
198 // OSAPI FORWARD DECLARATIONS
199 //
200
201 // Fills in the Os_debugger_running with non-zero if debugger detected.
202 void os_check_debugger()
203 {
204 }
205
206 // called at shutdown. Makes sure all thread processing terminates.
207 void os_deinit()
208 {
209 }
210
211 void os_poll()
212 {
213 }
214
215 void debug_int3()
216 {
217 }