From 35e77976a681ed3e31dcdaf1f4ee4ea87a040c64 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Sun, 5 Sep 2021 10:29:12 +0200 Subject: [PATCH 1/2] ui: use input from all keyboards Issue #339 --- core/rend/gui.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index e59956992..4dbafa71c 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -313,17 +313,20 @@ static void ImGui_Impl_NewFrame() UpdateInputState(); // Read keyboard modifiers inputs - io.KeyCtrl = (kb_shift[0] & (0x01 | 0x10)) != 0; - io.KeyShift = (kb_shift[0] & (0x02 | 0x20)) != 0; + io.KeyCtrl = 0; + io.KeyShift = 0; io.KeyAlt = false; io.KeySuper = false; - memset(&io.KeysDown[0], 0, sizeof(io.KeysDown)); - for (int i = 0; i < IM_ARRAYSIZE(kb_key[0]); i++) - if (kb_key[0][i] != 0) - io.KeysDown[kb_key[0][i]] = true; - else - break; + for (int port = 0; port < 4; port++) + { + io.KeyCtrl |= (kb_shift[port] & (0x01 | 0x10)) != 0; + io.KeyShift |= (kb_shift[port] & (0x02 | 0x20)) != 0; + + for (int i = 0; i < IM_ARRAYSIZE(kb_key[0]); i++) + if (kb_key[port][i] != 0) + io.KeysDown[kb_key[port][i]] = true; + } if (mouseX < 0 || mouseX >= screen_width || mouseY < 0 || mouseY >= screen_height) io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); else From 6768901446550fea6cdb17e2107c1daf9fd37b2e Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Sun, 5 Sep 2021 10:30:19 +0200 Subject: [PATCH 2/2] allow semicolon in content paths --- core/cfg/option.h | 80 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 12 deletions(-) diff --git a/core/cfg/option.h b/core/cfg/option.h index f392b2285..08db3a23d 100644 --- a/core/cfg/option.h +++ b/core/cfg/option.h @@ -215,14 +215,50 @@ protected: std::vector newValue; while (true) { - std::string::size_type end = paths.find(';', start); - if (end == std::string::npos) - end = paths.size(); - if (start != end) - newValue.push_back(paths.substr(start, end - start)); - if (end == paths.size()) - break; - start = end + 1; + if (paths[start] == '"') + { + std::string v; + start++; + while (true) + { + if (paths[start] == '"') + { + if (start + 1 >= paths.size()) + { + newValue.push_back(v); + return newValue; + } + if (paths[start + 1] == '"') + { + v += paths[start++]; + start++; + } + else if (paths[start + 1] == ';') + { + newValue.push_back(v); + start += 2; + break; + } + else + { + v += paths[start++]; + } + } + else + v += paths[start++]; + } + } + else + { + std::string::size_type end = paths.find(';', start); + if (end == std::string::npos) + end = paths.size(); + if (start != end) + newValue.push_back(paths.substr(start, end - start)); + if (end == paths.size()) + break; + start = end + 1; + } } return newValue; } @@ -263,12 +299,32 @@ protected: doSave(const std::string& section, const std::string& name) const { std::string s; - for (auto& v : value) + for (const auto& v : value) { - if (s.empty()) - s = v; + if (!s.empty()) + s += ';'; + if (v.find(';') != std::string::npos || (!v.empty() && v[0] == '"')) + { + s += '"'; + std::string v2 = v; + while (true) + { + auto pos = v2.find('"'); + if (pos != std::string::npos) + { + s += v2.substr(0, pos + 1) + '"'; + v2 = v2.substr(pos + 1); + } + else + { + s += v2; + break; + } + } + s += '"'; + } else - s += ";" + v; + s += v; } cfgSaveStr(section, name, s); }