Skip to content

Commit

Permalink
gui: some small improvements
Browse files Browse the repository at this point in the history
- Add option to disable motion
- Add jpeg format support for screenshots
  • Loading branch information
nishinji authored and Macdu committed Aug 8, 2024
1 parent b3b0b22 commit 5416318
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion vita3k/config/include/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ enum ScreenshotFormat {
code(int, "perfomance-overlay-detail", static_cast<int>(MINIMUM), performance_overlay_detail) \
code(int, "perfomance-overlay-position", static_cast<int>(TOP_LEFT), performance_overlay_position) \
code(int, "screenshot-format", static_cast<int>(JPEG), screenshot_format) \
code(bool, "disable-motion", false, disable_motion) \
code(int, "keyboard-button-select", 229, keyboard_button_select) \
code(int, "keyboard-button-start", 40, keyboard_button_start) \
code(int, "keyboard-button-up", 82, keyboard_button_up) \
Expand Down Expand Up @@ -143,7 +144,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) \
Expand Down
1 change: 1 addition & 0 deletions vita3k/ctrl/include/ctrl/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions vita3k/ctrl/src/ctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
Expand Down
10 changes: 8 additions & 2 deletions vita3k/gui/src/controllers_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,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);
Expand Down Expand Up @@ -369,6 +372,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();
}
Expand All @@ -377,8 +382,9 @@ void draw_controllers_dialog(GuiState &gui, EmuEnvState &emuenv) {

if (emuenv.ctrl.has_motion_support) {
ImGui::Spacing();
if (ImGui::Checkbox("Disable Motion", &emuenv.cfg.disable_motion))
config::serialize_config(emuenv.cfg, emuenv.cfg.config_path);
ImGui::PushTextWrapPos(ImGui::GetWindowWidth() - (ImGui::GetStyle().WindowPadding.x * 2.f));
ImGui::TextColored(GUI_COLOR_TEXT_TITLE, "%s", lang["motion_support"].c_str());
ImGui::PopTextWrapPos();
}

Expand Down
4 changes: 2 additions & 2 deletions vita3k/modules/SceDriverUser/SceMotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::mutex> guard(emuenv.motion.mutex);
sensorState->accelerometer = get_acceleration(emuenv.motion);
sensorState->gyro = get_gyroscope(emuenv.motion);
Expand Down Expand Up @@ -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<std::mutex> guard(emuenv.motion.mutex);
motionState->timestamp = emuenv.motion.last_accel_timestamp;

Expand Down

0 comments on commit 5416318

Please sign in to comment.