Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the ability to bind the side mouse buttons #96

Merged
merged 2 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ These don't matter except for other assembly patches
- section/xact_3d_fix.cpp
- Improvements to lua messages
- hooks/LuaMessages.cpp
- Adds the ability to bind the side mouse buttons (XButton1 and XButton2)
- hooks/OnWindowMessage.cpp
- section/OnWindowMessage.cpp

## Gameplay
- Change tick intel update interval from every 30 ticks to every 1 tick
Expand Down
3 changes: 3 additions & 0 deletions hooks/OnWindowMessage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "../define.h"
asm(".section h0; .set h0,0x00430C0E;"
"call " QU(OnWindowMessage) ";");
62 changes: 62 additions & 0 deletions section/OnWindowMessage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include "include/global.h"

struct KeyEventInfo
{
unsigned long repeatCount : 16;
unsigned long scanCode : 8;
unsigned long isExtended : 1;
unsigned long reserved : 4;
unsigned long contextCode : 1;
unsigned long previousState : 1;
unsigned long transitionState : 1;

inline unsigned long ToULong() const
{
return repeatCount |
(scanCode << 16) |
(isExtended << 24) |
(reserved << 25) |
(contextCode << 29) |
(previousState << 30) |
(transitionState << 31);
}
};
static_assert(sizeof(KeyEventInfo) == 4);

int __thiscall wxWindow__MSWWindowProc(void *this_, unsigned int uMsg, unsigned int wParam, unsigned long lParam) asm("0x0096D110");

int __thiscall OnWindowMessage(void *this_, unsigned int uMsg, unsigned int wParam, unsigned long lParam)
{
switch (uMsg)
{
case 0x020B: /*WM_XBUTTONDOWN*/
uMsg = 0x0100; /*WM_KEYDOWN*/
wParam = (((wParam) >> 16) & 0xFFFF) + 4; // VK_XBUTTON(1 or 2)
lParam = KeyEventInfo{
.repeatCount = 1,
.scanCode = 0xFF,
.isExtended = 0,
.reserved = 0,
.contextCode = 0,
.previousState = 0,
.transitionState = 0}
.ToULong();
break;
case 0x020C: /*WM_XBUTTONUP*/
uMsg = 0x0101; /*WM_KEYUP*/
wParam = (((wParam) >> 16) & 0xFFFF) + 4; // VK_XBUTTON(1 or 2)
lParam = KeyEventInfo{
.repeatCount = 1,
.scanCode = 0xFF,
.isExtended = 0,
.reserved = 0,
.contextCode = 0,
.previousState = 1,
.transitionState = 1}
.ToULong();
break;
default:
break;
}
return wxWindow__MSWWindowProc(this_, uMsg, wParam, lParam);
}