gui: Ignore keystrokes while entering text and small fixes

This commit is contained in:
nishinji 2022-12-16 07:54:28 +09:00 committed by Zangetsu
parent 04ee757ff6
commit 1df7f42d5c
8 changed files with 17 additions and 14 deletions

View File

@ -107,6 +107,7 @@ void draw_archive_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
if (type == "file") {
// Set file filters for the file picking dialog
std::vector<host::dialog::filesystem::FileFilter> file_filters = {
{ "PlayStation Vita commercial software package (NoNpDrm/FAGDec) / PlayStation Vita homebrew software package", { "zip", "vpk" } },
{ "PlayStation Vita commercial software package (NoNpDrm/FAGDec)", { "zip" } },
{ "PlayStation Vita homebrew software package", { "vpk" } },
};

View File

@ -27,7 +27,7 @@ namespace gui {
static char const *SDL_key_to_string[]{ "[unset]", "[unknown]", "[unknown]", "[unknown]", "A", "B", "C", "D", "E", "F", "G",
"H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
"Return", "Escape", "Backspace", "Tab", "Space", "-", "=", "[", "]", "\\", "NonUS #", ";", "'", "Grave", ",", ".", "/", "CapsLock", "F1",
"Return/Enter", "Escape", "Backspace", "Tab", "Space", "-", "=", "[", "]", "\\", "NonUS #", ";", "'", "Grave", ",", ".", "/", "CapsLock", "F1",
"F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "PrtScrn", "ScrlLock", "Pause", "Insert", "Home", "PgUp", "Delete",
"End", "PgDown", "Ar Right", "Ar Left", "Ar Down", "Ar Up", "NumLock/Clear", "Keypad /", "Keypad *", "Keypad -", "Keypad +",
"Keypad Enter", "Keypad 1", "Keypad 2", "Keypad 3", "Keypad 4", "Keypad 5", "Keypad 6", "Keypad 7", "Keypad 8", "Keypad 9", "Keypad 0",
@ -152,7 +152,11 @@ void draw_controls_dialog(GuiState &gui, EmuEnvState &emuenv) {
ImGui::TextColored(GUI_COLOR_TEXT_MENUBAR, "%-16s", lang["gui"].c_str());
ImGui::Text("%-16s %-16s", lang["full_screen"].c_str(), "F11");
ImGui::Text("%-16s %-16s", lang["toggle_touch"].c_str(), "T");
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Toggles between back touch and screen touch.");
ImGui::Text("%-16s %-16s", lang["toggle_gui_visibility"].c_str(), "G");
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Toggles between showing and hiding the GUI at the top of the screen while the app is running.");
const char *error_text = lang["error_duplicate_key"].c_str();
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x / 2.f, ImGui::GetIO().DisplaySize.y / 2.f), ImGuiCond_Always, ImVec2(0.5f, 0.5f));

View File

@ -149,10 +149,9 @@ static void init_font(GuiState &gui, EmuEnvState &emuenv) {
0x0100, 0x017F, // Latin Extended A
0x2200, 0x22FF, // Math operators
0x2150, 0x218F, // Numeral forms
0x2600, 0x26FF, // Miscellaneous symbols
0x25A0, 0x26FF, // Miscellaneous symbols
0x4E00, 0x9FFF, // Unified ideograms CJC
0x2460, 0x24FF, // Enclosed Alphanumerics
0x25A0, 0x25FF, // Miscellaneous Symbols
0,
};

View File

@ -705,7 +705,7 @@ void draw_home_screen(GuiState &gui, EmuEnvState &emuenv) {
ImVec2(ARROW_UPP_CENTER.x + (20.f * SCALE.x), ARROW_UPP_CENTER.y + (16.f * SCALE.y)), ARROW_COLOR);
ImGui::SetCursorPos(ImVec2(ARROW_UPP_CENTER.x - (SELECTABLE_SIZE.x / 2.f), ARROW_UPP_CENTER.y - SELECTABLE_SIZE.y));
if ((ImGui::Selectable("##upp", false, ImGuiSelectableFlags_None, SELECTABLE_SIZE))
|| ImGui::IsKeyPressed(emuenv.cfg.keyboard_leftstick_up) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_up))
|| !ImGui::GetIO().WantTextInput && ImGui::IsKeyPressed(emuenv.cfg.keyboard_leftstick_up) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_up))
scroll_type = 1;
}
if (!gui.apps_list_opened.empty()) {
@ -716,7 +716,7 @@ void draw_home_screen(GuiState &gui, EmuEnvState &emuenv) {
ImVec2(ARROW_CENTER.x - (16.f * SCALE.x), ARROW_CENTER.y + (20.f * SCALE.y)), ARROW_COLOR);
ImGui::SetCursorPos(ImVec2(ARROW_CENTER.x - (SELECTABLE_SIZE.x / 2.f), ARROW_CENTER.y - SELECTABLE_SIZE.y));
if ((ImGui::Selectable("##right", false, ImGuiSelectableFlags_None, SELECTABLE_SIZE))
|| ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_r1) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_leftstick_right)) {
|| !ImGui::GetIO().WantTextInput && (ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_r1) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_leftstick_right) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_right))) {
last_time["start"] = 0;
++gui.current_app_selected;
gui.live_area.home_screen = false;
@ -731,7 +731,7 @@ void draw_home_screen(GuiState &gui, EmuEnvState &emuenv) {
ImVec2(ARROW_DOWN_CENTER.x - (20.f * SCALE.x), ARROW_DOWN_CENTER.y - (16.f * SCALE.y)), ARROW_COLOR);
ImGui::SetCursorPos(ImVec2(ARROW_DOWN_CENTER.x - (SELECTABLE_SIZE.x / 2.f), ARROW_DOWN_CENTER.y - SELECTABLE_SIZE.y));
if ((ImGui::Selectable("##down", false, ImGuiSelectableFlags_None, SELECTABLE_SIZE))
|| ImGui::IsKeyPressed(emuenv.cfg.keyboard_leftstick_down) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_down))
|| !ImGui::GetIO().WantTextInput && ImGui::IsKeyPressed(emuenv.cfg.keyboard_leftstick_down) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_down))
scroll_type = -1;
}
ImGui::End();

