diff options
Diffstat (limited to 'proto-wine/opentrack-wrapper-wine-windows.cxx')
| -rw-r--r-- | proto-wine/opentrack-wrapper-wine-windows.cxx | 35 | 
1 files changed, 29 insertions, 6 deletions
| diff --git a/proto-wine/opentrack-wrapper-wine-windows.cxx b/proto-wine/opentrack-wrapper-wine-windows.cxx index 88ced502..c1d552e1 100644 --- a/proto-wine/opentrack-wrapper-wine-windows.cxx +++ b/proto-wine/opentrack-wrapper-wine-windows.cxx @@ -4,18 +4,22 @@  #define shm_wrapper ShmWine  #define __WINE_OLE2_H +// OSX sdk 10.8 build error otherwise +#undef _LIBCPP_MSVCRT +  #include "compat/shm.h"  #include "compat/shm.cpp"  #include "wine-shm.h"  #include "compat/library-path.hpp" +#include <cstdlib>  #include <cstring> +#include <sysexits.h>  using std::strcat; -static void write_path(const char* key, const char* subkey) +static void write_path(const char* key, const char* subkey, bool path)  { -    char dir[8192]; -    dir[sizeof(dir)-1] = '\0'; +    char dir[8192] {};      if (GetCurrentDirectoryA(8192, dir) < 8190)      { @@ -36,13 +40,32 @@ static void write_path(const char* key, const char* subkey)              // there's always a leading and trailing slash              strcat(dir, OPENTRACK_LIBRARY_PATH);              //strcat(dir, "/"); +            if (!path) +                dir[0] = '\0';              (void) RegSetValueExA(hkpath, subkey, 0, REG_SZ, (BYTE*) dir, strlen(dir) + 1);              RegCloseKey(hkpath);          }      }  } -void create_registry_key(void) { -    write_path("Software\\NaturalPoint\\NATURALPOINT\\NPClient Location", "Path"); -    write_path("Software\\Freetrack\\FreeTrackClient", "Path"); +void create_registry_key(void) +{ +    bool use_freetrack, use_npclient; +    const char* env = getenv("OTR_WINE_PROTO"); +    char* endptr; +    if (!env) env = ""; +    int selection = strtol(env, &endptr, 10); +    if (*endptr) +        selection = 0; + +    switch (selection) +    { +    default: std::exit(EX_USAGE); +    case 1: use_freetrack = true, use_npclient = false; break; +    case 2: use_freetrack = false, use_npclient = true; break; +    case 3: use_freetrack = true, use_npclient = true; break; +    } + +    write_path("Software\\NaturalPoint\\NATURALPOINT\\NPClient Location", "Path", use_npclient); +    write_path("Software\\Freetrack\\FreeTrackClient", "Path", use_freetrack);  } | 
