diff --git a/core/cfg/option.h b/core/cfg/option.h index 100d890f9..87a9a090b 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); } diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 9bf12165a..5655355be 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -311,17 +311,20 @@ static void ImGui_Impl_NewFrame() ImGuiIO& io = ImGui::GetIO(); // 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