From 108bab10bbdabcb3350b3e724ff52494d5ea2f86 Mon Sep 17 00:00:00 2001 From: nishinji <107111782+nishinji@users.noreply.github.com> Date: Wed, 14 Feb 2024 21:30:10 +0900 Subject: [PATCH] gui: some small improvements - Allows easily to hide the info dialog - Controllers_dialog: Add option to disable motion --- vita3k/config/include/config/config.h | 2 +- vita3k/config/include/config/state.h | 1 + vita3k/ctrl/include/ctrl/state.h | 1 + vita3k/ctrl/src/ctrl.cpp | 1 + vita3k/gui/src/controllers_dialog.cpp | 9 +++++++-- vita3k/modules/SceDriverUser/SceMotion.cpp | 4 ++-- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/vita3k/config/include/config/config.h b/vita3k/config/include/config/config.h index c1eb32feaa..961cbe8a62 100644 --- a/vita3k/config/include/config/config.h +++ b/vita3k/config/include/config/config.h @@ -143,7 +143,7 @@ enum ScreenshotFormat { code(std::string, "user-id", std::string{}, user_id) \ code(bool, "user-auto-connect", false, auto_user_login) \ code(std::string, "user-lang", std::string{}, user_lang) \ - code(bool, "display-info-message", true, display_info_message) \ + code(bool, "display-info-message", false, display_info_message) \ code(bool, "show-welcome", true, show_welcome) \ code(bool, "check-for-updates", true, check_for_updates) \ code(bool, "asia-font-support", false, asia_font_support) \ diff --git a/vita3k/config/include/config/state.h b/vita3k/config/include/config/state.h index 4ce3e4c10f..1680031829 100644 --- a/vita3k/config/include/config/state.h +++ b/vita3k/config/include/config/state.h @@ -107,6 +107,7 @@ struct Config : YamlLoader { bool fullscreen = false; bool console = false; bool load_app_list = false; + bool disable_motion = false; fs::path get_pref_path() const { return fs_utils::utf8_to_path(pref_path); diff --git a/vita3k/ctrl/include/ctrl/state.h b/vita3k/ctrl/include/ctrl/state.h index 0bc577d399..a2ee439055 100644 --- a/vita3k/ctrl/include/ctrl/state.h +++ b/vita3k/ctrl/include/ctrl/state.h @@ -58,6 +58,7 @@ struct CtrlState { ControllerList controllers; int controllers_num = 0; bool has_motion_support = false; + bool controllers_has_motion_support[SCE_CTRL_MAX_WIRELESS_NUM] = { false, false, false, false }; const char *controllers_name[SCE_CTRL_MAX_WIRELESS_NUM]; bool free_ports[SCE_CTRL_MAX_WIRELESS_NUM] = { true, true, true, true }; SceCtrlPadInputMode input_mode = SCE_CTRL_MODE_DIGITAL; diff --git a/vita3k/ctrl/src/ctrl.cpp b/vita3k/ctrl/src/ctrl.cpp index 401af4539c..320777e163 100644 --- a/vita3k/ctrl/src/ctrl.cpp +++ b/vita3k/ctrl/src/ctrl.cpp @@ -96,6 +96,7 @@ void refresh_controllers(CtrlState &state, EmuEnvState &emuenv) { state.controllers.emplace(guid, new_controller); state.controllers_name[joystick_index] = SDL_GameControllerNameForIndex(joystick_index); + state.controllers_has_motion_support[joystick_index] = found_gyro && found_accel; state.controllers_num++; } } diff --git a/vita3k/gui/src/controllers_dialog.cpp b/vita3k/gui/src/controllers_dialog.cpp index 3be676a0e0..83d5d5a273 100644 --- a/vita3k/gui/src/controllers_dialog.cpp +++ b/vita3k/gui/src/controllers_dialog.cpp @@ -198,15 +198,18 @@ void draw_controllers_dialog(GuiState &gui, EmuEnvState &emuenv) { ImGui::Spacing(); ImGui::Separator(); ImGui::Spacing(); - if (ImGui::BeginTable("main", 2, ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_BordersInnerV)) { + if (ImGui::BeginTable("main", 3, ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_BordersInnerV)) { ImGui::TableSetupColumn("num"); ImGui::TableSetupColumn("name"); + ImGui::TableSetupColumn("motion"); ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); ImGui::TextColored(GUI_COLOR_TEXT_TITLE, "%s", lang["num"].c_str()); ImGui::TableSetColumnIndex(1); ImGui::TextColored(GUI_COLOR_TEXT_TITLE, "%s", lang["name"].c_str()); ImGui::Spacing(); + ImGui::TableSetColumnIndex(2); + ImGui::TextColored(GUI_COLOR_TEXT_TITLE, "%s", "Motion Support"); for (auto i = 0; i < ctrl.controllers_num; i++) { ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); @@ -366,6 +369,8 @@ void draw_controllers_dialog(GuiState &gui, EmuEnvState &emuenv) { ImGui::End(); } + ImGui::TableSetColumnIndex(2); + ImGui::Text("%s", ctrl.controllers_has_motion_support[i] ? common["yes"].c_str() : common["no"].c_str()); } ImGui::EndTable(); } @@ -374,8 +379,8 @@ void draw_controllers_dialog(GuiState &gui, EmuEnvState &emuenv) { if (emuenv.ctrl.has_motion_support) { ImGui::Spacing(); + ImGui::Checkbox("Disable Motion", &emuenv.cfg.disable_motion); ImGui::PushTextWrapPos(ImGui::GetWindowWidth() - (ImGui::GetStyle().WindowPadding.x * 2.f)); - ImGui::TextColored(GUI_COLOR_TEXT_TITLE, "%s", lang["motion_support"].c_str()); ImGui::PopTextWrapPos(); } diff --git a/vita3k/modules/SceDriverUser/SceMotion.cpp b/vita3k/modules/SceDriverUser/SceMotion.cpp index 86875723d6..6da2c2b40d 100644 --- a/vita3k/modules/SceDriverUser/SceMotion.cpp +++ b/vita3k/modules/SceDriverUser/SceMotion.cpp @@ -82,7 +82,7 @@ EXPORT(int, sceMotionGetSensorState, SceMotionSensorState *sensorState, int numR if (!sensorState) return RET_ERROR(SCE_MOTION_ERROR_NULL_PARAMETER); - if (emuenv.ctrl.has_motion_support) { + if (emuenv.ctrl.has_motion_support && !emuenv.cfg.disable_motion) { std::lock_guard guard(emuenv.motion.mutex); sensorState->accelerometer = get_acceleration(emuenv.motion); sensorState->gyro = get_gyroscope(emuenv.motion); @@ -115,7 +115,7 @@ EXPORT(int, sceMotionGetState, SceMotionState *motionState) { if (!motionState) return RET_ERROR(SCE_MOTION_ERROR_NULL_PARAMETER); - if (emuenv.ctrl.has_motion_support) { + if (emuenv.ctrl.has_motion_support && !emuenv.cfg.disable_motion) { std::lock_guard guard(emuenv.motion.mutex); motionState->timestamp = emuenv.motion.last_accel_timestamp;