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.
This commit is contained in:
Andrew Eikum 2019-08-13 14:56:07 -05:00
parent 936c18088e
commit e924a862d7

28
proton
View file

@ -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...