View File

@ -170,7 +170,6 @@ void ImGui_ImplSdlGL3_RenderDrawData(ImGui_GLState &state) {
// fix the offset issues as per instructed in release notes of imgui v1.86
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset + pcmd->IdxOffset);
}
// idx_buffer_offset += pcmd->ElemCount;
}
}
glDeleteVertexArrays(1, &vao_handle);

View File

@ -1110,7 +1110,7 @@ void draw_live_area_screen(GuiState &gui, EmuEnvState &emuenv) {
ImVec2(ARROW_LEFT_CENTER.x - (16.f * SCALE.x), ARROW_LEFT_CENTER.y),
ImVec2(ARROW_LEFT_CENTER.x + (16.f * SCALE.x), ARROW_LEFT_CENTER.y + (20.f * SCALE.y)), ARROW_COLOR);
ImGui::SetCursorPos(ImVec2(ARROW_LEFT_CENTER.x - (SELECTABLE_SIZE.x / 2.f), ARROW_LEFT_CENTER.y - (SELECTABLE_SIZE.y / 2.f)));
if ((ImGui::Selectable("##left", false, ImGuiSelectableFlags_None, SELECTABLE_SIZE)) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_l1) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_leftstick_left) || (wheel_counter == 1)) {
if ((ImGui::Selectable("##left", false, ImGuiSelectableFlags_None, SELECTABLE_SIZE)) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_l1) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_leftstick_left) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_left) || (wheel_counter == 1)) {
if (gui.current_app_selected == 0) {
gui.live_area.live_area_screen = false;
gui.live_area.home_screen = true;
@ -1124,7 +1124,7 @@ void draw_live_area_screen(GuiState &gui, EmuEnvState &emuenv) {
ImVec2(ARROW_RIGHT_CENTER.x + (16.f * SCALE.x), ARROW_RIGHT_CENTER.y),
ImVec2(ARROW_RIGHT_CENTER.x - (16.f * SCALE.x), ARROW_RIGHT_CENTER.y + (20.f * SCALE.y)), ARROW_COLOR);
ImGui::SetCursorPos(ImVec2(ARROW_RIGHT_CENTER.x - (SELECTABLE_SIZE.x / 2.f), ARROW_RIGHT_CENTER.y - (SELECTABLE_SIZE.y / 2.f)));
if ((ImGui::Selectable("##right", false, ImGuiSelectableFlags_None, SELECTABLE_SIZE)) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_r1) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_leftstick_right) || (wheel_counter == -1))
if ((ImGui::Selectable("##right", false, ImGuiSelectableFlags_None, SELECTABLE_SIZE)) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_r1) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_leftstick_right) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_right) || (wheel_counter == -1))
++gui.current_app_selected;
}
ImGui::SetWindowFontScale(1.f);

