From 9fcc211220ec14254c657e539e417287617f46ba Mon Sep 17 00:00:00 2001 From: bb2020 Date: Sun, 1 Nov 2020 18:34:33 +0300 Subject: [PATCH] gimx: init at 8.0 --- pkgs/games/gimx/default.nix | 72 +++++++++++++++++++++++++++++++++ pkgs/games/gimx/ds4.patch | 16 ++++++++ pkgs/games/gimx/env.patch | 30 ++++++++++++++ pkgs/games/gimx/variant.nix | 14 +++++++ pkgs/top-level/all-packages.nix | 3 ++ 5 files changed, 135 insertions(+) create mode 100644 pkgs/games/gimx/default.nix create mode 100644 pkgs/games/gimx/ds4.patch create mode 100644 pkgs/games/gimx/env.patch create mode 100644 pkgs/games/gimx/variant.nix diff --git a/pkgs/games/gimx/default.nix b/pkgs/games/gimx/default.nix new file mode 100644 index 000000000000..727945ff2b46 --- /dev/null +++ b/pkgs/games/gimx/default.nix @@ -0,0 +1,72 @@ +{ stdenv, lib, fetchFromGitHub, makeWrapper, curl, libusb1, xorg, libxml2 +, ncurses5, bluez, libmhash, gimxAuth ? "" }: + +let + gimx-config = fetchFromGitHub { + owner = "matlo"; + repo = "GIMX-configurations"; + rev = "f31bba7d3be57519540be290cd69ba6a8dc4e4d4"; + sha256 = "0wpxx2qxyiiblz2qrl5swg00ls1aq7i5vzlk0qlnqdq8ss8jssax"; + }; + +in stdenv.mkDerivation rec { + pname = "gimx"; + version = "8.0"; + + src = fetchFromGitHub { + owner = "matlo"; + repo = "GIMX"; + rev = "v${version}"; + fetchSubmodules = true; + sha256 = "0265gg6q7ymg76fb4pjrfdwjd280b3zzry96qy92w0h411slph85"; + }; + + nativeBuildInputs = [ makeWrapper ]; + buildInputs = [ + curl libusb1 bluez libxml2 ncurses5 libmhash + xorg.libX11 xorg.libXi xorg.libXext + ]; + + patches = [ ./env.patch ]; + prePatch = (if gimxAuth == "afterglow" then (import ./variant.nix).afterglow + else ""); + + makeFlags = "build-core"; + installPhase = '' + runHook preInstall + + mkdir -p $out + substituteInPlace ./core/Makefile --replace "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 + + runHook postInstall + ''; + + postInstall = '' + mkdir -p $out/share + cp -r ./loader/firmware $out/share/firmware + cp -r ${gimx-config}/Linux $out/share/config + patch ${gimx-config}/Linux/Dualshock4.xml ${./ds4.patch} -o $out/share/DS4_noff.xml + + makeWrapper $out/bin/gimx $out/bin/gimx-with-confs \ + --set GIMXCONF $out/share + + makeWrapper $out/bin/gimx $out/bin/gimx-test-ds4 \ + --set GIMXCONF $out/share \ + --add-flags "--nograb" --add-flags "--curses" \ + --add-flags "-p /dev/ttyUSB0" --add-flags "-c DS4_noff.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/ds4.patch b/pkgs/games/gimx/ds4.patch new file mode 100644 index 000000000000..86b36adda231 --- /dev/null +++ b/pkgs/games/gimx/ds4.patch @@ -0,0 +1,16 @@ +diff --git a/Linux/Dualshock4.xml b/Linux/Dualshock4.xml +index 5e53ed3..45ee5ed 100644 +--- a/Linux/Dualshock4.xml ++++ b/Linux/Dualshock4.xml +@@ -94,6 +94,11 @@ + + + ++ ++ ++ ++ ++ + + + diff --git a/pkgs/games/gimx/env.patch b/pkgs/games/gimx/env.patch new file mode 100644 index 000000000000..e1f8ed8bb6f1 --- /dev/null +++ b/pkgs/games/gimx/env.patch @@ -0,0 +1,30 @@ +--- a/core/config_reader.c ++++ b/core/config_reader.c +@@ -1353,8 +1353,10 @@ static int read_file(char* file_path) + int read_config_file(const char* file) + { + char file_path[PATH_MAX]; +- +- snprintf(file_path, sizeof(file_path), "%s%s%s%s", gimx_params.homedir, GIMX_DIR, CONFIG_DIR, file); ++ char* e = getenv("GIMXCONF"); if (e) { snprintf(file_path, sizeof(file_path), "%s/%s", e, file); } ++ else { ++ snprintf(file_path, sizeof(file_path), "%s%s%s%s", gimx_params.homedir, GIMX_DIR, CONFIG_DIR, file); ++ } + + if(read_file(file_path) == -1) + { +--- a/core/gimx.c ++++ b/core/gimx.c +@@ -190,8 +190,10 @@ void show_config() + } + + char file_path[PATH_MAX]; +- +- snprintf(file_path, sizeof(file_path), "%s%s%s%s", gimx_params.homedir, GIMX_DIR, CONFIG_DIR, gimx_params.config_file); ++ char* e = getenv("GIMXCONF"); if (e) { snprintf(file_path, sizeof(file_path), "%s/%s", e, gimx_params.config_file); } ++ else { ++ snprintf(file_path, sizeof(file_path), "%s%s%s%s", gimx_params.homedir, GIMX_DIR, CONFIG_DIR, gimx_params.config_file); ++ } + + FILE * fp = gfile_fopen(file_path, "r"); + if (fp == NULL) diff --git a/pkgs/games/gimx/variant.nix b/pkgs/games/gimx/variant.nix new file mode 100644 index 000000000000..8396f72b4e77 --- /dev/null +++ b/pkgs/games/gimx/variant.nix @@ -0,0 +1,14 @@ +{ + afterglow = '' + substituteInPlace ./shared/gimxcontroller/include/x360.h \ + --replace "0x045e" "0x0e6f" --replace "0x028e" "0x0213" + + HEX="./loader/firmware/EMU360.hex" + sed -i '34s|1B2100|1B2110|' "$HEX" + sed -i '38s|092100|092110|' "$HEX" + sed -i '40s|5E048E021001|6F0E13020001|' "$HEX" + sed -i '34s|1C\r|0C\r|' "$HEX" + sed -i '38s|FE\r|EE\r|' "$HEX" + sed -i '40s|6D\r|DD\r|' "$HEX" + ''; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c9e45a90aea7..5435c2f17fab 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -26538,6 +26538,9 @@ in gemrb = callPackage ../games/gemrb { }; + gimx = callPackage ../games/gimx {}; + gimx-afterglow = lowPrio (gimx.override { gimxAuth = "afterglow"; }); + gl117 = callPackage ../games/gl-117 {}; globulation2 = callPackage ../games/globulation {