Skip to content

Commit

Permalink
sc support and textures
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Dec 30, 2023
1 parent 4ff026d commit d3b6eff
Show file tree
Hide file tree
Showing 42 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions data/plugins/MaxPayne3.FusionFix.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ GamepadIcons = 0
; 4 - Playstation 5
; 5 - Nintendo Switch
; 6 - Steam Deck
; 7 - Steam Controller
10 changes: 7 additions & 3 deletions source/buttons.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module;
export module buttons;

import common;
import comvars;
import settings;

class Buttons
Expand All @@ -19,6 +20,7 @@ private:
"PS5_",
"SWITCH_",
"SD_",
"SC_",
};

static inline std::vector<std::string> buttons = {
Expand Down Expand Up @@ -123,6 +125,8 @@ public:
{
FusionFix::onInitEvent() += []()
{
assert(gLastControllerTextureIndex == (btnPrefix.size() - 1));

auto pattern = hook::pattern("B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? B9");
gameButtonPtrs = *pattern.get_first<void**>(1);

Expand All @@ -145,7 +149,7 @@ public:
{
controllerDstTexPtr = (void**)(regs.esi + 0x104);
auto v = FusionFixSettings.GetInt("PREF_BUTTONS");
if (v > 6) v = 0; else if (v < 0) v = 6;
if (v > gLastControllerTextureIndex) v = 0; else if (v < 0) v = gLastControllerTextureIndex;
if (controllerTexPtrs[v])
*controllerDstTexPtr = controllerTexPtrs[v];
}
Expand All @@ -165,7 +169,7 @@ public:
if (oldVal == 3 && curVal == 4)
{
auto v = FusionFixSettings.GetInt("PREF_BUTTONS") + 1;
if (v > 6) v = 0; else if (v < 0) v = 6;
if (v > gLastControllerTextureIndex) v = 0; else if (v < 0) v = gLastControllerTextureIndex;

CIniReader iniWriter("");
iniWriter.WriteInteger("MAIN", "GamepadIcons", v);
Expand All @@ -175,7 +179,7 @@ public:
else if (oldVal == 4 && curVal == 3)
{
auto v = FusionFixSettings.GetInt("PREF_BUTTONS") - 1;
if (v > 6) v = 0; else if (v < 0) v = 6;
if (v > gLastControllerTextureIndex) v = 0; else if (v < 0) v = gLastControllerTextureIndex;

CIniReader iniWriter("");
iniWriter.WriteInteger("MAIN", "GamepadIcons", v);
Expand Down
1 change: 1 addition & 0 deletions source/comvars.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export HWND gWnd;
export RECT gRect;
export void* (__fastcall* getNativeAddress)(uintptr_t*, uint32_t, uint32_t);
export uintptr_t* nativeHandlerPtrAddress;
export constexpr auto gLastControllerTextureIndex = 7;

class Common
{
Expand Down
2 changes: 1 addition & 1 deletion source/settings.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public:
mFusionPrefs["PREF_OUTLINESIZE"] = std::clamp(iniReader.ReadFloat("MAIN", "OutlinesSizeMultiplier", 1.0f), 0.0f, 10.0f);
mFusionPrefs["PREF_BORDERLESS"] = std::clamp(iniReader.ReadInteger("MAIN", "BorderlessWindowed", 1), 0, 1);
mFusionPrefs["PREF_LEDILLUMINATION"] = std::clamp(iniReader.ReadInteger("MAIN", "LightSyncRGB", 1), 0, 1);
mFusionPrefs["PREF_BUTTONS"] = std::clamp(iniReader.ReadInteger("MAIN", "GamepadIcons", 0), 0, 6);
mFusionPrefs["PREF_BUTTONS"] = std::clamp(iniReader.ReadInteger("MAIN", "GamepadIcons", 0), 0, gLastControllerTextureIndex);

static std::once_flag flag;
std::call_once(flag, [&]()
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit d3b6eff

Please sign in to comment.