Skip to content

Commit

Permalink
Add -nojoy commandline to Steam client if Steam Input is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaldaien committed Jun 1, 2024
1 parent d407334 commit ae160a3
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
Binary file modified ValvePlug.rc
Binary file not shown.
53 changes: 53 additions & 0 deletions dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "pch.h"
#include "config.h"
#include <cassert>
#include <string>

#pragma comment (lib, "shlwapi.lib")

Expand All @@ -15,6 +16,48 @@
config_s config;
volatile LONG __VP_DLL_Refs = 0UL;

using GetCommandLineW_pfn = LPWSTR (WINAPI *)(void);
using GetCommandLineA_pfn = LPSTR (WINAPI *)(void);

GetCommandLineW_pfn GetCommandLineW_Original = nullptr;
GetCommandLineA_pfn GetCommandLineA_Original = nullptr;

LPWSTR
WINAPI
GetCommandLineW_Detour (void)
{
static std::wstring cmd_line;

if (cmd_line.empty ())
{
cmd_line =
GetCommandLineW_Original ();

cmd_line += L" -nojoy";
}

return (wchar_t *)cmd_line.c_str ();
}

LPSTR
WINAPI
GetCommandLineA_Detour (void)
{
static std::string cmd_line;

if (cmd_line.empty ())
{
cmd_line =
GetCommandLineA_Original ();

cmd_line += " -nojoy";
}

return (char *)cmd_line.c_str ();
}

using GetCommandLineA_pfn = LPSTR (WINAPI *)(void);

static CreateFileA_pfn CreateFileA_Original = nullptr;
static CreateFileW_pfn CreateFileW_Original = nullptr;
static CreateFile2_pfn CreateFile2_Original = nullptr;
Expand Down Expand Up @@ -609,6 +652,16 @@ ValvePlug_InitThread (LPVOID)
XInputGetCapabilities9_1_0_Detour,
(void **)(&XInputGetCapabilities9_1_0_Original), nullptr );

SK_CreateDLLHook2 ( L"kernel32.dll",
"GetCommandLineW",
GetCommandLineW_Detour,
(void **)(&GetCommandLineW_Original), nullptr );

SK_CreateDLLHook2 ( L"kernel32.dll",
"GetCommandLineA",
GetCommandLineA_Detour,
(void **)(&GetCommandLineA_Original), nullptr );

MH_ApplyQueued ();
}

Expand Down

0 comments on commit ae160a3

Please sign in to comment.