mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
overlay: fix mouse events queued up while overlay is hidden (#683)
## Link to GitHub Issue or related Pull Request, if one exists continuation of #677 ## Description of change When overlay was hidden, when mouse buttons were clicked, they were queued up and replayed when overlay became visible again. This is due to improper usage of `GetAsyncKeyState`, per documentation. ## Testing
This commit is contained in:
@@ -948,7 +948,7 @@ namespace overlay::windows {
|
||||
|
||||
// grab current keyboard state
|
||||
for (unsigned short int i = 0x01; i < 0xFF; i++) {
|
||||
buttons_keyboard_state[i] = GetAsyncKeyState(i) != 0;
|
||||
buttons_keyboard_state[i] = (GetAsyncKeyState(i) & 0x8000) != 0;
|
||||
}
|
||||
}
|
||||
if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
|
||||
@@ -1615,7 +1615,7 @@ namespace overlay::windows {
|
||||
// use care when iterating over the result (could result in torn reads)
|
||||
bool keyboard_state_new[sizeof(buttons_keyboard_state)];
|
||||
for (size_t i = 0; i < sizeof(keyboard_state_new); i++) {
|
||||
keyboard_state_new[i] = GetAsyncKeyState(i) != 0;
|
||||
keyboard_state_new[i] = (GetAsyncKeyState(i) & 0x8000) != 0;
|
||||
}
|
||||
|
||||
// detect key presses
|
||||
|
||||
Reference in New Issue
Block a user