Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
simons-public committed Sep 25, 2018
0 parents commit 7a43ca8
Show file tree
Hide file tree
Showing 9 changed files with 281 additions and 0 deletions.
111 changes: 111 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# protonfixes

A very basic modular method for applying fixes to run unsupported games with Steam Proton. The idea is to include seperate fixes that are only loaded when a game matching that ID is run. This should keep the individual game fixes from affecting any other games.

## Installation

1. [Download](/releases/latest) the latest release .zip file and extract it.

2. Move the `protonfixes` folder to the `Proton 3.7` or `Proton 3.7 Beta` directory.

This is usually located at `~/.steam/steam/steamapps/common/Proton 3.7` or `~/.local/share/Steam/steamapps/common/Proton 3.7` unless you have Steam installed to another location

3. If you are already using a customized `user_settings.py` file, skip to step 4. Otherwise, copy the `user_settings.py` file into the same Proton directory as the `protonfixes` folder.

4. If you are already using a customized `user_settings.py` and do not want to change your current settings, you can just import the protonfixes module in your `user_settings.py` file by adding the following lines:

```
from protonfixes.protonfix import ProtonFix
ProtonFix()
```

## Writing Game Fixes
Game fixes written in python and are named by the Steam game ID with the extension .py. For example, the file `gamefixes/377840.py` will be loaded when the game FINAL FANTASY IX is run. Here are some things to consider when writing fixes:

- Only import libraries that are part of the Python standard library for portability.
- Use docstrings and comment thoroughly. There will likely be people without python experience making game fixes and good commented examples will help
- Do not use any hard-coded paths, Steam may not always be installed in the same location.
- Check your gamefix with pylint. You can safely disable warning C0103, modules named by Steam ID will never conform to snake_case naming style.

## Enviornment Variables

From https://github.com/ValveSoftware/Proton

PROTON_LOG 1 or 0
PROTON_DUMP_DEBUG_COMMANDS 1 or 0
PROTON_DEBUG_DIR 1 or 0
PROTON_USE_WINE3D11 1 0r 0
PROTON_NO_D3D11 1 or 0
PROTON_NO_ESYNC 1 or 0

user_settings = {
#logs are saved to $HOME/steam-$STEAM_APP_ID.log, overwriting any previous log with that name
"WINEDEBUG": "+timestamp,+pid,+tid,+seh,+debugstr,+module",

"DXVK_LOG_LEVEL": "info",

#Enable DXVK's HUD
"DXVK_HUD": "devinfo,fps",

#Use wined3d for d3d11 instead of dxvk
#"PROTON_USE_WINED3D11": "1",

#Disable d3d11 entirely
# "PROTON_NO_D3D11": "1",

#Disable in-process synchronization primitives
"PROTON_NO_ESYNC": "1",
}
1 change: 1 addition & 0 deletions protonfixes/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import gamefixes
17 changes: 17 additions & 0 deletions protonfixes/gamefixes/15700.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
""" Game fox for Oddworld: Abe's Oddysee
TODO: Fix steam controller input, it is stuck in lizard mode without overlay
"""
#pylint: disable=C0103


import sys


def main():
""" Adds the -interline argument to the game
"""

print('Applying Oddworld: Abe\'s Oddysee Fixes')

# Adding -interline fixes slow videos but adds scanlines
sys.argv.append('-interline')
21 changes: 21 additions & 0 deletions protonfixes/gamefixes/15740.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
""" Game fox for Oddworld: Munch's Oddysee
Work in progress
"""
#pylint: disable=C0103


import sys


def main():
""" Changes the proton argument from the launcher to the game
"""

print('Applying Oddworld: Munch\'s Oddysee Game Fixes')

# Replace launcher with game exe in proton arguments
for idx, env in enumerate(sys.argv):
if 'Launcher' in env:
sys.argv[idx] = env.replace('bin/Launcher.exe', 'Munch.exe')

print(sys.argv)
22 changes: 22 additions & 0 deletions protonfixes/gamefixes/377840.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
""" Game fix for FINAL FANTASY IX
"""
#pylint: disable=C0103


import os
import sys


def main():
""" Changes the proton argument from the launcher to the game
"""

print('Applying FINAL FANTASY IX Game Fixes')

# Fix crackling audio
os.environ['PULSE_LATENCY_MSEC'] = '60'

# Replace launcher with game exe in proton arguments
for idx, env in enumerate(sys.argv):
if 'FF9_Launcher' in env:
sys.argv[idx] = env.replace('FF9_Launcher.exe', 'x64/FF9.exe')
Empty file.
41 changes: 41 additions & 0 deletions protonfixes/protonfix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
""" Loads gamefixes from the gamefixes dir based on game id
"""

from __future__ import print_function
import os
import re
from importlib import import_module

class ProtonFix():
""" Loads the specific fix for a game from gamefixes
"""

#pylint: disable=R0903

def __init__(self):
self._get_game_id()
self._import_fix()

def _import_fix(self):
try:
game_module = import_module(re.sub(r'\..*', '.gamefixes.', __name__) + str(self.game_id))
game_module.main()
print('Using protonfix for gameid', self.game_id)
except ImportError:
print('No protonfix for gameid', self.game_id, 'found')

def _get_game_id(self):
""" Try to get the game id from environment variables
"""

game_id = None
if game_id is None and 'SteamAppId' in os.environ:
game_id = int(os.environ["SteamAppId"])
if game_id is None and 'SteamGameId' in os.environ:
game_id = int(os.environ["SteamGameId"])
if game_id is None and 'STEAM_COMPAT_DATA_PATH' in os.environ:
game_id = int(re.findall(r'\d+', os.environ['STEAM_COMPAT_DATA_PATH'])[-1])

print('Steam gameid', game_id, 'retrieved from environment variables')
assert isinstance(game_id, int)
self.game_id = game_id
10 changes: 10 additions & 0 deletions user_settings.py-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
""" Example user_settings.py file for protonfixes
https://simons-public.github.io/protonfixes

If the protonfixes folder is not in this directory this will likely prevent
steam from launching any Proton games. Any errors in specific game fixes should
only affect that specific game.
"""

from protonfixes.protonfix import ProtonFix
ProtonFix()

0 comments on commit 7a43ca8

Please sign in to comment.