Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/libretro/RetroArch
Browse files Browse the repository at this point in the history
  • Loading branch information
ChronoAndross committed Nov 5, 2023
2 parents f6c0a22 + 3186b1d commit 1ba2afd
Show file tree
Hide file tree
Showing 129 changed files with 12,869 additions and 3,228 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ wiiu/wut/elf2rpl/elf2rpl
/media/shaders_cg/
/media/libretrodb/

compile_commands.json
pkg/apple/iOS/build/
pkg/apple/build/
ui/drivers/qt/moc_*
Expand Down
20 changes: 18 additions & 2 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,10 @@ ifeq ($(HAVE_LAKKA_NIGHTLY), 1)
DEFINES += -DHAVE_LAKKA_NIGHTLY
endif

ifneq ($(HAVE_LAKKA_CANARY), "")
DEFINES += -DHAVE_LAKKA_CANARY=\"${HAVE_LAKKA_CANARY}\"
endif

ifeq ($(HAVE_MENU_COMMON), 1)
OBJ += menu/menu_setting.o \
menu/menu_driver.o \
Expand Down Expand Up @@ -2097,20 +2101,31 @@ ifeq ($(HAVE_NETWORKING), 1)
DEFINES += -DHAVE_CHEEVOS
INCLUDE_DIRS += -Ideps/rcheevos/include

ifneq ($(HAVE_THREADS), 1)
DEFINES += -DRC_NO_THREADS
else ifneq (,$(filter GEKKO,$(CFLAGS)))
# Gekko (Wii) and 3DS use custom pthread wrappers (see rthreads.c)
DEFINES += -DRC_NO_THREADS
else ifneq (,$(filter _3DS,$(CFLAGS)))
DEFINES += -DRC_NO_THREADS
endif

OBJ += cheevos/cheevos.o \
cheevos/cheevos_client.o \
cheevos/cheevos_menu.o \
$(LIBRETRO_COMM_DIR)/formats/cdfs/cdfs.o \
deps/rcheevos/src/rc_client.o \
deps/rcheevos/src/rc_compat.o \
deps/rcheevos/src/rc_libretro.o \
deps/rcheevos/src/rc_util.o \
deps/rcheevos/src/rcheevos/alloc.o \
deps/rcheevos/src/rcheevos/compat.o \
deps/rcheevos/src/rcheevos/condition.o \
deps/rcheevos/src/rcheevos/condset.o \
deps/rcheevos/src/rcheevos/consoleinfo.o \
deps/rcheevos/src/rcheevos/format.o \
deps/rcheevos/src/rcheevos/lboard.o \
deps/rcheevos/src/rcheevos/memref.o \
deps/rcheevos/src/rcheevos/operand.o \
deps/rcheevos/src/rcheevos/rc_libretro.o \
deps/rcheevos/src/rcheevos/richpresence.o \
deps/rcheevos/src/rcheevos/runtime.o \
deps/rcheevos/src/rcheevos/runtime_progress.o \
Expand All @@ -2119,6 +2134,7 @@ ifeq ($(HAVE_NETWORKING), 1)
deps/rcheevos/src/rhash/cdreader.o \
deps/rcheevos/src/rhash/hash.o \
deps/rcheevos/src/rapi/rc_api_common.o \
deps/rcheevos/src/rapi/rc_api_info.o \
deps/rcheevos/src/rapi/rc_api_runtime.o \
deps/rcheevos/src/rapi/rc_api_user.o \

Expand Down
25 changes: 18 additions & 7 deletions Makefile.emscripten
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ HAVE_STATIC_DUMMY ?= 0
ifeq ($(TARGET),)
ifeq ($(LIBRETRO),)
TARGET := retroarch.js
LIBRETRO = dummy
else
TARGET := $(LIBRETRO)_libretro.js
endif
Expand Down Expand Up @@ -48,7 +49,6 @@ HAVE_7ZIP = 1
HAVE_BSV_MOVIE = 1
HAVE_AL = 1


# WARNING -- READ BEFORE ENABLING
# The rwebaudio driver is known to have several audio bugs, such as
# minor crackling, or the entire page freezing/crashing.
Expand Down Expand Up @@ -78,8 +78,11 @@ OBJDIR := obj-emscripten
#if you compile with SDL2 flag add this Emscripten flag "-s USE_SDL=2" to LDFLAGS:

LIBS := -s USE_ZLIB=1
LDFLAGS := -L. --no-heap-copy -s $(LIBS) -s TOTAL_MEMORY=$(MEMORY) -s NO_EXIT_RUNTIME=0 -s FULL_ES2=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']" \
-s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_load_state', '_cmd_take_screenshot']" \
LDFLAGS := -L. --no-heap-copy -s $(LIBS) -s TOTAL_MEMORY=$(MEMORY) -s NO_EXIT_RUNTIME=0 -s FULL_ES2=1 \
-s "EXPORTED_RUNTIME_METHODS=['callMain', 'FS', 'PATH', 'ERRNO_CODES']" \
-s ALLOW_MEMORY_GROWTH=1 -s "EXPORTED_FUNCTIONS=['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_load_state', '_cmd_take_screenshot']" \
-s MODULARIZE=1 -s EXPORT_ES6=1 -s EXPORT_NAME="$(LIBRETRO)" \
-s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 \
--js-library emscripten/library_errno_codes.js \
--js-library emscripten/library_rwebcam.js

