Commit daba654e authored by Tk-Glitch's avatar Tk-Glitch

proton-tkg: Add a patch to fix Warframe closing itself after 5 minutes when no...

proton-tkg: Add a patch to fix Warframe closing itself after 5 minutes when no controller is plugged-in - thanks to @GloriousEggroll - https://github.com/GloriousEggroll/proton-ge-custom/blob/proton-ge-5/game-patches-testing/proton-hotfixes/steamclient-disable_SteamController007_if_no_controller.patch
parent ae3f8fda
diff --git a/steamclient_main.c b/steamclient_main.c
index 1322eaa..de54021 100644
--- a/steamclient_main.c
+++ b/steamclient_main.c
@@ -4,6 +4,11 @@
#include <dlfcn.h>
#include <limits.h>
#include <stdint.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <linux/joystick.h>
#include "windef.h"
#include "winbase.h"
@@ -397,6 +402,27 @@ struct steamclient_interface
static struct list steamclient_interfaces = LIST_INIT(steamclient_interfaces);
+#define WF_STEAM_ID "230410"
+#define WF_CHECK_TODO (-2)
+#define WF_CHECK_YES (1)
+#define WF_CHECK_NO (0)
+#define WF_UNLIKELY(x) __builtin_expect(!!(x),0)
+
+static int is_wf_running(void) {
+ static int wf_running_flag = WF_CHECK_TODO;
+
+ /* don't care if we execute the below
+ * spuriously */
+ if(WF_UNLIKELY(wf_running_flag == WF_CHECK_TODO)) {
+ const char* p_gameid = getenv("SteamGameId");
+ const int is_running = (!p_gameid || strcmp(p_gameid, WF_STEAM_ID)) ? WF_CHECK_NO : WF_CHECK_YES;
+ /* atomic CAS */
+ __sync_bool_compare_and_swap(&wf_running_flag, WF_CHECK_TODO, is_running);
+ }
+
+ return wf_running_flag == WF_CHECK_YES;
+}
+
void *create_win_interface(const char *name, void *linux_side)
{
struct steamclient_interface *e;
@@ -408,6 +434,60 @@ void *create_win_interface(const char *name, void *linux_side)
if (!linux_side)
return NULL;
+ if(is_wf_running() && (!strcmp(name,"SteamController007") || !strcmp(name,"SteamInput001")))
+ {
+ DIR *d;
+ struct dirent *dir;
+ char path[] = "/dev/input/";
+ d = opendir(path);
+ int js = 0;
+
+ if(d)
+ {
+ TRACE("Reading contents of %s\n", "/dev/input");
+ while ((dir = readdir(d)) != NULL)
+ {
+ TRACE("Checking %s for joystick device\n", dir->d_name);
+ if(strcasestr(dir->d_name,"js"))
+ {
+ TRACE("Found %s marked as joystick device, attempting to read device\n", dir->d_name);
+ char jsdevice[128];
+ strcpy(jsdevice,path);
+ strcat(jsdevice,dir->d_name);
+ int fd = open (jsdevice, O_RDONLY);
+ if(fd>0)
+ {
+ TRACE("%s successfully read, checking for device name\n", jsdevice);
+ char jsname[128];
+
+ if (ioctl(fd, JSIOCGNAME(sizeof(jsname)), jsname) < 0)
+ {
+ strncpy(jsname, "Unknown", sizeof(jsname));
+ }
+
+ TRACE("Verifying if %s is joystick\n", jsname);
+ if (!strcasestr(jsname,"mouse") && !strcasestr(jsname,"keyboard") )
+ {
+ TRACE("Joystick device verified, loading %s\n", name);
+ js++;
+ close(fd);
+ break;
+ }
+ }
+ close(fd);
+ }
+ }
+ closedir(d);
+ }
+
+ if(js<1)
+ {
+ TRACE("No joystick devices detected, disabling: %s\n", name);
+ return NULL;
+ }
+ }
+
+
EnterCriticalSection(&steamclient_cs);
LIST_FOR_EACH_ENTRY(e, &steamclient_interfaces, struct steamclient_interface, entry)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment