From e924a862d7f4a8d527e4f6d29bf89d8c8c1c9c4a Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Tue, 13 Aug 2019 14:56:07 -0500 Subject: [PATCH] proton: Remove old xinput controller entries from registry These will get iterated by setupapi even if they're not physically present, which causes some games (HITMAN 2) to treat these devices like xinput devices. --- proton | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/proton b/proton index 8d023f86d..4418370e3 100755 --- a/proton +++ b/proton @@ -20,7 +20,7 @@ from filelock import FileLock #To enable debug logging, copy "user_settings.sample.py" to "user_settings.py" #and edit it if needed. -CURRENT_PREFIX_VERSION="4.11-1" +CURRENT_PREFIX_VERSION="4.11-2" PFX="Proton: " ld_path_var = "LD_LIBRARY_PATH" @@ -211,6 +211,32 @@ class CompatData: #deleting this directory allows wine-mono to work shutil.rmtree(self.prefix_dir + "/drive_c/windows/Microsoft.NET") + #prior to prefix version 4.11-2, all controllers were xbox controllers. wipe out the old registry entries. + if (int(old_proton_maj) < 4 or (int(old_proton_maj) == 4 and int(old_proton_min) == 11)) and \ + int(old_prefix_ver) < 2: + log("Removing old xinput registry entries.") + with open(self.prefix_dir + "system.reg", "r") as reg_in: + with open(self.prefix_dir + "system.reg.new", "w") as reg_out: + for line in reg_in: + if line[0] == '[' and "CurrentControlSet" in line and "IG_" in line: + if "DeviceClasses" in line: + reg_out.write(line.replace("DeviceClasses", "DeviceClasses_old")) + elif "Enum" in line: + reg_out.write(line.replace("Enum", "Enum_old")) + else: + reg_out.write(line) + try: + os.rename(self.prefix_dir + "system.reg", self.prefix_dir + "system.reg.old") + except OSError: + os.remove(self.prefix_dir + "system.reg") + pass + + try: + os.rename(self.prefix_dir + "system.reg.new", self.prefix_dir + "system.reg") + except OSError: + log("Unable to write new registry file to " + self.prefix_dir + "system.reg") + pass + except ValueError: log("Prefix has an invalid version?! You may want to back up user files and delete this prefix.") #Just let the Wine upgrade happen and hope it works...