diff --git a/command.c b/command.c index 37278c4eac..8e3dcff168 100755 --- a/command.c +++ b/command.c @@ -242,7 +242,7 @@ static const struct cmd_map map[] = { { "MENU_RIGHT", RETRO_DEVICE_ID_JOYPAD_RIGHT }, { "MENU_A", RETRO_DEVICE_ID_JOYPAD_A }, { "MENU_B", RETRO_DEVICE_ID_JOYPAD_B }, - { "MENU_B", RETRO_DEVICE_ID_JOYPAD_B }, + { "AI_SERVICE", RARCH_AI_SERVICE }, }; #endif @@ -1767,8 +1767,34 @@ bool command_event(enum event_command cmd, void *data) bsv_movie_check(); break; case CMD_EVENT_AI_SERVICE_TOGGLE: - /* TODO/FIXME - implement */ + { + settings_t *settings = config_get_ptr(); +#ifdef HAVE_TRANSLATE + if (settings->uints.ai_service_mode == 0) + { + /* Default mode - pause on call, unpause on second press. */ + if (!rarch_ctl(RARCH_CTL_IS_PAUSED, NULL)) + { + command_event(CMD_EVENT_PAUSE, NULL); + command_event(CMD_EVENT_AI_SERVICE_CALL, NULL); + } + else + { + command_event(CMD_EVENT_UNPAUSE, NULL); + } + } + else if (settings->uints.ai_service_mode == 1) + { + /* Text-to-Speech mode - don't pause */ + command_event(CMD_EVENT_AI_SERVICE_CALL, NULL); + } + else + { + RARCH_LOG("Invalid AI Service Mode.\n"); + } +#endif break; + } case CMD_EVENT_STREAMING_TOGGLE: if (streaming_is_enabled()) command_event(CMD_EVENT_RECORD_DEINIT, NULL); @@ -2524,7 +2550,6 @@ TODO: Add a setting for these tweaks */ bool is_idle = false; bool is_slowmotion = false; bool is_perfcnt_enable = false; - settings_t *settings = config_get_ptr(); #ifdef HAVE_DISCORD discord_userdata_t userdata; @@ -2548,22 +2573,6 @@ TODO: Add a setting for these tweaks */ if (!is_idle) video_driver_cached_frame(); - /* If OCR enabled, translate the screen while paused */ - if (settings->bools.translation_service_enable) - { -#ifdef HAVE_TRANSLATE - if (!g_translation_service_status) - { - RARCH_LOG("OCR START\n"); - run_translation_service(); - g_translation_service_status = true; - } -#else - RARCH_LOG("OCR Translation not enabled in build. Include HAVE_TRANSLATE define.\n"); -#endif - } - - #ifdef HAVE_DISCORD userdata.status = DISCORD_PRESENCE_GAME_PAUSED; command_event(CMD_EVENT_DISCORD_UPDATE, &userdata); @@ -2573,9 +2582,6 @@ TODO: Add a setting for these tweaks */ { #if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) menu_widgets_set_paused(is_paused); -#endif -#ifdef HAVE_TRANSLATE - g_translation_service_status = false; #endif RARCH_LOG("%s\n", msg_hash_to_str(MSG_UNPAUSED)); command_event(CMD_EVENT_AUDIO_START, NULL); @@ -3094,6 +3100,14 @@ TODO: Add a setting for these tweaks */ } #endif break; + + case CMD_EVENT_AI_SERVICE_CALL: + { +#ifdef HAVE_TRANSLATE + RARCH_LOG("AI Service Called...\n"); + run_translation_service(); +#endif + } case CMD_EVENT_NONE: return false; } diff --git a/command.h b/command.h index 2889e9ef14..d53f6ba747 100644 --- a/command.h +++ b/command.h @@ -255,7 +255,8 @@ enum event_command CMD_EVENT_SHADER_PREV, CMD_EVENT_CHEAT_INDEX_PLUS, CMD_EVENT_CHEAT_INDEX_MINUS, - CMD_EVENT_CHEAT_TOGGLE + CMD_EVENT_CHEAT_TOGGLE, + CMD_EVENT_AI_SERVICE_CALL }; bool command_set_shader(const char *arg); diff --git a/config.def.h b/config.def.h index f4485acabb..37e17b936c 100644 --- a/config.def.h +++ b/config.def.h @@ -457,8 +457,6 @@ static bool menu_swap_ok_cancel_buttons = false; static bool quit_press_twice = false; -static bool default_translation_service_enable = false; - static bool default_log_to_file = false; static bool log_to_file_timestamp = false; @@ -982,6 +980,6 @@ static char buildbot_assets_server_url[] = "http://buildbot.libretro.com/assets/ static char default_discord_app_id[] = "475456035851599874"; -static char default_translation_service_url[] = "http://localhost:4404/"; +static char default_ai_service_url[] = "http://localhost:4404/"; #endif diff --git a/config.def.keybinds.h b/config.def.keybinds.h index 29c72a5a52..9236851963 100644 --- a/config.def.keybinds.h +++ b/config.def.keybinds.h @@ -104,6 +104,7 @@ static const struct retro_keybind retro_keybinds_1[] = { { true, RARCH_MENU_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE, RETROK_SPACE, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_RECORDING_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_RECORDING_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_STREAMING_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_STREAMING_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_AI_SERVICE, MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, #else { true, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_z, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_a, NO_BTN, NO_BTN, 0, AXIS_NONE }, @@ -185,6 +186,8 @@ static const struct retro_keybind retro_keybinds_1[] = { { true, RARCH_MENU_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE, RETROK_F1, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_RECORDING_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_RECORDING_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_STREAMING_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_STREAMING_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_AI_SERVICE, MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + #endif }; diff --git a/configuration.c b/configuration.c index 612d65d41e..1cdd385049 100644 --- a/configuration.c +++ b/configuration.c @@ -1167,8 +1167,7 @@ static struct config_array_setting *populate_settings_array(settings_t *settings SETTING_ARRAY("youtube_stream_key", settings->arrays.youtube_stream_key, true, NULL, true); SETTING_ARRAY("twitch_stream_key", settings->arrays.twitch_stream_key, true, NULL, true); SETTING_ARRAY("discord_app_id", settings->arrays.discord_app_id, true, default_discord_app_id, true); - SETTING_ARRAY("translation_service_url", settings->arrays.translation_service_url, true, default_translation_service_url, true); - SETTING_ARRAY("ai_service_url", settings->arrays.ai_service_url, true, "", true); + SETTING_ARRAY("ai_service_url", settings->arrays.ai_service_url, true, default_ai_service_url, true); *size = count; @@ -1616,8 +1615,6 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, #ifdef HAVE_OZONE SETTING_BOOL("ozone_collapse_sidebar", &settings->bools.ozone_collapse_sidebar, true, DEFAULT_OZONE_COLLAPSE_SIDEBAR, false); #endif - SETTING_BOOL("translation_service_enable", &settings->bools.translation_service_enable, true, default_translation_service_enable, false); - SETTING_BOOL("log_to_file", &settings->bools.log_to_file, true, default_log_to_file, false); SETTING_OVERRIDE(RARCH_OVERRIDE_SETTING_LOG_TO_FILE); SETTING_BOOL("log_to_file_timestamp", &settings->bools.log_to_file_timestamp, true, log_to_file_timestamp, false); @@ -2022,8 +2019,8 @@ void config_set_defaults(void) strlcpy(settings->arrays.discord_app_id, default_discord_app_id, sizeof(settings->arrays.discord_app_id)); - strlcpy(settings->arrays.translation_service_url, - default_translation_service_url, sizeof(settings->arrays.translation_service_url)); + strlcpy(settings->arrays.ai_service_url, + default_ai_service_url, sizeof(settings->arrays.ai_service_url)); #ifdef HAVE_MATERIALUI diff --git a/configuration.h b/configuration.h index 82316b5c92..f4f5611f42 100644 --- a/configuration.h +++ b/configuration.h @@ -334,9 +334,6 @@ typedef struct settings bool enable_device_vibration; bool ozone_collapse_sidebar; - - bool translation_service_enable; - bool log_to_file; bool log_to_file_timestamp; diff --git a/retroarch.c b/retroarch.c index 2ab186fcfa..22ac73448f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2215,7 +2215,7 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { #endif DECLARE_META_BIND(2, recording_toggle, RARCH_RECORDING_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_RECORDING_TOGGLE), DECLARE_META_BIND(2, streaming_toggle, RARCH_STREAMING_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_STREAMING_TOGGLE), - DECLARE_META_BIND(2, streaming_toggle, RARCH_AI_SERVICE, MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE), + DECLARE_META_BIND(2, ai_service, RARCH_AI_SERVICE, MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE), }; typedef struct turbo_buttons turbo_buttons_t; @@ -16900,7 +16900,6 @@ void rarch_force_video_driver_fallback(const char *driver) free(title); } - exit(1); } diff --git a/translation/translation_service.c b/translation/translation_service.c index 0575f793f4..4fcd3d082b 100644 --- a/translation/translation_service.c +++ b/translation/translation_service.c @@ -7,12 +7,28 @@ #include "gfx/video_frame.h" #include "gfx/scaler/scaler.h" #include "tasks/tasks_internal.h" +#include