Merge pull request #244339 from bjornfor/retroarch-auto-detect-joypads

retroarch: auto-detect joypads
This commit is contained in:
Thiago Kenji Okada 2023-07-19 14:12:24 +00:00 committed by GitHub
commit da865b2b9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 5 deletions

View File

@ -0,0 +1,28 @@
{ lib
, stdenvNoCC
, fetchFromGitHub
}:
stdenvNoCC.mkDerivation rec {
pname = "retroarch-joypad-autoconfig";
version = "1.15.0";
src = fetchFromGitHub {
owner = "libretro";
repo = "retroarch-joypad-autoconfig";
rev = "v${version}";
hash = "sha256-/F2Y08uDA/pIIeLiLfOQfGVjX2pkuOqPourlx2RbZ28=";
};
makeFlags = [
"PREFIX=$(out)"
];
meta = with lib; {
description = "Joypad autoconfig files";
homepage = "https://www.libretro.com/";
license = licenses.mit;
maintainers = with maintainers; teams.libretro.members ++ [ ];
platforms = platforms.all;
};
}

View File

@ -3,16 +3,28 @@
, makeWrapper
, retroarch
, symlinkJoin
, runCommand
, cores ? [ ]
, settings ? { }
}:
let
settingsPath = runCommand "declarative-retroarch.cfg"
{
value = lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "${n} = \"${v}\"") settings);
passAsFile = [ "value" ];
}
''
cp "$valuePath" "$out"
'';
# All cores should be located in the same path after symlinkJoin,
# but let's be safe here
coresPath = lib.lists.unique (map (c: c.libretroCore) cores);
wrapperArgs = lib.strings.escapeShellArgs
(lib.lists.flatten
(map (p: [ "--add-flags" "-L ${placeholder "out" + p}" ]) coresPath));
wrapperArgs = lib.strings.escapeShellArgs (
(lib.lists.flatten (map (p: [ "--add-flags" "-L ${placeholder "out" + p}" ]) coresPath))
++ [ "--add-flags" "--appendconfig=${settingsPath}" ]
);
in
symlinkJoin {
name = "retroarch-with-cores-${lib.getVersion retroarch}";

View File

@ -2644,19 +2644,24 @@ with pkgs;
(builtins.attrValues libretro);
};
wrapRetroArch = { retroarch }:
wrapRetroArch = { retroarch, settings ? {} }:
callPackage ../applications/emulators/retroarch/wrapper.nix
{ inherit retroarch; };
{ inherit retroarch settings; };
retroarch = wrapRetroArch {
retroarch = retroarchBare.override {
withAssets = true;
withCoreInfo = true;
};
settings = {
joypad_autoconfig_dir = "${retroarch-joypad-autoconfig}/share/libretro/autoconfig";
};
};
retroarch-assets = callPackage ../applications/emulators/retroarch/retroarch-assets.nix { };
retroarch-joypad-autoconfig = callPackage ../applications/emulators/retroarch/retroarch-joypad-autoconfig.nix { };
libretranslate = with python3.pkgs; toPythonApplication libretranslate;
libretro = recurseIntoAttrs