Added Ryujinx Emulator

This commit is contained in:
EduardTheFirst 2021-09-14 00:23:45 +03:00 committed by Mathieu Comandon
parent 14e34f0699
commit bc4bc7ea05
2 changed files with 96 additions and 0 deletions

View file

@ -27,6 +27,7 @@ __all__ = [
"snes9x",
"mupen64plus",
"dolphin",
"ryujinx",
"yuzu",
# Sony
"pcsx2",

95
lutris/runners/ryujinx.py Normal file
View file

@ -0,0 +1,95 @@
# Standard Library
import filecmp
import os
from gettext import gettext as _
from shutil import copyfile
# Lutris Modules
from lutris.runners.runner import Runner
from lutris.util import system
from lutris.util.log import logger
class ryujinx(Runner):
human_name = _("Ryujinx")
platforms = [_("Nintendo Switch")]
description = _("Nintendo Switch emulator for LDN build visit https://ryujinx.org/")
runnable_alone = True
runner_executable = "ryujinx/publish/Ryujinx"
download_url = "https://ci.appveyor.com/api/buildjobs/o37yny5mfr4dyx6d/artifacts/ryujinx-1.0.7032-linux_x64.tar.gz"
game_options = [
{
"option": "main_file",
"type": "file",
"label": _("NSP file"),
"help": _("The game data, commonly called a ROM image."),
}
]
runner_options = [
{
"option": "prod_keys",
"label": _("Encryption keys"),
"type": "file",
"help": _("File containing the encryption keys."),
}, {
"option": "title_keys",
"label": _("Title keys"),
"type": "file",
"help": _("File containing the title keys."),
}
]
@property
def ryujinx_data_dir(self):
"""Return dir where Ryujinx files lie."""
candidates = ("~/.local/share/ryujinx", )
for candidate in candidates:
path = system.fix_path_case(os.path.join(os.path.expanduser(candidate), "nand"))
if path:
return path[:-len("nand")]
def play(self):
"""Run the game."""
arguments = [self.get_executable()]
rom = self.game_config.get("main_file") or ""
if not system.path_exists(rom):
return {"error": "FILE_NOT_FOUND", "file": rom}
arguments.append(rom)
return {"command": arguments}
def _update_key(self, key_type):
"""Update a keys file if set """
ryujinx_data_dir = self.ryujinx_data_dir
if not ryujinx_data_dir:
logger.error("Ryujinx data dir not set")
return
if key_type == "prod_keys":
key_loc = os.path.join(ryujinx_data_dir, "keys/prod.keys")
elif key_type == "title_keys":
key_loc = os.path.join(ryujinx_data_dir, "keys/title.keys")
else:
logger.error("Invalid keys type %s!", key_type)
return
key = self.runner_config.get(key_type)
if not key:
logger.debug("No %s file was set.", key_type)
return
if not system.path_exists(key):
logger.warning("Keys file %s does not exist!", key)
return
keys_dir = os.path.dirname(key_loc)
if not os.path.exists(keys_dir):
os.makedirs(keys_dir)
elif os.path.isfile(key_loc) and filecmp.cmp(key, key_loc):
# If the files are identical, don't do anything
return
copyfile(key, key_loc)
def prelaunch(self):
for key in ["prod_keys", "title_keys"]:
self._update_key(key_type=key)
return True