forked from FAForever/FA-Binary-Patches
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to bind the side mouse buttons (FAForever#96)
Supports the buttons that are identified with `XButton1` and `XButton2`
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) ";"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |