Skip to content

Commit

Permalink
Merge branch 'master' into linux_sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
oshaboy authored Feb 22, 2024
2 parents 2ab1ef5 + 6de0fd4 commit c218c60
Show file tree
Hide file tree
Showing 103 changed files with 3,592 additions and 1,336 deletions.
51 changes: 30 additions & 21 deletions accessibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ typedef struct
{
/* The last request task, used to prepare and send the translation */
retro_task_t *request_task;

/* The last response task, used to parse costly translation data */
retro_task_t *response_task;

/* Timestamp of the last translation request */
retro_time_t last_call;

Expand All @@ -59,7 +59,7 @@ typedef struct

/* 1 if the automatic mode has been enabled, 0 otherwise */
int ai_service_auto;

/* Text-to-speech narrator override flag */
bool enabled;
} access_state_t;
Expand All @@ -71,26 +71,26 @@ bool is_narrator_running(bool accessibility_enable);
#endif

/*
Invoke this method to send a request to the AI service.
Invoke this method to send a request to the AI service.
It makes the following POST request using URL params:
– source_lang (optional): language code of the content currently running.
– target_lang (optional): language of the content to return.
– output: comma-separated list of formats that must be provided by the
service. Also lists supported sub-formats.
The currently supported formats are:
– sound: raw audio to playback. (wav)
– text: text to be read through internal text-to-speech capabilities.
'subs' can be specified on top of that to explain that we are looking
for short text response in the manner of subtitles.
– image: image to display on top of the video feed. Widgets will be used
first if possible, otherwise we'll try to draw it directly on the
first if possible, otherwise we'll try to draw it directly on the
video buffer. (bmp, png, png-a) [All in 24-bits BGR formats]
In addition, the request contains a JSON payload, formatted as such:
– image: captured frame from the currently running content (in base64).
– format: format of the captured frame ("png", or "bmp").
– coords: array describing the coordinates of the image within the
– coords: array describing the coordinates of the image within the
viewport space (x, y, width, height).
– viewport: array describing the size of the viewport (width, height).
– label: a text string describing the content (<system id>__<content id>).
Expand All @@ -99,7 +99,7 @@ bool is_narrator_running(bool accessibility_enable);
– <key>: the name of a retropad input, valued 1 if pressed.
(a, b, x, y, l, r, l2, r2, l3, r3)
(up, down, left, right, start, select)
The translation component then expects a response from the AI service in the
form of a JSON payload, formatted as such:
– image: base64 representation of an image in a supported format.
Expand All @@ -108,40 +108,49 @@ bool is_narrator_running(bool accessibility_enable);
– text_position: hint for the position of the text when the service is
running in text mode (ie subtitles). Position is a number,
1 for Bottom or 2 for Top (defaults to bottom).
– press: a list of retropad input to forcibly press. On top of the
– press: a list of retropad input to forcibly press. On top of the
expected keys (cf. 'state' above) values 'pause' and 'unpause' can be
specified to control the flow of the content.
– error: any error encountered with the request.
– auto: either 'auto' or 'continue' to control automatic requests.
All fields are optional, but at least one of them must be present.
If 'error' is set, the error is shown to the user and everything else is
ignored, even 'auto' settings.
With 'auto' on 'auto', RetroArch will automatically send a new request
(with a minimum delay enforced by uints.ai_service_poll_delay), with a value
of 'continue', RetroArch will ignore the returned content and skip to the
of 'continue', RetroArch will ignore the returned content and skip to the
next automatic request. This allows the service to specify that the returned
content is the same as the one previously sent, so RetroArch does not need to
update its display unless necessary. With 'continue' the service *must*
still send the content, as we may need to display it if the user paused the
update its display unless necessary. With 'continue' the service *must*
still send the content, as we may need to display it if the user paused the
AI service for instance.
{paused} boolean is passed in to indicate if the current call was made
during a paused frame. Due to how the menu widgets work, if the AI service
is called in 'auto' mode, then this call will be made while the menu widgets
{paused} boolean is passed in to indicate if the current call was made
during a paused frame. Due to how the menu widgets work, if the AI service
is called in 'auto' mode, then this call will be made while the menu widgets
unpause the core for a frame to update the on-screen widgets. To tell the AI
service what the pause mode is honestly, we store the runloop_paused
service what the pause mode is honestly, we store the runloop_paused
variable from before the service wipes the widgets, and pass that in here.
*/
bool run_translation_service(settings_t *settings, bool paused);

