From 50b9638d6766551d0b4a867983c0b7b664e830a5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 3 Feb 2020 22:25:04 +0100 Subject: proto/wine: allow disabling freetrack/npclient Fixes #1042 --- proto-wine/ftnoir_protocol_wine.cpp | 4 + proto-wine/ftnoir_protocol_wine.h | 1 + proto-wine/ftnoir_protocol_wine_dialog.cpp | 1 + proto-wine/ftnoir_winecontrols.ui | 113 ++++++++++++++++++++------ proto-wine/lang/nl_NL.ts | 16 ++++ proto-wine/lang/ru_RU.ts | 16 ++++ proto-wine/lang/stub.ts | 16 ++++ proto-wine/lang/zh_CN.ts | 16 ++++ proto-wine/opentrack-wrapper-wine-windows.cxx | 30 +++++-- 9 files changed, 183 insertions(+), 30 deletions(-) (limited to 'proto-wine') diff --git a/proto-wine/ftnoir_protocol_wine.cpp b/proto-wine/ftnoir_protocol_wine.cpp index 5d46f18a..5955b507 100644 --- a/proto-wine/ftnoir_protocol_wine.cpp +++ b/proto-wine/ftnoir_protocol_wine.cpp @@ -19,6 +19,8 @@ wine::~wine() if (shm) { shm->stop = true; exit = wrapper.waitForFinished(100); + if (exit) + qDebug() << "proto/wine: wrapper exit code" << wrapper.exitCode(); } if (!exit) { @@ -92,6 +94,8 @@ module_status wine::initialize() if (s.fsync) env.insert("WINEFSYNC", "1"); + env.insert("OTR_WINE_PROTO", QString::number(s.protocol+1)); + wrapper.setProcessEnvironment(env); wrapper.setWorkingDirectory(OPENTRACK_BASE_PATH); wrapper.start(wine_path, { library_path + "opentrack-wrapper-wine.exe.so" }); diff --git a/proto-wine/ftnoir_protocol_wine.h b/proto-wine/ftnoir_protocol_wine.h index 8175be03..0e48e5b5 100644 --- a/proto-wine/ftnoir_protocol_wine.h +++ b/proto-wine/ftnoir_protocol_wine.h @@ -26,6 +26,7 @@ struct settings : opts value proton_appid{b, "proton-appid", 0}; value proton_version{b, "proton-version", {} }, wineprefix{b, "wineprefix", "~/.wine"}; + value protocol{b, "protocol", 2}; }; class wine : TR, public IProtocol diff --git a/proto-wine/ftnoir_protocol_wine_dialog.cpp b/proto-wine/ftnoir_protocol_wine_dialog.cpp index f1cb01c2..a0e7b488 100644 --- a/proto-wine/ftnoir_protocol_wine_dialog.cpp +++ b/proto-wine/ftnoir_protocol_wine_dialog.cpp @@ -20,6 +20,7 @@ FTControls::FTControls() tie_setting(s.fsync, ui.fsync); tie_setting(s.proton_appid, ui.proton_appid); tie_setting(s.wineprefix, ui.wineprefix); + tie_setting(s.protocol, ui.protocol_selection); connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &FTControls::doOK); connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &FTControls::doCancel); diff --git a/proto-wine/ftnoir_winecontrols.ui b/proto-wine/ftnoir_winecontrols.ui index a0a1e071..e9541447 100644 --- a/proto-wine/ftnoir_winecontrols.ui +++ b/proto-wine/ftnoir_winecontrols.ui @@ -9,8 +9,8 @@ 0 0 - 544 - 410 + 528 + 424 @@ -33,6 +33,19 @@ Wine variant + + + + + 0 + 0 + + + + Wine (system) + + + @@ -49,16 +62,19 @@ - - + + 0 0 - - Wine (system) + + + 286 + 0 + @@ -75,22 +91,6 @@ - - - - - 0 - 0 - - - - - 286 - 0 - - - - @@ -100,6 +100,9 @@ Advanced + + 6 + @@ -132,19 +135,81 @@ + + + + + 0 + 0 + + + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Protocol + + + + + + + + 0 + 0 + + + + + Freetrack + + + + + NPClient + + + + + Both + + + + + + + - + 0 0 + + 0 + + + 0 + - + 0 0 diff --git a/proto-wine/lang/nl_NL.ts b/proto-wine/lang/nl_NL.ts index f71d8ad7..e2183cc8 100644 --- a/proto-wine/lang/nl_NL.ts +++ b/proto-wine/lang/nl_NL.ts @@ -39,6 +39,22 @@ Proton (Steam Play) + + Protocol + + + + Freetrack + + + + NPClient + + + + Both + + wine diff --git a/proto-wine/lang/ru_RU.ts b/proto-wine/lang/ru_RU.ts index 9937083f..f3b44bd2 100644 --- a/proto-wine/lang/ru_RU.ts +++ b/proto-wine/lang/ru_RU.ts @@ -39,6 +39,22 @@ Proton (Steam Play) + + Protocol + + + + Freetrack + + + + NPClient + + + + Both + + wine diff --git a/proto-wine/lang/stub.ts b/proto-wine/lang/stub.ts index 9b74a44d..dd4f946f 100644 --- a/proto-wine/lang/stub.ts +++ b/proto-wine/lang/stub.ts @@ -39,6 +39,22 @@ Proton (Steam Play) + + Protocol + + + + Freetrack + + + + NPClient + + + + Both + + wine diff --git a/proto-wine/lang/zh_CN.ts b/proto-wine/lang/zh_CN.ts index 9b74a44d..dd4f946f 100644 --- a/proto-wine/lang/zh_CN.ts +++ b/proto-wine/lang/zh_CN.ts @@ -39,6 +39,22 @@ Proton (Steam Play) + + Protocol + + + + Freetrack + + + + NPClient + + + + Both + + wine 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); } -- cgit v1.2.3