Expand All @@ -102,7 +105,10 @@ else
endif

ifeq ($(ASYNC), 1)
LDFLAGS += -s ASYNCIFY=$(ASYNC)
LDFLAGS += -s ASYNCIFY=$(ASYNC) -s ASYNCIFY_STACK_SIZE=8192
ifeq ($(DEBUG), 1)
LDFLAGS += -s ASYNCIFY_DEBUG=1 # -s ASYNCIFY_ADVISE
endif
endif

ifeq ($(HAVE_SDL2), 1)
Expand All @@ -127,8 +133,8 @@ ifneq ($(V), 1)
endif

ifeq ($(DEBUG), 1)
LDFLAGS += -O0 -g
CFLAGS += -O0 -g
LDFLAGS += -O0 -g -gsource-map -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=2 -s ASSERTIONS=1
CFLAGS += -O0 -g -gsource-map -s SAFE_HEAP=1 -s SAFE_HEAP_LOG=1 -s STACK_OVERFLOW_CHECK=2 -s ASSERTIONS=1
else
LDFLAGS += -O3 -s WASM=1
# WARNING: some optimizations can break some cores (ex: LTO breaks tyrquake)
Expand All @@ -139,7 +145,12 @@ else
CFLAGS += -O3
endif

CFLAGS += -Wall -I. -Ilibretro-common/include -std=gnu99 $(LIBS) #\
# 128 * 1024, double the usual emscripten stack size
LDFLAGS += -s STACK_SIZE=131072

LDFLAGS += --extern-pre-js emscripten/pre.js

CFLAGS += -Wall -I. -Ilibretro-common/include -std=gnu99 #\
# -s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_take_screenshot']"

RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
Expand Down
124 changes: 90 additions & 34 deletions accessibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,36 @@
#endif

#include "configuration.h"
#include "tasks/tasks_internal.h"

#ifdef HAVE_THREADS
#include "rthreads/rthreads.h"
#endif

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;

#ifdef HAVE_THREADS
/* Necessary because last_image is manipulated by task handlers */
slock_t *image_lock;
#endif

/* Frame captured during the last call to the translation service */
uint8_t *last_image;
int last_image_size;

/* 1 if the automatic mode has been enabled, 0 otherwise */
int ai_service_auto;
/* Is text-to-speech accessibility turned on? */

/* Text-to-speech narrator override flag */
bool enabled;
} access_state_t;

Expand All @@ -46,42 +71,73 @@ bool is_narrator_running(bool accessibility_enable);
#endif

/*
This function does all the stuff needed to translate the game screen,
using the URL given in the settings. Once the image from the frame
buffer is sent to the server, the callback will write the translated
image to the screen.
Supported client/services (thus far)
-VGTranslate client ( www.gitlab.com/spherebeaker/vg_translate )
-Ztranslate client/service ( www.ztranslate.net/docs/service )
To use a client, download the relevant code/release, configure
them, and run them on your local machine, or network. Set the
retroarch configuration to point to your local client (usually
listening on localhost:4404 ) and enable translation service.
If you don't want to run a client, you can also use a service,
which is basically like someone running a client for you. The
downside here is that your retroarch device will have to have
an internet connection, and you may have to sign up for it.
To make your own server, it must listen for a POST request, which
will consist of a JSON body, with the "image" field as a base64
encoded string of a 24bit-BMP/PNG that the will be translated.
The server must output the translated image in the form of a
JSON body, with the "image" field also as a base64 encoded
24bit-BMP, or as an alpha channel png.
"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 variable from before
the handle_translation_cb wipes the widgets, and pass that in here.
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
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
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>).
– state: a JSON object describing the state of the frontend, containing:
– paused: 1 if the content has been paused, 0 otherwise.
– <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.
– sound: base64 representation of a sound byte in a supported format.
– text: results from the service as a string.
– 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
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
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
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
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
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(
bool accessibility_enable,
unsigned accessibility_narrator_speech_speed,
Expand Down
14 changes: 7 additions & 7 deletions cheevos/cheevos.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
#include "../deps/rcheevos/include/rc_runtime.h"
#include "../deps/rcheevos/include/rc_runtime_types.h"
#include "../deps/rcheevos/include/rc_hash.h"
#include "../deps/rcheevos/src/rcheevos/rc_libretro.h"
#include "../deps/rcheevos/src/rc_libretro.h"

/* Define this macro to prevent cheevos from being deactivated when they trigger. */
#undef CHEEVOS_DONT_DEACTIVATE
Expand Down Expand Up @@ -163,7 +163,7 @@ static void rcheevos_handle_log_message(const char* message)
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", message);
}