void translation_release(bool inform);

bool accessibility_speak_priority(
/* Proxy for calls related to menu navigation */
bool navigation_say(
bool accessibility_enable,
unsigned accessibility_narrator_speech_speed,
const char* speak_text, int priority);
const char* speak_text,
int priority);

/* Local platform-specific TTS */
bool accessibility_speak_priority(
unsigned accessibility_narrator_speech_speed,
const char *speak_text,
int priority,
const char* voice);

access_state_t *access_state_get_ptr(void);

Expand Down
16 changes: 15 additions & 1 deletion cheevos/cheevos.c
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@ void rcheevos_validate_config_settings(void)
}

/* this causes N blank frames to be rendered between real frames, thus
* slowing down the actual number of rendered frames per second. */
* can slow down the actual number of rendered frames per second. */
if (settings->uints.video_black_frame_insertion > 0) {
const char* error = "Hardcore paused. Black frame insertion not allowed.";
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", error);
Expand All @@ -1726,6 +1726,20 @@ void rcheevos_validate_config_settings(void)
return;
}

/* this causes N dupe frames to be rendered between real frames, for
the purposes of shaders that update faster than content. Thus
* can slow down the actual number of rendered frames per second. */
if (settings->uints.video_shader_subframes > 1) {
const char* error = "Hardcore paused. Shader subframes not allowed.";
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", error);
rcheevos_pause_hardcore();

runloop_msg_queue_push(error, 0, 4 * 60, false, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_WARNING);
return;
}


if (!(disallowed_settings
= rc_libretro_get_disallowed_settings(sysinfo->library_name)))
return;
Expand Down
8 changes: 8 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,13 @@
/* Try to sleep the spare time after frame is presented in order to reduce vsync CPU usage. */
#define DEFAULT_FRAME_REST false

/* Duplicates frames for the purposes of running Shaders at a higher framerate
* than content framerate. Requires running screen at multiple of 60hz, and
* don't combine with Swap_interval > 1, or BFI. (Though BFI can be done in a shader
* with multi-frame shaders.)
*/
#define DEFAULT_SHADER_SUBFRAMES 1

