From 89a004214eb34b4f86c7ce653b5da6d9652b9110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E7=80=AC=E7=B4=85=E8=8E=89=E6=A0=96?= Date: Sun, 26 Apr 2020 15:22:53 -0500 Subject: [PATCH 01/12] Allow user to toggle FPS display --- src/config.c | 4 ++++ src/config.h | 1 + src/gui/ui_settings.c | 13 +++++++++++++ src/video/vita.c | 6 +++--- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/config.c b/src/config.c index 107b581a..dc2f2e24 100644 --- a/src/config.c +++ b/src/config.c @@ -100,6 +100,8 @@ static int ini_handle(void *out, const char *section, const char *name, config->enable_frame_pacer = BOOL(value); } else if (strcmp(name, "disable_powersave") == 0) { config->disable_powersave = BOOL(value); + } else if (strcmp(name, "show_fps") == 0) { + config->show_fps = BOOL(value); } else if (strcmp(name, "save_debug_log") == 0) { config->save_debug_log = BOOL(value); } else if (strcmp(name, "mapping") == 0) { @@ -151,6 +153,7 @@ void config_save(const char* filename, PCONFIGURATION config) { write_config_bool(fd, "enable_frame_pacer", config->enable_frame_pacer); write_config_bool(fd, "disable_powersave", config->disable_powersave); + write_config_bool(fd, "show_fps", config->show_fps); write_config_bool(fd, "save_debug_log", config->save_debug_log); write_config_int(fd, "mouse_acceleration", config->mouse_acceleration); @@ -198,6 +201,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) { config->unsupported_version = false; config->save_debug_log = false; config->disable_powersave = true; + config->show_fps = false; config->enable_frame_pacer = true; config->special_keys.nw = INPUT_SPECIAL_KEY_PAUSE | INPUT_TYPE_SPECIAL; diff --git a/src/config.h b/src/config.h index 79691e59..a1cacaff 100644 --- a/src/config.h +++ b/src/config.h @@ -57,6 +57,7 @@ typedef struct _CONFIGURATION { struct touchscreen_deadzone back_deadzone; struct special_keys special_keys; bool disable_powersave; + bool show_fps; bool enable_frame_pacer; bool save_debug_log; struct input_config inputs[MAX_INPUTS]; diff --git a/src/gui/ui_settings.c b/src/gui/ui_settings.c index dd03f5ab..660ec428 100644 --- a/src/gui/ui_settings.c +++ b/src/gui/ui_settings.c @@ -381,6 +381,7 @@ enum { SETTINGS_ENABLE_STREAM_OPTIMIZE, SETTINGS_SAVE_DEBUG_LOG, SETTINGS_DISABLE_POWERSAVE, + SETTINGS_SHOW_FPS, SETTINGS_ENABLE_FRAME_PACER, SETTINGS_ENABLE_MAPPING, SETTINGS_BACK_DEADZONE, @@ -397,6 +398,7 @@ enum { SETTINGS_VIEW_ENABLE_STREAM_OPTIMIZE, SETTINGS_VIEW_SAVE_DEBUG_LOG, SETTINGS_VIEW_DISABLE_POWERSAVE, + SETTINGS_VIEW_SHOW_FPS, SETTINGS_VIEW_ENABLE_FRAME_PACER, SETTINGS_VIEW_ENABLE_MAPPING, SETTINGS_VIEW_BACK_DEADZONE, @@ -518,6 +520,13 @@ static int settings_loop(int id, void *context, const input_data *input) { did_change = 1; config.disable_powersave = !config.disable_powersave; break; + case SETTINGS_SHOW_FPS: + if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + break; + } + did_change = 1; + config.show_fps = !config.show_fps; + break; case SETTINGS_ENABLE_FRAME_PACER: if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { break; @@ -602,6 +611,9 @@ static int settings_loop(int id, void *context, const input_data *input) { sprintf(current, "%s", config.disable_powersave ? "yes" : "no"); MENU_REPLACE(SETTINGS_VIEW_DISABLE_POWERSAVE, current); + sprintf(current, "%s", config.show_fps ? "yes" : "no"); + MENU_REPLACE(SETTINGS_VIEW_SHOW_FPS, current); + sprintf(current, "%s", config.enable_frame_pacer ? "yes" : "no"); MENU_REPLACE(SETTINGS_VIEW_ENABLE_FRAME_PACER, current); @@ -660,6 +672,7 @@ int ui_settings_menu() { MENU_CATEGORY("System"); MENU_ENTRY(SETTINGS_SAVE_DEBUG_LOG, SETTINGS_VIEW_SAVE_DEBUG_LOG, "Enable debug log", ""); MENU_ENTRY(SETTINGS_DISABLE_POWERSAVE, SETTINGS_VIEW_DISABLE_POWERSAVE, "Disable power save", ""); + MENU_ENTRY(SETTINGS_SHOW_FPS, SETTINGS_VIEW_SHOW_FPS, "Show FPS", ""); MENU_CATEGORY("Input"); MENU_ENTRY(SETTINGS_MOUSE_ACCEL, SETTINGS_VIEW_MOUSE_ACCEL, "Mouse acceleration", ICON_LEFT_RIGHT_ARROWS); diff --git a/src/video/vita.c b/src/video/vita.c index e50825ec..bc58e66a 100644 --- a/src/video/vita.c +++ b/src/video/vita.c @@ -409,9 +409,9 @@ static int vita_submit_decode_unit(PDECODE_UNIT decodeUnit) { vita2d_start_drawing(); void *tex_buf = vita2d_texture_get_datap(frame_texture); vita2d_draw_texture(frame_texture, 0, 0); -#ifdef DRAW_FPS - vita2d_font_draw_textf(font, 20, 40, RGBA8(0xFF, 0xFF, 0xFF, 0xFF), 12, "fps: %u / %u", curr_fps[0], curr_fps[1]); -#endif + if (config.show_fps) { + vita2d_font_draw_textf(font, 20, 40, RGBA8(0xFF, 0xFF, 0xFF, 0xFF), 12, "fps: %u / %u", curr_fps[0], curr_fps[1]); + } draw_indicators(); vita2d_end_drawing(); vita2d_wait_rendering_done(); From 60c6b6ff8d26003ceb5545ee773931a011775b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E7=80=AC=E7=B4=85=E8=8E=89=E6=A0=96?= Date: Sun, 26 Apr 2020 18:48:35 -0500 Subject: [PATCH 02/12] Add button layout switch Alternative to this is to use sceRegMgrGetKeyInt (see xyzz/vita-button-swapper). However this requires extended permission. --- src/config.c | 17 +++++++++++++++++ src/config.h | 8 ++++++++ src/gui/guilib.c | 7 +++++-- src/gui/ui.c | 2 +- src/gui/ui_connect.c | 2 +- src/gui/ui_device.c | 2 +- src/gui/ui_settings.c | 38 ++++++++++++++++++++++++++------------ 7 files changed, 59 insertions(+), 17 deletions(-) diff --git a/src/config.c b/src/config.c index 107b581a..5be8a010 100644 --- a/src/config.c +++ b/src/config.c @@ -100,6 +100,8 @@ static int ini_handle(void *out, const char *section, const char *name, config->enable_frame_pacer = BOOL(value); } else if (strcmp(name, "disable_powersave") == 0) { config->disable_powersave = BOOL(value); + } else if (strcmp(name, "jp_layout") == 0) { + config->jp_layout = BOOL(value); } else if (strcmp(name, "save_debug_log") == 0) { config->save_debug_log = BOOL(value); } else if (strcmp(name, "mapping") == 0) { @@ -151,6 +153,7 @@ void config_save(const char* filename, PCONFIGURATION config) { write_config_bool(fd, "enable_frame_pacer", config->enable_frame_pacer); write_config_bool(fd, "disable_powersave", config->disable_powersave); + write_config_bool(fd, "jp_layout", config->jp_layout); write_config_bool(fd, "save_debug_log", config->save_debug_log); write_config_int(fd, "mouse_acceleration", config->mouse_acceleration); @@ -174,6 +177,17 @@ void config_save(const char* filename, PCONFIGURATION config) { fclose(fd); } +void update_layout() { + if (config.jp_layout) { + config.btn_confirm = SCE_CTRL_CIRCLE; + config.btn_cancel = SCE_CTRL_CROSS; + } + else { + config.btn_confirm = SCE_CTRL_CROSS; + config.btn_cancel = SCE_CTRL_CIRCLE; + } +} + void config_parse(int argc, char* argv[], PCONFIGURATION config) { LiInitializeStreamConfiguration(&config->stream); @@ -198,6 +212,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) { config->unsupported_version = false; config->save_debug_log = false; config->disable_powersave = true; + config->jp_layout = false; config->enable_frame_pacer = true; config->special_keys.nw = INPUT_SPECIAL_KEY_PAUSE | INPUT_TYPE_SPECIAL; @@ -218,6 +233,8 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) { config_file_parse(config_file, config); } + update_layout(); + if (config->config_file != NULL) config_save(config->config_file, config); diff --git a/src/config.h b/src/config.h index 79691e59..ac11ad99 100644 --- a/src/config.h +++ b/src/config.h @@ -23,6 +23,8 @@ #include #include +#include + #define MAX_INPUTS 6 struct input_config { @@ -40,6 +42,7 @@ struct special_keys { }; typedef struct _CONFIGURATION { + // static configuration, value will be saved to config file STREAM_CONFIGURATION stream; char* app; char* action; @@ -64,6 +67,10 @@ typedef struct _CONFIGURATION { int mouse_acceleration; bool enable_ref_frame_invalidation; FILE *log_file; + bool jp_layout; + // runtime configuration, value will be recreated at launch + SceCtrlButtons btn_confirm; + SceCtrlButtons btn_cancel; } CONFIGURATION, *PCONFIGURATION; extern CONFIGURATION config; @@ -74,3 +81,4 @@ bool inputAdded; bool config_file_parse(char* filename, PCONFIGURATION config); void config_parse(int argc, char* argv[], PCONFIGURATION config); void config_save(const char* filename, PCONFIGURATION config); +void update_layout(); diff --git a/src/gui/guilib.c b/src/gui/guilib.c index 9b91cb96..d079c6cc 100644 --- a/src/gui/guilib.c +++ b/src/gui/guilib.c @@ -1,5 +1,6 @@ #include "guilib.h" +#include "../config.h" #include "../platform.h" #include @@ -259,7 +260,9 @@ void draw_alert(char *message, menu_geom geom, char *buttons_captions[], int but char caption[256]; strcpy(caption, ""); - char *icons[4] = {"x", "◯", "△", "□"}; + char *o_layout[4] = {"◯", "x", "△", "□"}; + char *x_layout[4] = {"x", "◯", "△", "□"}; + char **icons = config.jp_layout ? o_layout : x_layout; char *default_captions[4] = {"Ok", "Cancel", "Options", "Delete"}; for (int i = 0; i < buttons_count; i++) { char single_button_caption[64]; @@ -400,7 +403,7 @@ int display_menu(menu_entry menu[], int total_elements, menu_geom *geom_ptr, gui_global_loop_callback(menu[real_cursor].id, context, &input); } - if (input.buttons & SCE_CTRL_CIRCLE && (input.buttons & SCE_CTRL_HOLD) == 0) { + if (input.buttons & config.btn_cancel && (input.buttons & SCE_CTRL_HOLD) == 0) { if (!back_cb || back_cb(context) == 0) { exit_code = 1; goto error; diff --git a/src/gui/ui.c b/src/gui/ui.c index cbc3e18f..584f6857 100644 --- a/src/gui/ui.c +++ b/src/gui/ui.c @@ -36,7 +36,7 @@ enum { }; int ui_main_menu_loop(int cursor, void *context, const input_data *input) { - if ((input->buttons & SCE_CTRL_CROSS) == 0 || (input->buttons & SCE_CTRL_HOLD) != 0) { + if ((input->buttons & config.btn_confirm) == 0 || (input->buttons & SCE_CTRL_HOLD) != 0) { return 0; } if (cursor >= MAIN_MENU_CONNECT_PAIRED && cursor < MAIN_MENU_QUIT) { diff --git a/src/gui/ui_connect.c b/src/gui/ui_connect.c index 07042b8f..d6c2a2b4 100644 --- a/src/gui/ui_connect.c +++ b/src/gui/ui_connect.c @@ -134,7 +134,7 @@ int ui_connect_loop(int id, void *context, const input_data *input) { menu[i].disabled = (server.currentGame != 0); } - if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { return 0; } diff --git a/src/gui/ui_device.c b/src/gui/ui_device.c index e67284de..a5c80ffd 100644 --- a/src/gui/ui_device.c +++ b/src/gui/ui_device.c @@ -189,7 +189,7 @@ int end_search_thread(SceUID thid) { } static int ui_search_device_callback(int id, void *context, const input_data *input) { - if ((input->buttons & SCE_CTRL_CROSS) == 0 || (input->buttons & SCE_CTRL_HOLD) != 0) { + if ((input->buttons & config.btn_confirm) == 0 || (input->buttons & SCE_CTRL_HOLD) != 0) { // if remain slot, reload discovered devices if (!DEVICE_ENTRY_IDX[DEVICE_VIEW_ITEM + found_device - 1]) { return 2; diff --git a/src/gui/ui_settings.c b/src/gui/ui_settings.c index dd03f5ab..28ab8af7 100644 --- a/src/gui/ui_settings.c +++ b/src/gui/ui_settings.c @@ -214,7 +214,7 @@ enum { static int select_special_key_loop(int id, void *context, const input_data *input) { int *code = context; - if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { return 0; } if (id != SETTINGS_SELECT_SPECIAL_KEY_MANUAL) { @@ -274,7 +274,7 @@ static int special_keys_loop(int id, void *context, const input_data *input) { config.special_keys.size += delta; break; default: - if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { break; } select_special_key_menu(&selected_ord); @@ -381,6 +381,7 @@ enum { SETTINGS_ENABLE_STREAM_OPTIMIZE, SETTINGS_SAVE_DEBUG_LOG, SETTINGS_DISABLE_POWERSAVE, + SETTINGS_JP_LAYOUT, SETTINGS_ENABLE_FRAME_PACER, SETTINGS_ENABLE_MAPPING, SETTINGS_BACK_DEADZONE, @@ -397,6 +398,7 @@ enum { SETTINGS_VIEW_ENABLE_STREAM_OPTIMIZE, SETTINGS_VIEW_SAVE_DEBUG_LOG, SETTINGS_VIEW_DISABLE_POWERSAVE, + SETTINGS_VIEW_JP_LAYOUT, SETTINGS_VIEW_ENABLE_FRAME_PACER, SETTINGS_VIEW_ENABLE_MAPPING, SETTINGS_VIEW_BACK_DEADZONE, @@ -468,7 +470,7 @@ static int settings_loop(int id, void *context, const input_data *input) { did_change = 1; break; case SETTINGS_BITRATE: - if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { break; } char value[512]; @@ -484,49 +486,56 @@ static int settings_loop(int id, void *context, const input_data *input) { } break; case SETTINGS_SOPS: - if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { break; } did_change = 1; config.sops = !config.sops; break; case SETTINGS_ENABLE_FRAME_INVAL: - if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { break; } did_change = 1; config.enable_ref_frame_invalidation = !config.enable_ref_frame_invalidation; break; case SETTINGS_ENABLE_STREAM_OPTIMIZE: - if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { break; } did_change = 1; config.stream.streamingRemotely = config.stream.streamingRemotely ? 0 : 1; break; case SETTINGS_SAVE_DEBUG_LOG: - if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { break; } did_change = 1; config.save_debug_log = !config.save_debug_log; break; case SETTINGS_DISABLE_POWERSAVE: - if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { break; } did_change = 1; config.disable_powersave = !config.disable_powersave; break; + case SETTINGS_JP_LAYOUT: + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { + break; + } + did_change = 1; + config.jp_layout = !config.jp_layout; + break; case SETTINGS_ENABLE_FRAME_PACER: - if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { break; } did_change = 1; config.enable_frame_pacer = !config.enable_frame_pacer; break; case SETTINGS_ENABLE_MAPPING: - if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { break; } did_change = 1; @@ -538,14 +547,14 @@ static int settings_loop(int id, void *context, const input_data *input) { } break; case SETTINGS_BACK_DEADZONE: - if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { break; } deadzone_settings_menu(); did_change = 1; break; case SETTINGS_SPECIAL_KEYS: - if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { break; } special_keys_menu(); @@ -602,6 +611,9 @@ static int settings_loop(int id, void *context, const input_data *input) { sprintf(current, "%s", config.disable_powersave ? "yes" : "no"); MENU_REPLACE(SETTINGS_VIEW_DISABLE_POWERSAVE, current); + sprintf(current, "%s", config.jp_layout ? "yes" : "no"); + MENU_REPLACE(SETTINGS_VIEW_JP_LAYOUT, current); + sprintf(current, "%s", config.enable_frame_pacer ? "yes" : "no"); MENU_REPLACE(SETTINGS_VIEW_ENABLE_FRAME_PACER, current); @@ -625,6 +637,7 @@ static int settings_loop(int id, void *context, const input_data *input) { static int settings_back(void *context) { ui_settings_save_config(); + update_layout(); return 0; } @@ -660,6 +673,7 @@ int ui_settings_menu() { MENU_CATEGORY("System"); MENU_ENTRY(SETTINGS_SAVE_DEBUG_LOG, SETTINGS_VIEW_SAVE_DEBUG_LOG, "Enable debug log", ""); MENU_ENTRY(SETTINGS_DISABLE_POWERSAVE, SETTINGS_VIEW_DISABLE_POWERSAVE, "Disable power save", ""); + MENU_ENTRY(SETTINGS_JP_LAYOUT, SETTINGS_VIEW_JP_LAYOUT, "Swap X & O for Moonlight", ""); MENU_CATEGORY("Input"); MENU_ENTRY(SETTINGS_MOUSE_ACCEL, SETTINGS_VIEW_MOUSE_ACCEL, "Mouse acceleration", ICON_LEFT_RIGHT_ARROWS); From aaaa687da7c9a095a893ee415275b22e0570d1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E7=80=AC=E7=B4=85=E8=8E=89=E6=A0=96?= Date: Sun, 26 Apr 2020 18:50:53 -0500 Subject: [PATCH 03/12] =?UTF-8?q?Change=20=E2=97=AF=20to=20o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default font cannot display ◯. Currently every call to draw_alert will have buttons_count either 0 or 1. Thus we can leave the other 2 alone for now. --- src/gui/guilib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/guilib.c b/src/gui/guilib.c index d079c6cc..63e9e107 100644 --- a/src/gui/guilib.c +++ b/src/gui/guilib.c @@ -260,8 +260,8 @@ void draw_alert(char *message, menu_geom geom, char *buttons_captions[], int but char caption[256]; strcpy(caption, ""); - char *o_layout[4] = {"◯", "x", "△", "□"}; - char *x_layout[4] = {"x", "◯", "△", "□"}; + char *o_layout[4] = {"o", "x", "△", "□"}; + char *x_layout[4] = {"x", "o", "△", "□"}; char **icons = config.jp_layout ? o_layout : x_layout; char *default_captions[4] = {"Ok", "Cancel", "Options", "Delete"}; for (int i = 0; i < buttons_count; i++) { From d48f28cd4bb77e4e52eb71e6fdb106eb95748094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E7=80=AC=E7=B4=85=E8=8E=89=E6=A0=96?= Date: Sun, 26 Apr 2020 18:56:59 -0500 Subject: [PATCH 04/12] Fix display_alert exit --- src/gui/guilib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/guilib.c b/src/gui/guilib.c index 63e9e107..4ec1804b 100644 --- a/src/gui/guilib.c +++ b/src/gui/guilib.c @@ -442,9 +442,9 @@ void display_alert(char *message, char *button_captions[], int buttons_count, continue; } - if (input.buttons & SCE_CTRL_CROSS) { + if (input.buttons & config.btn_confirm) { result = 0; - } else if (input.buttons & SCE_CTRL_CIRCLE) { + } else if (input.buttons & config.btn_cancel) { result = 1; } else if (input.buttons & SCE_CTRL_TRIANGLE) { result = 2; From 7f00c581792eba6cdf2c10250887c9498828bbad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E7=80=AC=E7=B4=85=E8=8E=89=E6=A0=96?= Date: Sun, 26 Apr 2020 19:03:11 -0500 Subject: [PATCH 05/12] Improve readability --- src/video/vita.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/vita.c b/src/video/vita.c index bc58e66a..fe89c650 100644 --- a/src/video/vita.c +++ b/src/video/vita.c @@ -410,7 +410,7 @@ static int vita_submit_decode_unit(PDECODE_UNIT decodeUnit) { void *tex_buf = vita2d_texture_get_datap(frame_texture); vita2d_draw_texture(frame_texture, 0, 0); if (config.show_fps) { - vita2d_font_draw_textf(font, 20, 40, RGBA8(0xFF, 0xFF, 0xFF, 0xFF), 12, "fps: %u / %u", curr_fps[0], curr_fps[1]); + vita2d_font_draw_textf(font, 20, 40, RGBA8(0xFF, 0xFF, 0xFF, 0xFF), 14, "fps: %u / %u", curr_fps[0], curr_fps[1]); } draw_indicators(); vita2d_end_drawing(); From feed4c2e85ba61f1dd706684b2065965e58836e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E7=80=AC=E7=B4=85=E8=8E=89=E6=A0=96?= Date: Sun, 26 Apr 2020 19:05:15 -0500 Subject: [PATCH 06/12] Clarify the option ... that it's only about the streaming fps, not the host fps --- src/gui/ui_settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/ui_settings.c b/src/gui/ui_settings.c index 660ec428..28c7c890 100644 --- a/src/gui/ui_settings.c +++ b/src/gui/ui_settings.c @@ -672,7 +672,7 @@ int ui_settings_menu() { MENU_CATEGORY("System"); MENU_ENTRY(SETTINGS_SAVE_DEBUG_LOG, SETTINGS_VIEW_SAVE_DEBUG_LOG, "Enable debug log", ""); MENU_ENTRY(SETTINGS_DISABLE_POWERSAVE, SETTINGS_VIEW_DISABLE_POWERSAVE, "Disable power save", ""); - MENU_ENTRY(SETTINGS_SHOW_FPS, SETTINGS_VIEW_SHOW_FPS, "Show FPS", ""); + MENU_ENTRY(SETTINGS_SHOW_FPS, SETTINGS_VIEW_SHOW_FPS, "Display streaming FPS", ""); MENU_CATEGORY("Input"); MENU_ENTRY(SETTINGS_MOUSE_ACCEL, SETTINGS_VIEW_MOUSE_ACCEL, "Mouse acceleration", ICON_LEFT_RIGHT_ARROWS); From 298707a7146a3e85344eeb5c5923d2139c259b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E7=80=AC=E7=B4=85=E8=8E=89=E6=A0=96?= Date: Sun, 26 Apr 2020 20:18:49 -0500 Subject: [PATCH 07/12] Remove unused define --- src/video/vita.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/video/vita.c b/src/video/vita.c index fe89c650..88dd2610 100644 --- a/src/video/vita.c +++ b/src/video/vita.c @@ -39,7 +39,6 @@ #if 0 #define printf vita_debug_log -#define DRAW_FPS 1 #endif void draw_indicators(); From 1b4dcbcda9fba2d2ea356b8ac49d43496860df97 Mon Sep 17 00:00:00 2001 From: Yuntian Zhang Date: Mon, 27 Apr 2020 08:21:44 -0500 Subject: [PATCH 08/12] Fix conflicts --- src/config.c | 4 ++++ src/config.h | 1 + src/gui/ui_settings.c | 13 +++++++++++++ src/video/vita.c | 6 +++--- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/config.c b/src/config.c index 5be8a010..61061a2e 100644 --- a/src/config.c +++ b/src/config.c @@ -102,6 +102,8 @@ static int ini_handle(void *out, const char *section, const char *name, config->disable_powersave = BOOL(value); } else if (strcmp(name, "jp_layout") == 0) { config->jp_layout = BOOL(value); + } else if (strcmp(name, "show_fps") == 0) { + config->show_fps = BOOL(value); } else if (strcmp(name, "save_debug_log") == 0) { config->save_debug_log = BOOL(value); } else if (strcmp(name, "mapping") == 0) { @@ -154,6 +156,7 @@ void config_save(const char* filename, PCONFIGURATION config) { write_config_bool(fd, "enable_frame_pacer", config->enable_frame_pacer); write_config_bool(fd, "disable_powersave", config->disable_powersave); write_config_bool(fd, "jp_layout", config->jp_layout); + write_config_bool(fd, "show_fps", config->show_fps); write_config_bool(fd, "save_debug_log", config->save_debug_log); write_config_int(fd, "mouse_acceleration", config->mouse_acceleration); @@ -213,6 +216,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) { config->save_debug_log = false; config->disable_powersave = true; config->jp_layout = false; + config->show_fps = false; config->enable_frame_pacer = true; config->special_keys.nw = INPUT_SPECIAL_KEY_PAUSE | INPUT_TYPE_SPECIAL; diff --git a/src/config.h b/src/config.h index ac11ad99..c5b06b7c 100644 --- a/src/config.h +++ b/src/config.h @@ -60,6 +60,7 @@ typedef struct _CONFIGURATION { struct touchscreen_deadzone back_deadzone; struct special_keys special_keys; bool disable_powersave; + bool show_fps; bool enable_frame_pacer; bool save_debug_log; struct input_config inputs[MAX_INPUTS]; diff --git a/src/gui/ui_settings.c b/src/gui/ui_settings.c index 28ab8af7..6b9d9bcb 100644 --- a/src/gui/ui_settings.c +++ b/src/gui/ui_settings.c @@ -382,6 +382,7 @@ enum { SETTINGS_SAVE_DEBUG_LOG, SETTINGS_DISABLE_POWERSAVE, SETTINGS_JP_LAYOUT, + SETTINGS_SHOW_FPS, SETTINGS_ENABLE_FRAME_PACER, SETTINGS_ENABLE_MAPPING, SETTINGS_BACK_DEADZONE, @@ -399,6 +400,7 @@ enum { SETTINGS_VIEW_SAVE_DEBUG_LOG, SETTINGS_VIEW_DISABLE_POWERSAVE, SETTINGS_VIEW_JP_LAYOUT, + SETTINGS_VIEW_SHOW_FPS, SETTINGS_VIEW_ENABLE_FRAME_PACER, SETTINGS_VIEW_ENABLE_MAPPING, SETTINGS_VIEW_BACK_DEADZONE, @@ -527,6 +529,13 @@ static int settings_loop(int id, void *context, const input_data *input) { did_change = 1; config.jp_layout = !config.jp_layout; break; + case SETTINGS_SHOW_FPS: + if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + break; + } + did_change = 1; + config.show_fps = !config.show_fps; + break; case SETTINGS_ENABLE_FRAME_PACER: if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { break; @@ -614,6 +623,9 @@ static int settings_loop(int id, void *context, const input_data *input) { sprintf(current, "%s", config.jp_layout ? "yes" : "no"); MENU_REPLACE(SETTINGS_VIEW_JP_LAYOUT, current); + sprintf(current, "%s", config.show_fps ? "yes" : "no"); + MENU_REPLACE(SETTINGS_VIEW_SHOW_FPS, current); + sprintf(current, "%s", config.enable_frame_pacer ? "yes" : "no"); MENU_REPLACE(SETTINGS_VIEW_ENABLE_FRAME_PACER, current); @@ -674,6 +686,7 @@ int ui_settings_menu() { MENU_ENTRY(SETTINGS_SAVE_DEBUG_LOG, SETTINGS_VIEW_SAVE_DEBUG_LOG, "Enable debug log", ""); MENU_ENTRY(SETTINGS_DISABLE_POWERSAVE, SETTINGS_VIEW_DISABLE_POWERSAVE, "Disable power save", ""); MENU_ENTRY(SETTINGS_JP_LAYOUT, SETTINGS_VIEW_JP_LAYOUT, "Swap X & O for Moonlight", ""); + MENU_ENTRY(SETTINGS_SHOW_FPS, SETTINGS_VIEW_SHOW_FPS, "Show FPS", ""); MENU_CATEGORY("Input"); MENU_ENTRY(SETTINGS_MOUSE_ACCEL, SETTINGS_VIEW_MOUSE_ACCEL, "Mouse acceleration", ICON_LEFT_RIGHT_ARROWS); diff --git a/src/video/vita.c b/src/video/vita.c index e50825ec..bc58e66a 100644 --- a/src/video/vita.c +++ b/src/video/vita.c @@ -409,9 +409,9 @@ static int vita_submit_decode_unit(PDECODE_UNIT decodeUnit) { vita2d_start_drawing(); void *tex_buf = vita2d_texture_get_datap(frame_texture); vita2d_draw_texture(frame_texture, 0, 0); -#ifdef DRAW_FPS - vita2d_font_draw_textf(font, 20, 40, RGBA8(0xFF, 0xFF, 0xFF, 0xFF), 12, "fps: %u / %u", curr_fps[0], curr_fps[1]); -#endif + if (config.show_fps) { + vita2d_font_draw_textf(font, 20, 40, RGBA8(0xFF, 0xFF, 0xFF, 0xFF), 12, "fps: %u / %u", curr_fps[0], curr_fps[1]); + } draw_indicators(); vita2d_end_drawing(); vita2d_wait_rendering_done(); From e310c2100663a5eb210559af97d1714b2568d64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E7=80=AC=E7=B4=85=E8=8E=89=E6=A0=96?= Date: Sun, 26 Apr 2020 19:03:11 -0500 Subject: [PATCH 09/12] Improve readability --- src/video/vita.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/vita.c b/src/video/vita.c index bc58e66a..fe89c650 100644 --- a/src/video/vita.c +++ b/src/video/vita.c @@ -410,7 +410,7 @@ static int vita_submit_decode_unit(PDECODE_UNIT decodeUnit) { void *tex_buf = vita2d_texture_get_datap(frame_texture); vita2d_draw_texture(frame_texture, 0, 0); if (config.show_fps) { - vita2d_font_draw_textf(font, 20, 40, RGBA8(0xFF, 0xFF, 0xFF, 0xFF), 12, "fps: %u / %u", curr_fps[0], curr_fps[1]); + vita2d_font_draw_textf(font, 20, 40, RGBA8(0xFF, 0xFF, 0xFF, 0xFF), 14, "fps: %u / %u", curr_fps[0], curr_fps[1]); } draw_indicators(); vita2d_end_drawing(); From 43ac98b8a56041d3cfc65cb2c05d01fbb7d48193 Mon Sep 17 00:00:00 2001 From: Yuntian Zhang Date: Mon, 27 Apr 2020 08:22:43 -0500 Subject: [PATCH 10/12] More conflict --- src/gui/ui_settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/ui_settings.c b/src/gui/ui_settings.c index 6b9d9bcb..3ecd18db 100644 --- a/src/gui/ui_settings.c +++ b/src/gui/ui_settings.c @@ -686,7 +686,7 @@ int ui_settings_menu() { MENU_ENTRY(SETTINGS_SAVE_DEBUG_LOG, SETTINGS_VIEW_SAVE_DEBUG_LOG, "Enable debug log", ""); MENU_ENTRY(SETTINGS_DISABLE_POWERSAVE, SETTINGS_VIEW_DISABLE_POWERSAVE, "Disable power save", ""); MENU_ENTRY(SETTINGS_JP_LAYOUT, SETTINGS_VIEW_JP_LAYOUT, "Swap X & O for Moonlight", ""); - MENU_ENTRY(SETTINGS_SHOW_FPS, SETTINGS_VIEW_SHOW_FPS, "Show FPS", ""); + MENU_ENTRY(SETTINGS_SHOW_FPS, SETTINGS_VIEW_SHOW_FPS, "Display streaming FPS", ""); MENU_CATEGORY("Input"); MENU_ENTRY(SETTINGS_MOUSE_ACCEL, SETTINGS_VIEW_MOUSE_ACCEL, "Mouse acceleration", ICON_LEFT_RIGHT_ARROWS); From e0365cc8f61ccf29078fc2b04f97f5f0c41c97b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E7=80=AC=E7=B4=85=E8=8E=89=E6=A0=96?= Date: Sun, 26 Apr 2020 20:18:49 -0500 Subject: [PATCH 11/12] Remove unused define --- src/video/vita.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/video/vita.c b/src/video/vita.c index fe89c650..88dd2610 100644 --- a/src/video/vita.c +++ b/src/video/vita.c @@ -39,7 +39,6 @@ #if 0 #define printf vita_debug_log -#define DRAW_FPS 1 #endif void draw_indicators(); From c41879d9c9e856e0a1bf72d7aa9c3fddaed1bf34 Mon Sep 17 00:00:00 2001 From: Yuntian Zhang Date: Mon, 27 Apr 2020 08:33:10 -0500 Subject: [PATCH 12/12] Some final touches --- src/config.h | 2 +- src/gui/ui_settings.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config.h b/src/config.h index c5b06b7c..477aba2b 100644 --- a/src/config.h +++ b/src/config.h @@ -60,6 +60,7 @@ typedef struct _CONFIGURATION { struct touchscreen_deadzone back_deadzone; struct special_keys special_keys; bool disable_powersave; + bool jp_layout; bool show_fps; bool enable_frame_pacer; bool save_debug_log; @@ -68,7 +69,6 @@ typedef struct _CONFIGURATION { int mouse_acceleration; bool enable_ref_frame_invalidation; FILE *log_file; - bool jp_layout; // runtime configuration, value will be recreated at launch SceCtrlButtons btn_confirm; SceCtrlButtons btn_cancel; diff --git a/src/gui/ui_settings.c b/src/gui/ui_settings.c index 3ecd18db..b5a92dd4 100644 --- a/src/gui/ui_settings.c +++ b/src/gui/ui_settings.c @@ -530,7 +530,7 @@ static int settings_loop(int id, void *context, const input_data *input) { config.jp_layout = !config.jp_layout; break; case SETTINGS_SHOW_FPS: - if ((input->buttons & SCE_CTRL_CROSS) == 0 || input->buttons & SCE_CTRL_HOLD) { + if ((input->buttons & config.btn_confirm) == 0 || input->buttons & SCE_CTRL_HOLD) { break; } did_change = 1;