static void rcheevos_get_core_memory_info(unsigned id,
static void rcheevos_get_core_memory_info(uint32_t id,
rc_libretro_core_memory_info_t* info)
{
retro_ctx_memory_info_t ctx_info;
Expand Down Expand Up @@ -220,10 +220,10 @@ uint8_t* rcheevos_patch_address(unsigned address)
return rc_libretro_memory_find(&rcheevos_locals.memory, address);
}

static unsigned rcheevos_peek(unsigned address,
unsigned num_bytes, void* ud)
static uint32_t rcheevos_peek(uint32_t address,
uint32_t num_bytes, void* ud)
{
unsigned avail;
uint32_t avail;
uint8_t* data = rc_libretro_memory_find_avail(
&rcheevos_locals.memory, address, &avail);

Expand Down Expand Up @@ -1321,7 +1321,7 @@ static void rcheevos_runtime_event_handler(
}
}

static int rcheevos_runtime_address_validator(unsigned address)
static int rcheevos_runtime_address_validator(uint32_t address)
{
return rc_libretro_memory_find(
&rcheevos_locals.memory, address) != NULL;
Expand Down Expand Up @@ -2066,7 +2066,7 @@ static void rcheevos_identify_game_callback(void* userdata)
rcheevos_fetch_game_data();
}

static int rcheevos_get_image_path(unsigned index, char* buffer, size_t buffer_size)
static int rcheevos_get_image_path(uint32_t index, char* buffer, size_t buffer_size)
{
rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system;
if (!sys_info->disk_control.cb.get_image_path)
Expand Down
2 changes: 1 addition & 1 deletion cheevos/cheevos_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,7 @@ static void rcheevos_async_award_achievement_callback(
{
if ((int)api_response.awarded_achievement_id != request->id)
snprintf(buffer, buffer_size, "Achievement %u awarded instead",
api_response.awarded_achievement_id);
(unsigned)api_response.awarded_achievement_id);
else if (api_response.response.error_message)
{
/* previously unlocked achievements are returned as a "successful" error */
Expand Down
2 changes: 1 addition & 1 deletion cheevos/cheevos_locals.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define __RARCH_CHEEVOS_LOCALS_H

#include "../deps/rcheevos/include/rc_runtime.h"
#include "../deps/rcheevos/src/rcheevos/rc_libretro.h"
#include "../deps/rcheevos/src/rc_libretro.h"

#include <boolean.h>
#include <queues/task_queue.h>
Expand Down
5 changes: 5 additions & 0 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <locale.h>
#ifdef HAVE_NETWORKING
#include <net/net_compat.h>
#include <net/net_socket.h>
Expand Down Expand Up @@ -1166,6 +1167,10 @@ bool command_event_save_config(
const char *str = path_exists ? config_path :
path_get(RARCH_PATH_CONFIG);

/* Workaround for libdecor 0.2.0 setting unwanted locale */
#if defined(HAVE_WAYLAND) && defined(HAVE_DYNAMIC)
setlocale(LC_NUMERIC,"C");
#endif
if (path_exists && config_save_file(config_path))
{
snprintf(s, len, "%s \"%s\".",
Expand Down
11 changes: 10 additions & 1 deletion config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
/* Number of threads to use for video recording */
#define DEFAULT_VIDEO_RECORD_THREADS 2

#if defined(RARCH_CONSOLE) || defined(__APPLE__)
#if defined(RARCH_CONSOLE)
#define DEFAULT_LOAD_DUMMY_ON_CORE_SHUTDOWN false
#else
#define DEFAULT_LOAD_DUMMY_ON_CORE_SHUTDOWN true
Expand Down Expand Up @@ -391,6 +391,9 @@
#define MAXIMUM_FRAME_DELAY 19
#define DEFAULT_FRAME_DELAY_AUTO false

/* Try to sleep the spare time after frame is presented in order to reduce vsync CPU usage. */
#define DEFAULT_FRAME_REST false

/* 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 eliminated ghosting. video_refresh_rate should still be configured
Expand Down Expand Up @@ -1749,8 +1752,14 @@

#define DEFAULT_AI_SERVICE_MODE 1

#define DEFAULT_AI_SERVICE_TEXT_POSITION 0
#define DEFAULT_AI_SERVICE_TEXT_PADDING 5

#define DEFAULT_AI_SERVICE_URL "http://localhost:4404/"

#define DEFAULT_AI_SERVICE_POLL_DELAY 0
#define MAXIMUM_AI_SERVICE_POLL_DELAY 500

#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
#define DEFAULT_BUILTIN_MEDIAPLAYER_ENABLE true
#else
Expand Down
Loading

0 comments on commit 1ba2afd

Please sign in to comment.