Skip to content

Commit 55a5635

Browse files
committed
Avoid calling IDrectInputDevice2::GetDeviceData if there are MenuTapKey,MenuHoldKey,MenuReleaseKey buffered fake events. Should Fix #231
1 parent aaaefe1 commit 55a5635

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

obse/obse/Hooks_Input.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,16 +275,14 @@ UInt16 OSInputGlobalsEx::GetMouseControlKey(UInt16 ctrl)
275275
return key;
276276
}
277277

278-
int OSInputGlobalsEx::GetBufferedKeyStateChangeHook(DIDEVICEOBJECTDATA* data) {
278+
int OSInputGlobalsEx::GetBufferedKeyStateChangeHook(DIDEVICEOBJECTDATA* data /*Appears to be a smaller struct or with the last members overlapping aother memory zone. Fullinitialization cause strange crashes*/) {
279279
DIDEVICEOBJECTDATA temp = {};
280280
if(!this->keyboardInterface) return 0;
281281
IDirectInputDevice8* keyInterface = this->keyboardInterface;
282282
UInt32 number = 1;
283283
if(fakeBuffered.HasElement()) temp = fakeBuffered.RemoveFirst();
284-
if(keyInterface->GetDeviceData(0x14, &temp, &number, 0) != DI_OK || number == 0) return 0;
284+
else if(keyInterface->GetDeviceData(0x14, &temp, &number, 0) != DI_OK || number == 0) return 0;
285285
data->dwOfs = temp.dwOfs;
286-
data->dwData = temp.dwData;
287-
data->dwTimeStamp = temp.dwTimeStamp;
288286
return 2 - ((temp.dwData & 0x80) == 0x80);
289287
}
290288
/*

obse_whatsnew.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ xOBSE 22.10
1414
- More precise handling of replace/count/find matching part of a multibyte character (stringVar are now internally wide string, proper handling require the proper locale and codepage setted in the system)
1515
- Fix RemoveEventHandler for OnKeyEvent/OnControlEvent to remove all events with partial filter definition
1616
- Avoid rare null pointer access in ShowRuntimeError (thanks @Fox2Code)
17+
- Fix Menu{Tap/Hold/Release}Key commands not properly registering the button event for the UI.
1718
Changes:
1819
- Force C++20 Standard, modified some places for compliance
1920
API:

0 commit comments

Comments
 (0)