Fix bug where the 'o' char input got eaten because the char matches the keycode for Esc..

This commit is contained in:
Henrik Rydgård 2024-11-07 19:41:10 +01:00
parent da9bfa6256
commit e9bc28f629
2 changed files with 10 additions and 5 deletions

View file

@ -955,7 +955,7 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) {
if (UI::IsFocusMovementEnabled() || (imguiVisible_ && imguiInited_)) {
// Note: Allow some Vkeys through, so we can toggle the imgui for example (since we actually block the control mapper otherwise in imgui mode).
// We need to manually implement it here :/
if (imguiVisible_ && imguiInited_) {
if (imguiVisible_ && imguiInited_ && (key.flags & (KEY_UP | KEY_DOWN))) {
InputMapping mapping(key.deviceId, key.keyCode);
std::vector<int> pspButtons;
bool mappingFound = KeyMap::InputMappingToPspButton(mapping, &pspButtons);

View file

@ -22,10 +22,10 @@ void ImGui_ImplPlatform_KeyEvent(const KeyInput &key) {
default:
{
ImGuiKey keyCode = KeyCodeToImGui(key.keyCode);
if (keyCode == ImGuiKey_None) {
WARN_LOG(Log::System, "Unmapped ImGui keycode conversion from %d", key.keyCode);
} else {
if (keyCode != ImGuiKey_None) {
io.AddKeyEvent(keyCode, true);
} else {
WARN_LOG(Log::System, "KeyDown: Unmapped ImGui keycode conversion from %d", key.keyCode);
}
break;
}
@ -33,10 +33,15 @@ void ImGui_ImplPlatform_KeyEvent(const KeyInput &key) {
}
if (key.flags & KEY_UP) {
ImGuiKey keyCode = KeyCodeToImGui(key.keyCode);
io.AddKeyEvent(keyCode, false);
if (keyCode != ImGuiKey_None) {
io.AddKeyEvent(keyCode, false);
} else {
WARN_LOG(Log::System, "KeyUp: Unmapped ImGui keycode conversion from %d", key.keyCode);
}
}
if (key.flags & KEY_CHAR) {
const int unichar = key.unicodeChar;
if (unichar >= 0x20) {
// Insert it! (todo: do it with a string insert)
char buf[16];