diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2020-02-03 22:25:04 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2020-02-03 22:25:04 +0100 |
commit | 50b9638d6766551d0b4a867983c0b7b664e830a5 (patch) | |
tree | 70d369723577d2b207925b277dda5171d276bbb9 /proto-wine/opentrack-wrapper-wine-windows.cxx | |
parent | 25dd60c84f686e9e2239f70e67fd8dcd82c1b268 (diff) |
proto/wine: allow disabling freetrack/npclient
Fixes #1042
Diffstat (limited to 'proto-wine/opentrack-wrapper-wine-windows.cxx')
-rw-r--r-- | proto-wine/opentrack-wrapper-wine-windows.cxx | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/proto-wine/opentrack-wrapper-wine-windows.cxx b/proto-wine/opentrack-wrapper-wine-windows.cxx index 08e9882a..fb59eb43 100644 --- a/proto-wine/opentrack-wrapper-wine-windows.cxx +++ b/proto-wine/opentrack-wrapper-wine-windows.cxx @@ -14,10 +14,9 @@ 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) { @@ -38,13 +37,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); } |