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