From cea145942d86da8a4747f1a9fb53ad2e58b2ed70 Mon Sep 17 00:00:00 2001 From: bb2020 Date: Wed, 18 Sep 2024 19:29:20 +0300 Subject: [PATCH] gimx: unstable-2021-08-31 -> 8.0 (#336754) Co-authored-by: Sandro --- pkgs/games/gimx/conf.patch | 4 +- pkgs/games/gimx/custom/Dualshock4.xml | 104 -------------------------- pkgs/games/gimx/default.nix | 77 ++++--------------- pkgs/games/gimx/gcc14.patch | 26 +++++++ 4 files changed, 42 insertions(+), 169 deletions(-) delete mode 100644 pkgs/games/gimx/custom/Dualshock4.xml create mode 100644 pkgs/games/gimx/gcc14.patch diff --git a/pkgs/games/gimx/conf.patch b/pkgs/games/gimx/conf.patch index 875cc68824ac..1040a6192f38 100644 --- a/pkgs/games/gimx/conf.patch +++ b/pkgs/games/gimx/conf.patch @@ -7,7 +7,7 @@ index 451fc48..ed45f4d 100644 snprintf(file_path, sizeof(file_path), "%s%s%s%s", gimx_params.homedir, GIMX_DIR, CONFIG_DIR, file); - -+ if(getenv("GIMXCONF")) { snprintf(file_path, sizeof(file_path), "%s", file); } ++ snprintf(file_path, sizeof(file_path), "%s", file); if(read_file(file_path) == -1) { gerror("read_file failed\n"); @@ -20,7 +20,7 @@ index 700cae9..9143d8b 100755 snprintf(file_path, sizeof(file_path), "%s%s%s%s", gimx_params.homedir, GIMX_DIR, CONFIG_DIR, gimx_params.config_file); - -+ if(getenv("GIMXCONF")) { snprintf(file_path, sizeof(file_path), "%s", gimx_params.config_file); } ++ snprintf(file_path, sizeof(file_path), "%s", gimx_params.config_file); FILE * fp = gfile_fopen(file_path, "r"); if (fp == NULL) { diff --git a/pkgs/games/gimx/custom/Dualshock4.xml b/pkgs/games/gimx/custom/Dualshock4.xml deleted file mode 100644 index 45ee5ed7c1c1..000000000000 --- a/pkgs/games/gimx/custom/Dualshock4.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pkgs/games/gimx/default.nix b/pkgs/games/gimx/default.nix index 4173ac0cc2d6..8f81ab09357d 100644 --- a/pkgs/games/gimx/default.nix +++ b/pkgs/games/gimx/default.nix @@ -1,103 +1,54 @@ -{ stdenv, lib, fetchFromGitHub, fetchpatch -, makeWrapper, curl, libusb1, xorg, libxml2 -, ncurses5, bluez, libmhash, gimxPdpGamepad ? false }: +{ stdenv, lib, fetchFromGitHub, makeWrapper, curl, libusb1, bluez, libxml2, ncurses5, libmhash, xorg }: let gimx-config = fetchFromGitHub { owner = "matlo"; repo = "GIMX-configurations"; rev = "c20300f24d32651d369e2b27614b62f4b856e4a0"; - sha256 = "02wcjk8da188x7y0jf3p0arjdh9zbb0lla3fxdb28b1xyybfvx5p"; + hash = "sha256-t/Ttlvc9LCRW624oSsFaP8EmswJ3OAn86QgF1dCUjAs="; }; in stdenv.mkDerivation rec { pname = "gimx"; - version = "unstable-2021-08-31"; + version = "8.0"; src = fetchFromGitHub { owner = "matlo"; repo = "GIMX"; - rev = "58d2098dce75ed4c90ae649460d3a7a150f4ef0a"; + rev = "v${version}"; fetchSubmodules = true; - sha256 = "05kdv2qqr311c2p76hdlgvrq7b04vcpps5c80zn8b8l7p831ilgz"; + hash = "sha256-BcFLdQgEAi6Sxyb5/P9YAIkmeXNZXrKcOa/6g817xQg="; }; - patches = [ - ./conf.patch - - # gcc-13 build fixes: - # https://github.com/matlo/GIMX/pull/705 - (fetchpatch { - name = "gcc-13-headers.patch"; - url = "https://github.com/matlo/GIMX/commit/4525dff4d9af672116d8c6c182707f2ad6295b2d.patch"; - hash = "sha256-LkswnFsxqADooa09yO7Yf0AbxTrGfjBObyv/6FQJvRs="; - }) - (fetchpatch { - name = "gcc-13-protos.patch"; - url = "https://github.com/matlo/GIMX/commit/f11855fcb8bd9d0cb9c94871b4111ddfd5b610df.patch"; - hash = "sha256-JL67UUsEyPcOuaimJtMviiGLGghuq9665Lg1QuiaWUU="; - }) - ]; + env.NIX_CFLAGS_COMPILE = "-Wno-error"; + patches = [ ./conf.patch ./gcc14.patch ]; nativeBuildInputs = [ makeWrapper ]; - buildInputs = [ - curl libusb1 bluez libxml2 ncurses5 libmhash - xorg.libX11 xorg.libXi xorg.libXext - ]; - - postPatch = lib.optionals gimxPdpGamepad '' - substituteInPlace ./shared/gimxcontroller/include/x360.h \ - --replace "0x045e" "0x0e6f" --replace "0x028e" "0x0213" - substituteInPlace ./loader/firmware/EMU360.hex \ - --replace "1B210001" "1B211001" \ - --replace "09210001" "09211001" \ - --replace "5E048E021001" "6F0E13020001" - ''; - + buildInputs = [ curl libusb1 bluez libxml2 ncurses5 libmhash xorg.libX11 xorg.libXi ]; makeFlags = [ "build-core" ]; - env.NIX_CFLAGS_COMPILE = toString [ - # Needed with GCC 12 - "-Wno-error=address" - "-Wno-error=deprecated-declarations" - "-Wno-error=use-after-free" - ]; - installPhase = '' runHook preInstall mkdir -p $out - substituteInPlace ./core/Makefile --replace "chmod ug+s" "echo" - + substituteInPlace ./core/Makefile --replace-fail "chmod ug+s" "echo" export DESTDIR="$out" make install-shared install-core mv $out/usr/lib $out/lib mv $out/usr/bin $out/bin - rmdir $out/usr + cp -r ${gimx-config}/Linux $out/share + + makeWrapper $out/bin/gimx $out/bin/gimx-ds4 \ + --add-flags "--nograb" --add-flags "-p /dev/ttyUSB0" \ + --add-flags "-c $out/share/Dualshock4.xml" runHook postInstall ''; - postInstall = '' - mkdir -p $out/share - cp -r ./loader/firmware $out/share/firmware - cp -r ${gimx-config}/Linux $out/share/config - cp -r ${./custom} $out/share/custom - - makeWrapper $out/bin/gimx $out/bin/gimx-dualshock4 \ - --set GIMXCONF 1 --add-flags "--nograb" --add-flags "-p /dev/ttyUSB0" \ - --add-flags "-c $out/share/custom/Dualshock4.xml" - - makeWrapper $out/bin/gimx $out/bin/gimx-xboxonepad \ - --set GIMXCONF 1 --add-flags "--nograb" --add-flags "-p /dev/ttyUSB0" \ - --add-flags "-c $out/share/config/XOnePadUsb.xml" - ''; - meta = with lib; { homepage = "https://github.com/matlo/GIMX"; description = "Game Input Multiplexer"; license = licenses.gpl3Only; platforms = platforms.linux; - maintainers = with maintainers; [ bb2020 ]; }; } diff --git a/pkgs/games/gimx/gcc14.patch b/pkgs/games/gimx/gcc14.patch new file mode 100644 index 000000000000..b736891f07ea --- /dev/null +++ b/pkgs/games/gimx/gcc14.patch @@ -0,0 +1,26 @@ +diff --git a/core/config_reader.c b/core/config_reader.c +index 451fc48..737d27c 100644 +--- a/core/config_reader.c ++++ b/core/config_reader.c +@@ -17,7 +17,7 @@ + #include "../directories.h" + #include "macros.h" + #include +- ++#include + /* + * These variables are used to read the configuration. + */ +diff --git a/core/gimx.c b/core/gimx.c +index 700cae9..693f72f 100755 +--- a/core/gimx.c ++++ b/core/gimx.c +@@ -8,7 +8,7 @@ + #include //to print errors + #include //to print errors + #include //PATH_MAX +- ++#include + #ifndef WIN32 + #include //to disable/enable echo + #include