From 9b58385c8c61121499721df5c9716b8c127bf007 Mon Sep 17 00:00:00 2001 From: Taylor Richards Date: Sun, 3 Aug 2003 15:57:00 +0000 Subject: [PATCH] simpler mouse usage; default ini settings in os_init(); cleanup --- include/osapi.h | 1 - src/freespace2/freespace.cpp | 38 +++++++++++------------ src/osapi/os_unix.cpp | 59 +++++++++++++++--------------------- 3 files changed, 43 insertions(+), 55 deletions(-) diff --git a/include/osapi.h b/include/osapi.h index 5c5f641..a688d91 100644 --- a/include/osapi.h +++ b/include/osapi.h @@ -39,7 +39,6 @@ extern int Os_debugger_running; #ifdef PLAT_UNIX extern const char *detect_home(void); -void default_registry(); #endif // If app_name is NULL or ommited, then TITLE is used diff --git a/src/freespace2/freespace.cpp b/src/freespace2/freespace.cpp index 4d963a0..22f0163 100644 --- a/src/freespace2/freespace.cpp +++ b/src/freespace2/freespace.cpp @@ -15,6 +15,9 @@ * Freespace main body * * $Log$ + * Revision 1.33 2003/08/03 15:57:00 taylor + * simpler mouse usage; default ini settings in os_init(); cleanup + * * Revision 1.32 2003/06/19 11:51:41 taylor * adjustments to memory leak fixes * @@ -2391,11 +2394,6 @@ void game_init() // verify that he has a valid weapons.tbl verify_weapons_tbl(); -#ifdef PLAT_UNIX - // setup the default osreg values if they don't exist - default_registry(); -#endif - // Output version numbers to registry for auto patching purposes os_config_write_uint(NOX("Version"), NOX("Major"), FS_VERSION_MAJOR); os_config_write_uint(NOX("Version"), NOX("Minor"), FS_VERSION_MINOR); @@ -2522,12 +2520,12 @@ void game_init() if(has_sparky_hi && strstr(ptr, NOX("(1024x768)"))){ #else if(strstr(ptr, NOX("(1024x768)"))){ -#endif +#endif // NDEBUG gr_init(GR_1024, GR_GLIDE); } else { gr_init(GR_640, GR_GLIDE); } -#endif +#endif // E3_BUILD } else if (!Is_standalone && ptr && (strstr(ptr, NOX("Direct 3D -") ))) { #ifdef E3_BUILD // always 640 for E3 @@ -2539,7 +2537,7 @@ void game_init() if(has_sparky_hi && strstr(ptr, NOX("(1024x768)"))){ #else if(strstr(ptr, NOX("(1024x768)"))){ -#endif +#endif // NDEBUG // Direct 3D trying_d3d = 1; gr_init(GR_1024, GR_DIRECT3D, depth); @@ -2548,22 +2546,22 @@ void game_init() trying_d3d = 1; gr_init(GR_640, GR_DIRECT3D, depth); } -#endif +#endif // E3_BUILD } else { // Software - #ifndef NDEBUG +#ifndef NDEBUG if ( Use_fullscreen_at_startup && !Is_standalone) { gr_init(GR_640, GR_DIRECTDRAW); } else { gr_init(GR_640, GR_SOFTWARE); } - #else +#else if ( !Is_standalone ) { gr_init(GR_640, GR_DIRECTDRAW); } else { gr_init(GR_640, GR_SOFTWARE); } - #endif +#endif // !NDEBUG } #else if (!Is_standalone /* && ptr && (strstr(ptr, NOX("OpenGL"))) */) { @@ -2576,7 +2574,7 @@ void game_init() STUB_FUNCTION; gr_init(GR_640, GR_SOFTWARE); } -#endif +#endif // !PLAT_UNIX // tried d3d ? extern int Gr_inited; @@ -7163,19 +7161,19 @@ int PASCAL WinMainSub(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCm plist[i] = NULL; } } -#endif +#endif // RELEASE_REAL } if ( !Is_standalone ) { // release -- movies always play - #if defined(NDEBUG) +#if defined(NDEBUG) // in RELEASE_REAL builds make the user stick in CD2 if there are no pilots on disk so that we guarantee he plays the movie movie_play( NOX("intro.mve"), 0 ); // debug version, movie will only play with -showmovies - #elif !defined(NDEBUG) +#elif !defined(NDEBUG) movie_play( NOX("intro.mve"), 0); /* @@ -7184,10 +7182,10 @@ int PASCAL WinMainSub(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCm movie_play( NOX("intro.mve"), 0 ); #endif */ - #endif +#endif // NDEBUG } -#endif +#endif // DEMO if (Is_standalone){ gameseq_post_event(GS_EVENT_STANDALONE_MAIN); @@ -8589,7 +8587,7 @@ int init_cdrom() rval = 1; - #ifndef DEMO +#ifndef DEMO i = find_freespace_cd(); rval = set_cdrom_path(i); @@ -8601,7 +8599,7 @@ int init_cdrom() nprintf(("CD", "FreeSpace CD not found\n")); } */ - #endif +#endif return rval; } diff --git a/src/osapi/os_unix.cpp b/src/osapi/os_unix.cpp index a31ea2b..9425aa1 100644 --- a/src/osapi/os_unix.cpp +++ b/src/osapi/os_unix.cpp @@ -15,6 +15,9 @@ * Low level Windows code * * $Log$ + * Revision 1.15 2003/08/03 15:56:59 taylor + * simpler mouse usage; default ini settings in os_init(); cleanup + * * Revision 1.14 2003/05/09 05:04:15 taylor * better window min/max/focus support * @@ -144,10 +147,10 @@ // os-wide globals static int fAppActive = 1; -static int main_window_inited = 0; -static char szWinTitle[128]; -static char szWinClass[128]; -static int WinX, WinY, WinW, WinH; +//static int main_window_inited = 0; // not used (here) +//static char szWinTitle[128]; // not used (here) +//static char szWinClass[128]; // not used (here) +//static int WinX, WinY, WinW, WinH; // not used (grsoft.cpp) in UNIX build static int Os_inited = 0; static CRITICAL_SECTION Os_lock; @@ -185,8 +188,10 @@ const char *detect_home(void) return (getenv("HOME")); } -void default_registry() -{ +// If app_name is NULL or ommited, then TITLE is used +// for the app name, which is where registry keys are stored. +void os_init(char * wclass, char * title, char *app_name, char *version_string ) +{ /* set some sane defaults since we don't have a laucher... */ if (os_config_read_string(NULL, NOX("Videocard"), NULL) == NULL) os_config_write_string(NULL, NOX("Videocard"), NOX("OpenGL (640x480)")); @@ -196,16 +201,11 @@ void default_registry() if (os_config_read_string(NULL, NOX("ConnectionSpeed"), NULL) == NULL) os_config_write_string(NULL, NOX("ConnectionSpeed"), NOX("Slow")); -} - -// If app_name is NULL or ommited, then TITLE is used -// for the app name, which is where registry keys are stored. -void os_init(char * wclass, char * title, char *app_name, char *version_string ) -{ - STUB_FUNCTION; Os_inited = 1; + Os_lock = SDL_CreateMutex(); + // check to see if we're running under msdev os_check_debugger(); @@ -215,7 +215,7 @@ void os_init(char * wclass, char * title, char *app_name, char *version_string ) // set the main window title void os_set_title( char * title ) { - STUB_FUNCTION; + // the title is already set by SDL in gropengl.cpp } // call at program end @@ -223,15 +223,15 @@ void os_cleanup() { STUB_FUNCTION; - #ifndef NDEBUG +#ifndef NDEBUG outwnd_close(); - #endif +#endif } // window management ----------------------------------------------------------------- -// Returns 1 if app is not the foreground app. +// Returns 0 if app is not the foreground app. int os_foreground() { return fAppActive; @@ -240,7 +240,7 @@ int os_foreground() // Returns the handle to the main window uint os_get_window() { - STUB_FUNCTION; +// STUB_FUNCTION; // not used/needed with UNIX builds? return 0; } @@ -278,6 +278,8 @@ void os_check_debugger() // called at shutdown. Makes sure all thread processing terminates. void os_deinit() { + SDL_DestroyMutex(Os_lock); + SDL_Quit(); } @@ -289,20 +291,9 @@ void os_poll() while (SDL_PollEvent (&e)) { switch (e.type) { case SDL_MOUSEBUTTONDOWN: - if (e.button.button == SDL_BUTTON_LEFT) - mouse_mark_button (MOUSE_LEFT_BUTTON,1); - else if (e.button.button == SDL_BUTTON_RIGHT) - mouse_mark_button (MOUSE_RIGHT_BUTTON,1); - else if (e.button.button == SDL_BUTTON_MIDDLE) - mouse_mark_button (MOUSE_MIDDLE_BUTTON, 1); - break; case SDL_MOUSEBUTTONUP: - if (e.button.button == SDL_BUTTON_LEFT) - mouse_mark_button (MOUSE_LEFT_BUTTON,0); - else if (e.button.button == SDL_BUTTON_RIGHT) - mouse_mark_button (MOUSE_RIGHT_BUTTON,0); - else if (e.button.button == SDL_BUTTON_MIDDLE) - mouse_mark_button (MOUSE_MIDDLE_BUTTON, 0); + if (e.button.button <= HIGHEST_MOUSE_BUTTON) + mouse_mark_button(e.button.button, e.button.state); break; case SDL_KEYDOWN: if ((e.key.keysym.mod & KMOD_ALT) && @@ -334,11 +325,11 @@ void os_poll() } if (SDLtoFS2[e.key.keysym.sym]) - key_mark (SDLtoFS2[e.key.keysym.sym], 1, 0); + key_mark (SDLtoFS2[e.key.keysym.sym], 1, 0); break; case SDL_KEYUP: if (SDLtoFS2[e.key.keysym.sym]) - key_mark (SDLtoFS2[e.key.keysym.sym], 0, 0); + key_mark (SDLtoFS2[e.key.keysym.sym], 0, 0); break; case SDL_ACTIVEEVENT: if (e.active.state & SDL_APPACTIVE) { @@ -362,7 +353,7 @@ void os_poll() Uint32 curtic = SDL_GetTicks(); Uint32 delta = curtic - lasttic; - while (delta >= joy_pollrate) { + while (delta >= (uint)joy_pollrate) { joy_process(delta); lasttic += joy_pollrate; -- 2.39.2