/* Inserts black frame(s) inbetween frames.
* Useful for Higher Hz monitors (set to multiples of 60 Hz) who want to play 60 Hz
* material with CRT-like motion clarity.
Expand Down Expand Up @@ -848,6 +855,7 @@
#define DEFAULT_GAME_SPECIFIC_OPTIONS true
#define DEFAULT_AUTO_OVERRIDES_ENABLE true
#define DEFAULT_AUTO_REMAPS_ENABLE true
#define DEFAULT_INITIAL_DISK_CHANGE_ENABLE true
#define DEFAULT_GLOBAL_CORE_OPTIONS false
#define DEFAULT_AUTO_SHADERS_ENABLE true

Expand Down
107 changes: 83 additions & 24 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#endif

#include "file_path_special.h"
#include "command.h"
#include "configuration.h"
#include "content.h"
#include "config.def.h"
Expand Down Expand Up @@ -1719,6 +1720,7 @@ static struct config_bool_setting *populate_settings_bool(
SETTING_BOOL("game_specific_options", &settings->bools.game_specific_options, true, DEFAULT_GAME_SPECIFIC_OPTIONS, false);
SETTING_BOOL("auto_overrides_enable", &settings->bools.auto_overrides_enable, true, DEFAULT_AUTO_OVERRIDES_ENABLE, false);
SETTING_BOOL("auto_remaps_enable", &settings->bools.auto_remaps_enable, true, DEFAULT_AUTO_REMAPS_ENABLE, false);
SETTING_BOOL("initial_disk_change_enable", &settings->bools.initial_disk_change_enable, true, DEFAULT_INITIAL_DISK_CHANGE_ENABLE, false);
SETTING_BOOL("global_core_options", &settings->bools.global_core_options, true, DEFAULT_GLOBAL_CORE_OPTIONS, false);
SETTING_BOOL("auto_shaders_enable", &settings->bools.auto_shaders_enable, true, DEFAULT_AUTO_SHADERS_ENABLE, false);
SETTING_BOOL("scan_without_core_match", &settings->bools.scan_without_core_match, true, DEFAULT_SCAN_WITHOUT_CORE_MATCH, false);
Expand Down Expand Up @@ -2397,6 +2399,7 @@ static struct config_uint_setting *populate_settings_uint(
SETTING_UINT("video_max_frame_latency", &settings->uints.video_max_frame_latency, true, DEFAULT_MAX_FRAME_LATENCY, false);
SETTING_UINT("video_black_frame_insertion", &settings->uints.video_black_frame_insertion, true, DEFAULT_BLACK_FRAME_INSERTION, false);
SETTING_UINT("video_bfi_dark_frames", &settings->uints.video_bfi_dark_frames, true, DEFAULT_BFI_DARK_FRAMES, false);
SETTING_UINT("video_shader_subframes", &settings->uints.video_shader_subframes, true, DEFAULT_SHADER_SUBFRAMES, false);
SETTING_UINT("video_swap_interval", &settings->uints.video_swap_interval, true, DEFAULT_SWAP_INTERVAL, false);
SETTING_UINT("video_rotation", &settings->uints.video_rotation, true, ORIENTATION_NORMAL, false);
SETTING_UINT("screen_orientation", &settings->uints.screen_orientation, true, ORIENTATION_NORMAL, false);
Expand Down Expand Up @@ -4455,6 +4458,10 @@ bool config_load_override_file(const char *config_path)
*/
bool config_unload_override(void)
{
settings_t *settings = config_st;
bool fullscreen_prev = settings->bools.video_fullscreen;
uint32_t flags = runloop_get_flags();

runloop_state_get_ptr()->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
path_clear(RARCH_PATH_CONFIG_OVERRIDE);

Expand All @@ -4466,6 +4473,20 @@ bool config_unload_override(void)
path_get(RARCH_PATH_CONFIG), config_st))
return false;

if (settings->bools.video_fullscreen != fullscreen_prev)
{
/* This is for 'win32_common.c', so we don't save
* fullscreen size and position if we're switching
* back to windowed mode.
* Might be useful for other devices as well? */
if ( settings->bools.video_window_save_positions
&& !settings->bools.video_fullscreen)
settings->skip_window_positions = true;

if (flags & RUNLOOP_FLAG_CORE_RUNNING)
command_event(CMD_EVENT_REINIT, NULL);
}

RARCH_LOG("[Overrides]: Configuration overrides unloaded, original configuration restored.\n");

/* Reset save paths */
Expand Down Expand Up @@ -4914,14 +4935,9 @@ static void input_config_save_keybinds_user_override(config_file_t *conf,
}
}

