aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2021-12-25 21:01:20 +0100
committerJan200101 <sentrycraft123@gmail.com>2022-05-05 11:07:56 +0200
commit4bd8a7b66d37c502b4144e9cdd9167ce87f7fa3a (patch)
tree211998e36bec30899d59ad02c941010715e13941
parentf622bf41dbc584dd17e6cfd1f1dc7bbe4250d098 (diff)
downloadpolecat-dev-proton.tar.gz
polecat-dev-proton.zip
add Proton supportdev-proton
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/CMakeLists.txt13
-rw-r--r--src/config.c10
-rw-r--r--src/config.h2
-rw-r--r--src/defines.h4
-rw-r--r--src/main.c6
-rw-r--r--src/proton.c87
-rw-r--r--src/proton.h17
8 files changed, 139 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b93216b..87f3486 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,7 @@ endif()
option(BUILD_MOCK "build polecat against mock libraries" OFF)
option(ENABLE_WINE "enables wine support [Not on Windows]" ON)
+option(ENABLE_PROTON "enables proton support [Not on Windows]" ON)
option(ENABLE_DXVK "enables dxvk support" ON)
option(ENABLE_LUTRIS "enables lutris support" OFF)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index de3d40c..42ba5ee 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -67,6 +67,19 @@ list(APPEND
)
endif()
+if (ENABLE_PROTON AND NOT WIN32)
+add_compile_definitions(PROTON_ENABLED)
+add_library(proton OBJECT
+ ${CMAKE_CURRENT_SOURCE_DIR}/proton.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/proton.h
+)
+
+list(APPEND
+ SOURCES
+ $<TARGET_OBJECTS:proton>
+)
+endif()
+
set(CFLAGS
-Wall -Wextra -pedantic
-Wconversion -Wshadow -Wstrict-aliasing
diff --git a/src/config.c b/src/config.c
index f05f5c1..4fb5f01 100644
--- a/src/config.c
+++ b/src/config.c
@@ -45,6 +45,10 @@ void getCacheDir(char* config, const size_t size)
{
getXDGDir("XDG_CACHE_HOME", "/.cache/" NAME, config, size);
}
+void getSteamDir(char* config, const size_t size)
+{
+ getXDGDir("XDG_DATA_HOME", "/.local/share/Steam", config, size);
+}
void getWineDir(char* config, const size_t size)
{
@@ -57,3 +61,9 @@ void getDXVKDir(char* config, const size_t size)
getDataDir(config, size);
strncat(config, "/dxvk", size - strlen(config) - 1);
}
+
+void getProtonDir(char* config, const size_t size)
+{
+ getSteamDir(config, size);
+ strncat(config, "/compatibilitytools.d", size - strlen(config) - 1);
+}
diff --git a/src/config.h b/src/config.h
index 39fb4d8..b2ee87d 100644
--- a/src/config.h
+++ b/src/config.h
@@ -6,8 +6,10 @@
void getConfigDir(char*, const size_t);
void getDataDir(char*, const size_t);
void getCacheDir(char*, const size_t);
+void getSteamDir(char*, const size_t);
void getWineDir(char*, const size_t);
void getDXVKDir(char*, const size_t);
+void getProtonDir(char*, const size_t);
#endif
diff --git a/src/defines.h b/src/defines.h
index eb9989f..546fedb 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -5,8 +5,10 @@
#define GITHUB_API "https://api.github.com"
#define LUTRIS_API "https://lutris.net/api"
+#define GITHUB_RELEASE(repo) GITHUB_API"/repos/" repo "/releases"
+
#define WINE_API LUTRIS_API "/runners/wine"
-#define DXVK_API GITHUB_API"/repos/lutris/dxvk/releases"
+#define DXVK_API GITHUB_RELEASE("lutris/dxvk")
#define INSTALLER_API LUTRIS_API "/installers/"
#define LUTRIS_GAME_API LUTRIS_API "/games"
#define LUTRIS_GAME_SEARCH_API LUTRIS_GAME_API "?search=%s"
diff --git a/src/main.c b/src/main.c
index 67f99db..a1b0577 100644
--- a/src/main.c
+++ b/src/main.c
@@ -7,6 +7,9 @@
#ifdef WINE_ENABLED
#include "wine.h"
#endif
+#ifdef PROTON_ENABLED
+#include "proton.h"
+#endif
#ifdef DXVK_ENABLED
#include "dxvk.h"
#endif
@@ -27,6 +30,9 @@ static const struct Command main_commands[] = {
#ifdef WINE_ENABLED
{ .name = "wine", .func = winecmd, .description = "manage wine versions" },
#endif
+#ifdef PROTON_ENABLED
+ { .name = "proton", .func = proton, .description = "manage Proton installations" },
+#endif
#ifdef DXVK_ENABLED
{ .name = "dxvk", .func = dxvk, .description = "manage DXVK versions" },
#endif
diff --git a/src/proton.c b/src/proton.c
new file mode 100644
index 0000000..0b0f289
--- /dev/null
+++ b/src/proton.c
@@ -0,0 +1,87 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <dirent.h>
+
+#include "proton.h"
+#include "config.h"
+
+static const struct Command proton_commands[] = {
+ { .name = "download", .func = proton_download, .description = "download and extract a third.party Proton release" },
+ { .name = "list", .func = proton_list, .description = "list installable Proton version" },
+ { .name = "installed", .func = proton_installed, .description = "list already installed Proton versions" },
+ { .name = "remove", .func = proton_remove, .description = "remove a Proton release" },
+};
+
+static const struct Flag proton_flags[] = {
+ { .name = "no-net", .variant = TWO, .returns = 0, .func = set_no_net, .description = "run commands without commitment"}
+};
+
+char* repos[] = {
+ GITHUB_RELEASE("GloriousEggroll/proton-ge-custom"),
+ GITHUB_RELEASE("Frogging-Family/wine-tkg-git"),
+ NULL
+};
+
+COMMAND_GROUP_FUNC(proton)
+
+COMMAND(proton, download)
+{
+ return 0;
+}
+
+COMMAND(proton, list)
+{
+ char** repo_index = repos;
+
+ do
+ {
+ puts(*repo_index);
+ ++repo_index;
+ }
+ while(*repo_index);
+
+ return 0;
+}
+
+COMMAND(proton, installed)
+{
+ char protondir[PATH_MAX];
+ getProtonDir(protondir, sizeof(protondir));
+
+ size_t protonlen = strlen(protondir)+1;
+ protondir[protonlen-1] = '/';
+
+ DIR *dir;
+ struct dirent *ent;
+
+ int intty = isatty(STDOUT_FILENO);
+
+ if (intty) puts("Installed Proton versions:");
+
+ if ((dir = opendir(protondir)) != NULL)
+ {
+ while ((ent = readdir (dir)) != NULL)
+ {
+ if (ent->d_name[0] == '.') continue;
+ strncat(protondir, ent->d_name, sizeof(protondir) - protonlen - 1);
+ int isdirec = isDir(protondir);
+ protondir[protonlen] = '\0';
+
+ if (!isdirec) continue;
+
+ if (intty) printf(" - ");
+ printf("%s\n", ent->d_name);
+ }
+ closedir(dir);
+ }
+
+ return EXIT_SUCCESS;
+}
+
+COMMAND(proton, remove)
+{
+ return 0;
+}
+
+
+COMMAND_HELP(proton, " proton")
diff --git a/src/proton.h b/src/proton.h
new file mode 100644
index 0000000..c5d87d5
--- /dev/null
+++ b/src/proton.h
@@ -0,0 +1,17 @@
+#ifndef PROTON_H
+#define PROTON_H
+
+#include <stddef.h>
+
+#include "command.h"
+
+extern char* repos[];
+
+COMMAND_GROUP(proton);
+COMMAND(proton, download);
+COMMAND(proton, list);
+COMMAND(proton, installed);
+COMMAND(proton, remove);
+COMMAND(proton, help);
+
+#endif \ No newline at end of file