Skip to content

Commit

Permalink
Add ControllerInputTester ASI
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgamerz committed Jul 4, 2021
1 parent c4afc6d commit 3dc51a2
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 0 deletions.
68 changes: 68 additions & 0 deletions ControllerInputTester/ControllerInputTester.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include <stdio.h>
#include <io.h>
#include <fcntl.h> /* for _O_TEXT and _O_BINARY */
#include <string>
#include <fstream>
#include <iostream>
#include <ostream>
#include <streambuf>
#include <shlwapi.h>

#include "..\ME3SDK\ME3TweaksHeader.h"
#include "..\ME3SDK\SdkHeaders.h"
#include "..\detours\detours.h"

#define _CRT_SECURE_NO_WARNINGS
#pragma comment(lib, "detours.lib") //Library needed for Hooking part.

ME3TweaksASILogger logger("Controller Input Tester v1", "ControllerInputTester.txt");

void __fastcall HookedPE(UObject *pObject, void *edx, UFunction *pFunction, void *pParms, void *pResult)
{
char *szName = pFunction->GetFullName();
if (isPartOf(szName, "Function SFXGame.SFXConsole.InputKey")) {
USFXConsole_execInputKey_Parms* params = (USFXConsole_execInputKey_Parms*)pParms;
//Event: 0 - > Down
//Event: 1 - > Up
//Event: 2 - > Holding
//logger.writeToConsoleOnly(string_format("Key pressed: %u %s\n", params->Event, params->Key.GetName()), true);
if (isPartOf(params->Key.GetName(), "Xbox")) {
if (params->Event == 0) {
logger.writeToConsoleOnly(string_format("%s DOWN\n", params->Key.GetName()), true);
}
else if (params->Event == 1) {
logger.writeToConsoleOnly(string_format("%s UP\n", params->Key.GetName()), true);
}
else if (params->Event == 2) {
logger.writeToConsoleOnly(string_format("%s HOLD\n", params->Key.GetName()), true);
}
}
}
ProcessEvent(pObject, pFunction, pParms, pResult);
}

void onAttach()
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread()); //This command set the current working thread to the game current thread.
DetourAttach(&(PVOID&)ProcessEvent, HookedPE); //This command will start your Hook.
DetourTransactionCommit();
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hModule);
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)onAttach, NULL, 0, NULL);
return true;
break;

case DLL_PROCESS_DETACH:
return true;
break;
}
return true;
};

22 changes: 22 additions & 0 deletions ControllerInputTester/ControllerInputTester.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="KismetLogger.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
Binary file added ControllerInputTester/ControllerInputTester.rc
Binary file not shown.
111 changes: 111 additions & 0 deletions ControllerInputTester/ControllerInputTester.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{8D665319-15FD-489A-BC12-D009332EA7F2}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ControllerInputTester</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>ControllerInputTester</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<PostBuildEventUseInBuild>false</PostBuildEventUseInBuild>
<TargetExt>.asi</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;ControllerInputTester_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProjectDir)..\detours;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;ControllerInputTester_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalLibraryDirectories>$(ProjectDir)..\detours;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>
</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ControllerInputTester.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ControllerInputTester.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
15 changes: 15 additions & 0 deletions ControllerInputTester/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by ControllerInputTester2.rc
//

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
8 changes: 8 additions & 0 deletions FemShep-ME3-ASI-Plugins.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.29318.209
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KismetLogger", "KismetLogger\KismetLogger.vcxproj", "{BD1404C7-84A2-4733-99E4-5FDFFD3235FE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ControllerInputTester", "ControllerInputTester\ControllerInputTester.vcxproj", "{8D665319-15FD-489A-BC12-D009332EA7F2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Experiments", "Experiments\Experiments.vcxproj", "{9871453F-068C-463E-9E34-84E4332CB0C4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0626F548-B3AC-4BAC-8251-B655279EE851}"
Expand Down Expand Up @@ -52,6 +54,12 @@ Global
{BD1404C7-84A2-4733-99E4-5FDFFD3235FE}.Release|x64.ActiveCfg = Release|Win32
{BD1404C7-84A2-4733-99E4-5FDFFD3235FE}.Release|x86.ActiveCfg = Release|Win32
{BD1404C7-84A2-4733-99E4-5FDFFD3235FE}.Release|x86.Build.0 = Release|Win32
{8D665319-15FD-489A-BC12-D009332EA7F2}.Debug|x64.ActiveCfg = Debug|Win32
{8D665319-15FD-489A-BC12-D009332EA7F2}.Debug|x86.ActiveCfg = Debug|Win32
{8D665319-15FD-489A-BC12-D009332EA7F2}.Debug|x86.Build.0 = Debug|Win32
{8D665319-15FD-489A-BC12-D009332EA7F2}.Release|x64.ActiveCfg = Release|Win32
{8D665319-15FD-489A-BC12-D009332EA7F2}.Release|x86.ActiveCfg = Release|Win32
{8D665319-15FD-489A-BC12-D009332EA7F2}.Release|x86.Build.0 = Release|Win32
{9871453F-068C-463E-9E34-84E4332CB0C4}.Debug|x64.ActiveCfg = Debug|Win32
{9871453F-068C-463E-9E34-84E4332CB0C4}.Debug|x86.ActiveCfg = Debug|Win32
{9871453F-068C-463E-9E34-84E4332CB0C4}.Debug|x86.Build.0 = Debug|Win32
Expand Down

0 comments on commit 3dc51a2

Please sign in to comment.