Skip to content

Commit

Permalink
Avoid calling IDrectInputDevice2::GetDeviceData if there are MenuTapK…
Browse files Browse the repository at this point in the history
…ey,MenuHoldKey,MenuReleaseKey buffered fake events. Should Fix #231
  • Loading branch information
llde committed Aug 14, 2024
1 parent aaaefe1 commit 55a5635
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 2 additions & 4 deletions obse/obse/Hooks_Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,14 @@ UInt16 OSInputGlobalsEx::GetMouseControlKey(UInt16 ctrl)
return key;
}

int OSInputGlobalsEx::GetBufferedKeyStateChangeHook(DIDEVICEOBJECTDATA* data) {
int OSInputGlobalsEx::GetBufferedKeyStateChangeHook(DIDEVICEOBJECTDATA* data /*Appears to be a smaller struct or with the last members overlapping aother memory zone. Fullinitialization cause strange crashes*/) {
DIDEVICEOBJECTDATA temp = {};
if(!this->keyboardInterface) return 0;
IDirectInputDevice8* keyInterface = this->keyboardInterface;
UInt32 number = 1;
if(fakeBuffered.HasElement()) temp = fakeBuffered.RemoveFirst();
if(keyInterface->GetDeviceData(0x14, &temp, &number, 0) != DI_OK || number == 0) return 0;
else if(keyInterface->GetDeviceData(0x14, &temp, &number, 0) != DI_OK || number == 0) return 0;
data->dwOfs = temp.dwOfs;
data->dwData = temp.dwData;
data->dwTimeStamp = temp.dwTimeStamp;
return 2 - ((temp.dwData & 0x80) == 0x80);
}
/*
Expand Down
1 change: 1 addition & 0 deletions obse_whatsnew.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ xOBSE 22.10
- 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)
- Fix RemoveEventHandler for OnKeyEvent/OnControlEvent to remove all events with partial filter definition
- Avoid rare null pointer access in ShowRuntimeError (thanks @Fox2Code)
- Fix Menu{Tap/Hold/Release}Key commands not properly registering the button event for the UI.
Changes:
- Force C++20 Standard, modified some places for compliance
API:
Expand Down

0 comments on commit 55a5635

Please sign in to comment.