View File

@ -254,7 +254,7 @@ void draw_settings(GuiState &gui, EmuEnvState &emuenv) {
ImVec2(ARROW_UPP_CENTER.x + (20.f * SCALE.x), ARROW_UPP_CENTER.y + (16.f * SCALE.y)), ARROW_COLOR);
ImGui::SetCursorPos(ImVec2(ARROW_UPP_CENTER.x - (ARROW_SIZE.x / 2.f), ARROW_UPP_CENTER.y - ARROW_SIZE.y));
if ((ImGui::Selectable("##upp", false, ImGuiSelectableFlags_None, ARROW_SIZE))
|| ImGui::IsKeyPressed(emuenv.cfg.keyboard_leftstick_up) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_up))
|| !ImGui::GetIO().WantTextInput && ImGui::IsKeyPressed(emuenv.cfg.keyboard_leftstick_up) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_up))
set_scroll_pos = current_scroll_pos - (340 * SCALE.y);
}
if (current_scroll_pos < max_scroll_pos) {
@ -265,7 +265,7 @@ void draw_settings(GuiState &gui, EmuEnvState &emuenv) {
ImVec2(ARROW_DOWN_CENTER.x - (20.f * SCALE.x), ARROW_DOWN_CENTER.y - (16.f * SCALE.y)), ARROW_COLOR);
ImGui::SetCursorPos(ImVec2(ARROW_DOWN_CENTER.x - (ARROW_SIZE.x / 2.f), ARROW_DOWN_CENTER.y - ARROW_SIZE.y));
if ((ImGui::Selectable("##down", false, ImGuiSelectableFlags_None, ARROW_SIZE))
|| ImGui::IsKeyPressed(emuenv.cfg.keyboard_leftstick_down) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_down))
|| !ImGui::GetIO().WantTextInput && ImGui::IsKeyPressed(emuenv.cfg.keyboard_leftstick_down) || ImGui::IsKeyPressed(emuenv.cfg.keyboard_button_down))
set_scroll_pos = current_scroll_pos + (340 * SCALE.y);
}
}

View File

@ -600,10 +600,10 @@ bool handle_events(EmuEnvState &emuenv, GuiState &gui) {
}
if (!emuenv.io.title_id.empty() && !gui.live_area.user_management && !gui.configuration_menu.custom_settings_dialog && !gui.configuration_menu.settings_dialog && !gui.controls_menu.controls_dialog) {
// toggle gui state
if (event.key.keysym.sym == SDLK_g)
if (event.key.keysym.sym == SDLK_g && !ImGui::GetIO().WantTextInput)
emuenv.display.imgui_render = !emuenv.display.imgui_render;
// Show/Hide Live Area during app run, TODO pause app running
else if (gui::get_sys_apps_state(gui) && (event.key.keysym.scancode == emuenv.cfg.keyboard_button_psbutton)) {
else if (gui::get_sys_apps_state(gui) && (event.key.keysym.scancode == emuenv.cfg.keyboard_button_psbutton && !ImGui::GetIO().WantTextInput)) {
if (gui::get_app_open_list_index(gui, emuenv.io.app_path) == gui.apps_list_opened.end())
gui::open_live_area(gui, emuenv, emuenv.io.app_path);
else {
@ -612,7 +612,7 @@ bool handle_events(EmuEnvState &emuenv, GuiState &gui) {
}
}
}
if (event.key.keysym.sym == SDLK_t && !gui.is_key_capture_dropped)
if (event.key.keysym.sym == SDLK_t && !gui.is_key_capture_dropped && !ImGui::GetIO().WantTextInput)
toggle_touchscreen();
if (event.key.keysym.sym == SDLK_F11 && !gui.is_key_capture_dropped)
switch_full_screen(emuenv);