From fb766d1cf947bc5d250da3f0696b2953b96890c6 Mon Sep 17 00:00:00 2001 From: Daniel Richard G Date: Fri, 20 Sep 2013 15:25:14 -0400 Subject: [PATCH] Make optional the use of the SpaceNavigator libraries --- Makefile.msvc | 9 ++++++++- win32/w32main.cpp | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Makefile.msvc b/Makefile.msvc index bc4e25c6..2848db76 100644 --- a/Makefile.msvc +++ b/Makefile.msvc @@ -1,6 +1,8 @@ # SolveSpace may be built using Microsoft Visual Studio 2003 or newer. # (MSVC++ 6.0 is not supported.) +HAVE_SPACEWARE_INPUT = 1 + DEFINES = /D_WIN32_WINNT=0x500 /DISOLATION_AWARE_ENABLED /D_WIN32_IE=0x500 /DWIN32_LEAN_AND_MEAN /DWIN32 # Use the multi-threaded static libc because libpng and zlib do; not sure if anything bad # happens if those mix, but don't want to risk it. @@ -63,10 +65,15 @@ SRFOBJS = $(OBJDIR)\boolean.obj \ RES = $(OBJDIR)\resource.res LIBS = user32.lib gdi32.lib comctl32.lib advapi32.lib shell32.lib opengl32.lib glu32.lib \ - extlib\libpng.lib extlib\zlib.lib extlib\si\siapp.lib + extlib\libpng.lib extlib\zlib.lib PERL = perl +!IFDEF HAVE_SPACEWARE_INPUT +DEFINES = $(DEFINES) -DHAVE_SPACEWARE_INPUT +LIBS = $(LIBS) extlib\si\siapp.lib +!ENDIF + all: $(OBJDIR)\solvespace.exe @copy /y $(OBJDIR)\solvespace.exe . @echo solvespace.exe diff --git a/win32/w32main.cpp b/win32/w32main.cpp index 8bcc990f..fbd749a6 100644 --- a/win32/w32main.cpp +++ b/win32/w32main.cpp @@ -16,8 +16,10 @@ #include #include -#include -#include +#ifdef HAVE_SPACEWARE_INPUT +# include +# include +#endif #include "solvespace.h" @@ -52,8 +54,10 @@ int ClientIsSmallerBy; HFONT FixedFont; +#ifdef HAVE_SPACEWARE_INPUT // The 6-DOF input device. SiHdl SpaceNavigator = SI_NO_HANDLE; +#endif //----------------------------------------------------------------------------- // Routines to display message boxes on screen. Do our own, instead of using @@ -1085,6 +1089,7 @@ static void CreateMainWindows(void) ClientIsSmallerBy = (r.bottom - r.top) - (rc.bottom - rc.top); } +#ifdef HAVE_SPACEWARE_INPUT //----------------------------------------------------------------------------- // Test if a message comes from the SpaceNavigator device. If yes, dispatch // it appropriately and return TRUE. Otherwise, do nothing and return FALSE. @@ -1120,6 +1125,7 @@ static BOOL ProcessSpaceNavigatorMsg(MSG *msg) { } return TRUE; } +#endif // HAVE_SPACEWARE_INPUT //----------------------------------------------------------------------------- // Entry point into the program. @@ -1173,6 +1179,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, GetAbsoluteFilename(file); } +#ifdef HAVE_SPACEWARE_INPUT // Initialize the SpaceBall, if present. Test if the driver is running // first, to avoid a long timeout if it's not. HWND swdc = FindWindow("SpaceWare Driver Class", NULL); @@ -1184,6 +1191,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, SiOpen("GraphicsWnd", SI_ANY_DEVICE, SI_NO_MASK, SI_EVENT, &sod); SiSetUiMode(SpaceNavigator, SI_UI_NO_CONTROLS); } +#endif // Call in to the platform-independent code, and let them do their init SS.Init(file); @@ -1193,8 +1201,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, MSG msg; DWORD ret; while((ret = GetMessage(&msg, NULL, 0, 0)) != 0) { +#ifdef HAVE_SPACEWARE_INPUT // Is it a message from the six degree of freedom input device? if(ProcessSpaceNavigatorMsg(&msg)) goto done; +#endif // A message from the keyboard, which should be processed as a keyboard // accelerator? @@ -1214,10 +1224,12 @@ done: SS.DoLater(); } +#ifdef HAVE_SPACEWARE_INPUT if(swdc != NULL) { if(SpaceNavigator != SI_NO_HANDLE) SiClose(SpaceNavigator); SiTerminate(); } +#endif // Write everything back to the registry FreezeWindowPos(TextWnd);