/**
* config_save_autoconf_profile:
* @device_name : Input device name
* @user : Controller number to save
* Writes a controller autoconf file to disk.
**/
bool config_save_autoconf_profile(const
char *device_name, unsigned user)
void config_get_autoconf_profile_filename(
const char *device_name, unsigned user,
char *buf, size_t len_buf)
{
static const char* invalid_filename_chars[] = {
/* https://support.microsoft.com/en-us/help/905231/information-about-the-characters-that-you-cannot-use-in-site-names--fo */
Expand All @@ -4930,12 +4946,7 @@ bool config_save_autoconf_profile(const
};
size_t len;
unsigned i;
char buf[PATH_MAX_LENGTH];
char autoconf_file[PATH_MAX_LENGTH];
config_file_t *conf = NULL;
int32_t pid_user = 0;
int32_t vid_user = 0;
bool ret = false;

settings_t *settings = config_st;
const char *autoconf_dir = settings->paths.directory_autoconfig;
const char *joypad_driver_fallback = settings->arrays.input_joypad_driver;
Expand Down Expand Up @@ -4978,15 +4989,66 @@ bool config_save_autoconf_profile(const
}

/* Generate autoconfig file path */
fill_pathname_join_special(buf, autoconf_dir, joypad_driver, sizeof(buf));
fill_pathname_join_special(buf, autoconf_dir, joypad_driver, len_buf);

if (path_is_directory(buf))
len = fill_pathname_join_special(autoconf_file, buf,
sanitised_name, sizeof(autoconf_file));
/* Driver specific autoconf dir may not exist, if autoconfs are not downloaded. */
if (!path_is_directory(buf))
{
len = strlcpy(buf, sanitised_name, len_buf);
}
else
len = fill_pathname_join_special(autoconf_file, autoconf_dir,
sanitised_name, sizeof(autoconf_file));
strlcpy(autoconf_file + len, ".cfg", sizeof(autoconf_file) - len);
{
len = fill_pathname_join_special(buf, joypad_driver, sanitised_name, len_buf);
}
strlcpy(buf + len, ".cfg", len_buf - len);

end:
if (sanitised_name)
free(sanitised_name);

}
/**
* config_save_autoconf_profile:
* @device_name : Input device name
* @user : Controller number to save
* Writes a controller autoconf file to disk.
**/
bool config_save_autoconf_profile(const
char *device_name, unsigned user)
{
size_t len;
unsigned i;
char buf[PATH_MAX_LENGTH];
char autoconf_file[PATH_MAX_LENGTH];
config_file_t *conf = NULL;
int32_t pid_user = 0;
int32_t vid_user = 0;
bool ret = false;
settings_t *settings = config_st;
const char *autoconf_dir = settings->paths.directory_autoconfig;
const char *joypad_driver_fallback = settings->arrays.input_joypad_driver;
const char *joypad_driver = NULL;

if (string_is_empty(device_name))
goto end;

/* Get currently set joypad driver */
joypad_driver = input_config_get_device_joypad_driver(user);
if (string_is_empty(joypad_driver))
{
/* This cannot happen, but if we reach this
* point without a driver being set for the
* current input device then use the value
* from the settings struct as a fallback */
joypad_driver = joypad_driver_fallback;

if (string_is_empty(joypad_driver))
goto end;
}

/* Generate autoconfig file path */
config_get_autoconf_profile_filename(device_name, user, buf, sizeof(buf));
fill_pathname_join_special(autoconf_file, autoconf_dir, buf, sizeof(autoconf_file));

/* Open config file */
if ( !(conf = config_file_new_from_path_to_string(autoconf_file))
Expand Down Expand Up @@ -5028,9 +5090,6 @@ bool config_save_autoconf_profile(const
ret = config_file_write(conf, autoconf_file, false);

end:
if (sanitised_name)
free(sanitised_name);

if (conf)
config_file_free(conf);

Expand Down
13 changes: 13 additions & 0 deletions configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ typedef struct settings
unsigned core_updater_auto_backup_history_size;
unsigned video_black_frame_insertion;
unsigned video_bfi_dark_frames;
unsigned video_shader_subframes;
unsigned video_autoswitch_refresh_rate;
unsigned quit_on_close_content;

Expand Down Expand Up @@ -572,6 +573,7 @@ typedef struct settings
} paths;

bool modified;
bool skip_window_positions;

struct
{
Expand Down Expand Up @@ -981,6 +983,7 @@ typedef struct settings
bool game_specific_options;
bool auto_overrides_enable;
bool auto_remaps_enable;
bool initial_disk_change_enable;
bool global_core_options;
bool auto_shaders_enable;

Expand Down Expand Up @@ -1211,6 +1214,16 @@ bool config_unload_override(void);
bool config_load_remap(const char *directory_input_remapping,
void *data);

/**
* config_get_autoconf_profile_filename:
* @device_name : Input device name
* @user : Controller number to save
* Fills buf with the autoconf profile file name (including driver dir if needed).
**/

void config_get_autoconf_profile_filename(
const char *device_name, unsigned user,
char *buf, size_t len_buf);
/**
* config_save_autoconf_profile:
* @device_name : Input device name
Expand Down
Loading

0 comments on commit c218c60

Please sign in to comment.