Skip to content

Commit

Permalink
always send release inputs from dispatchKeyboardMSG to imgui
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool committed Dec 7, 2023
1 parent 3c7f7c2 commit bc342a8
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,21 @@ bool shouldBlockInput() {

class $modify(CCKeyboardDispatcher) {
bool dispatchKeyboardMSG(enumKeyCodes key, bool down) {
if (!ImGuiCocos::get().isInitialized() || (!ImGui::GetIO().WantCaptureKeyboard && !shouldBlockInput())) {
if (!ImGuiCocos::get().isInitialized())
return CCKeyboardDispatcher::dispatchKeyboardMSG(key, down);

const bool shouldEatInput = ImGui::GetIO().WantCaptureKeyboard || shouldBlockInput();
if (shouldEatInput || !down) {
const auto imKey = cocosToImGuiKey(key);
if (imKey != ImGuiKey_None) {
ImGui::GetIO().AddKeyEvent(imKey, down);
}
}
const auto imKey = cocosToImGuiKey(key);
if (imKey != ImGuiKey_None) {
ImGui::GetIO().AddKeyEvent(imKey, down);
if (shouldEatInput) {
return false;
} else {
return CCKeyboardDispatcher::dispatchKeyboardMSG(key, down);
}
return false;
}
};

Expand Down

0 comments on commit bc342a8

Please sign in to comment.