Skip to content

Commit f121d47

Browse files
committed
WM_DEVICECHANGE fix
1 parent b89731a commit f121d47

File tree

5 files changed

+43
-4
lines changed

5 files changed

+43
-4
lines changed

.github/workflows/msvc_x86.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ env:
3535
VERINC: ${{ github.event.inputs.version_increment || 'patch' }}
3636

3737
concurrency:
38-
group: ${{ github.ref }}
39-
cancel-in-progress: true
38+
group: ${{ github.workflow }}-${{ github.ref }}
39+
cancel-in-progress: ${{ github.event_name != 'workflow_dispatch' }}
4040

4141
permissions:
4242
contents: write
@@ -55,7 +55,7 @@ jobs:
5555
uses: microsoft/setup-msbuild@main
5656

5757
- name: Auto Increment Version
58-
uses: MCKanpolat/auto-semver-action@v1
58+
uses: MCKanpolat/auto-semver-action@v2
5959
id: versioning
6060
with:
6161
releaseType: ${{ env.VERINC }}

data/plugins/MaxPayne3.FusionFix.ini

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ DisableGlobalLeaderboards = 1 // Fixes Hoboken Alleys map crash in coop
55
OutlinesSizeMultiplier = 1.0f
66
BorderlessWindowed = 1
77
LightSyncRGB = 1 // Only Logitech hardware is supported, requires Logitech G HUB app
8+
DisableDeviceChangeEvent = 1 // Fixes an issue when the game randomly enters pause menu
89
GamepadIcons = 0
910
; 0 - Xbox 360
1011
; 1 - Xbox One

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This projects aims to add new features and fix some issues in Max Payne 3. Also
3232
### New menu options
3333

3434
- **BorderlessWindowed**, scroll through **SETTINGS -> GRAPHICS -> FULLSCREEN** to switch between windowed and borderless modes
35-
- **GamepadIcons**, scroll through **SETTINGS -> CONTROLS -> GAMEPAD -> CONFIGURATION** to select various controller icon styles (Xbox 360, Xbox One, PS3, PS4, PS5, Nintendo Switch, Steam Deck)
35+
- **GamepadIcons**, scroll through **SETTINGS -> CONTROLS -> GAMEPAD -> CONFIGURATION** to select various controller icon styles (Xbox 360, Xbox One, PS3, PS4, PS5, Nintendo Switch, Steam Deck, Steam Controller)
3636

3737
### New options
3838

source/devicechange.ixx

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module;
2+
3+
#include <common.hxx>
4+
5+
export module devicechange;
6+
7+
import common;
8+
import settings;
9+
10+
class DeviceChange
11+
{
12+
public:
13+
DeviceChange()
14+
{
15+
FusionFix::onInitEvent() += []()
16+
{
17+
// Disable WM_DEVICECHANGE message handler, since it happens randomly for some reason
18+
auto pattern = hook::pattern("74 63 83 E8 18 0F 85 ? ? ? ? E8 ? ? ? ? 84 C0");
19+
static raw_mem pDeviceChangeCheck(pattern.get_first(0), { 0x90, 0x90 }); // nop
20+
21+
static auto DeviceChangeCB = []()
22+
{
23+
if (FusionFixSettings.GetInt("PREF_DEVICECHANGE"))
24+
pDeviceChangeCheck.Write();
25+
else
26+
pDeviceChangeCheck.Restore();
27+
};
28+
29+
DeviceChangeCB();
30+
31+
FusionFix::onIniFileChange() += []()
32+
{
33+
DeviceChangeCB();
34+
};
35+
};
36+
}
37+
} DeviceChange;

source/settings.ixx

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public:
2525
mFusionPrefs["PREF_BORDERLESS"] = std::clamp(iniReader.ReadInteger("MAIN", "BorderlessWindowed", 1), 0, 1);
2626
mFusionPrefs["PREF_LEDILLUMINATION"] = std::clamp(iniReader.ReadInteger("MAIN", "LightSyncRGB", 1), 0, 1);
2727
mFusionPrefs["PREF_BUTTONS"] = std::clamp(iniReader.ReadInteger("MAIN", "GamepadIcons", 0), 0, gLastControllerTextureIndex);
28+
mFusionPrefs["PREF_DEVICECHANGE"] = std::clamp(iniReader.ReadInteger("MAIN", "DisableDeviceChangeEvent", 1), 0, 1);
2829

2930
static std::once_flag flag;
3031
std::call_once(flag, [&]()

0 commit comments

Comments
 (0)