From 969475254f241ad2c49f5ca05cc42a90ae09bc7a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 03:30:04 +0200 Subject: [PATCH] (retroarch.c) Reorganize globals, forward declarations, and defines --- retroarch.c | 1472 +++++++++++++++++++++++++-------------------------- 1 file changed, 724 insertions(+), 748 deletions(-) diff --git a/retroarch.c b/retroarch.c index ad17a5742a..f9c9a6ca17 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1028,6 +1028,50 @@ static const camera_driver_t *camera_drivers[] = { #define DEBUG_INFO_FILENAME "debug_info.txt" +#define BSV_MAGIC 0x42535631 + +#define MAGIC_INDEX 0 +#define SERIALIZER_INDEX 1 +#define CRC_INDEX 2 +#define STATE_SIZE_INDEX 3 + +#define BSV_MOVIE_IS_PLAYBACK_ON() (bsv_movie_state_handle && bsv_movie_state.movie_playback) +#define BSV_MOVIE_IS_PLAYBACK_OFF() (bsv_movie_state_handle && !bsv_movie_state.movie_playback) + +#define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024) + +#define TIME_TO_FPS(last_time, new_time, frames) ((1000000.0f * (frames)) / ((new_time) - (last_time))) + +#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024) + +#define MENU_SOUND_FORMATS "ogg|mod|xm|s3m|mp3|flac" + +#define MIDI_DRIVER_BUF_SIZE 4096 + +/** + * db_to_gain: + * @db : Decibels. + * + * Converts decibels to voltage gain. + * + * Returns: voltage gain value. + **/ +#define db_to_gain(db) (powf(10.0f, (db) / 20.0f)) + +#define DEFAULT_NETWORK_GAMEPAD_PORT 55400 +#define UDP_FRAME_PACKETS 16 + +#ifdef HAVE_OVERLAY +#define OVERLAY_GET_KEY(state, key) (((state)->keys[(key) / 32] >> ((key) % 32)) & 1) +#define OVERLAY_SET_KEY(state, key) (state)->keys[(key) / 32] |= 1 << ((key) % 32) + +#define MAX_VISIBILITY 32 +#endif + +#define DECLARE_BIND(x, bind, desc) { true, 0, #x, desc, bind } +#define DECLARE_META_BIND(level, x, bind, desc) { true, level, #x, desc, bind } + + /* Descriptive names for options without short variant. * * Please keep the name in sync with the option name. @@ -1123,6 +1167,18 @@ struct bsv_movie bool did_rewind; }; +typedef struct video_pixel_scaler +{ + struct scaler_ctx *scaler; + void *scaler_out; +} video_pixel_scaler_t; + +typedef struct +{ + enum gfx_ctx_api api; + struct string_list *list; +} gfx_api_gpu_map; + static struct global g_extern; static struct retro_callbacks retro_ctx; @@ -1219,11 +1275,9 @@ static bool runloop_max_frames_screenshot = false; #ifdef HAVE_RUNAHEAD static bool has_variable_update = false; #endif -#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) -static bool shader_presets_need_reload = true; -#endif #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) +static bool shader_presets_need_reload = true; static char cli_shader[PATH_MAX_LENGTH] = {0}; static bool cli_shader_disable = false; static char runtime_shader_preset[PATH_MAX_LENGTH] = {0}; @@ -1258,21 +1312,615 @@ static char current_savefile_dir[PATH_MAX_LENGTH] = {0}; static char current_savestate_dir[PATH_MAX_LENGTH] = {0}; static char dir_savestate[PATH_MAX_LENGTH] = {0}; -#define BSV_MAGIC 0x42535631 +#ifdef HAVE_GFX_WIDGETS +static bool gfx_widgets_paused = false; +static bool gfx_widgets_fast_forward = false; +static bool gfx_widgets_rewinding = false; +#endif -#define MAGIC_INDEX 0 -#define SERIALIZER_INDEX 1 -#define CRC_INDEX 2 -#define STATE_SIZE_INDEX 3 +#ifdef HAVE_ACCESSIBILITY +/* Is text-to-speech accessibility turned on? */ +static bool accessibility_enabled = false; +#endif -#define BSV_MOVIE_IS_PLAYBACK_ON() (bsv_movie_state_handle && bsv_movie_state.movie_playback) -#define BSV_MOVIE_IS_PLAYBACK_OFF() (bsv_movie_state_handle && !bsv_movie_state.movie_playback) +#ifdef HAVE_MENU +static const char **menu_input_dialog_keyboard_buffer = {NULL}; +static unsigned menu_input_dialog_keyboard_type = 0; +static unsigned menu_input_dialog_keyboard_idx = 0; +static char menu_input_dialog_keyboard_label_setting[256] = {0}; +static char menu_input_dialog_keyboard_label[256] = {0}; +static bool menu_input_dialog_keyboard_display = false; +static unsigned char menu_keyboard_key_state[RETROK_LAST] = {0}; + +/* Since these are static/global, they are initialised to zero */ +static menu_input_pointer_hw_state_t menu_input_pointer_hw_state; +static menu_input_t menu_input_state; + +/* Is the menu driver still running? */ +static bool menu_driver_alive = false; +/* Are we binding a button inside the menu? */ +static bool menu_driver_is_binding = false; +#endif + +static unsigned recording_width = 0; +static unsigned recording_height = 0; +static size_t recording_gpu_width = 0; +static size_t recording_gpu_height = 0; +static bool recording_enable = false; +static bool streaming_enable = false; + +static const record_driver_t *recording_driver = NULL; +static void *recording_data = NULL; + +static uint8_t *video_driver_record_gpu_buffer = NULL; + +#ifdef HAVE_THREADS +static slock_t *_runloop_msg_queue_lock = NULL; +#endif + +static struct retro_camera_callback camera_cb; +static const camera_driver_t *camera_driver = NULL; +static void *camera_data = NULL; +static bool camera_driver_active = false; + +static midi_driver_t *midi_drv = &midi_null; +static void *midi_drv_data = NULL; +static struct string_list *midi_drv_inputs = NULL; +static struct string_list *midi_drv_outputs = NULL; +static bool midi_drv_input_enabled = false; +static bool midi_drv_output_enabled = false; +static uint8_t *midi_drv_input_buffer = NULL; +static uint8_t *midi_drv_output_buffer = NULL; +static midi_event_t midi_drv_input_event; +static midi_event_t midi_drv_output_event; +static bool midi_drv_output_pending = false; + +static const uint8_t midi_drv_ev_sizes[128] = +{ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 0, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +}; + +static bool main_ui_companion_is_on_foreground = false; +static const ui_companion_driver_t *ui_companion = NULL; +static void *ui_companion_data = NULL; + +#ifdef HAVE_QT +static void *ui_companion_qt_data = NULL; +static bool qt_is_inited = false; +#endif + +static const location_driver_t *location_driver = NULL; +static void *location_data = NULL; + +static bool location_driver_active = false; + +static const wifi_driver_t *wifi_driver = NULL; +static void *wifi_data = NULL; +static bool wifi_driver_active = false; + +static const video_display_server_t *current_display_server = &dispserv_null; +static void *current_display_server_data = NULL; +static enum rotation initial_screen_orientation = ORIENTATION_NORMAL; +static enum rotation current_screen_orientation = ORIENTATION_NORMAL; typedef struct bsv_movie bsv_movie_t; static bsv_movie_t *bsv_movie_state_handle = NULL; static struct bsv_state bsv_movie_state; +struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { + { "4:3", 1.3333f }, + { "16:9", 1.7778f }, + { "16:10", 1.6f }, + { "16:15", 16.0f / 15.0f }, + { "21:9", 21.0f / 9.0f }, + { "1:1", 1.0f }, + { "2:1", 2.0f }, + { "3:2", 1.5f }, + { "3:4", 0.75f }, + { "4:1", 4.0f }, + { "9:16", 0.5625f }, + { "5:4", 1.25f }, + { "6:5", 1.2f }, + { "7:9", 0.7777f }, + { "8:3", 2.6666f }, + { "8:7", 1.1428f }, + { "19:12", 1.5833f }, + { "19:14", 1.3571f }, + { "30:17", 1.7647f }, + { "32:9", 3.5555f }, + { "Config", 0.0f }, + { "Square pixel", 1.0f }, + { "Core provided", 1.0f }, + { "Custom", 0.0f } +}; + +static gfx_api_gpu_map gpu_map[] = { + { GFX_CTX_VULKAN_API, NULL }, + { GFX_CTX_DIRECT3D10_API, NULL }, + { GFX_CTX_DIRECT3D11_API, NULL }, + { GFX_CTX_DIRECT3D12_API, NULL } +}; + +/* Opaque handles to currently running window. + * Used by e.g. input drivers which bind to a window. + * Drivers are responsible for setting these if an input driver + * could potentially make use of this. */ +static uintptr_t video_driver_display_userdata = 0; +static uintptr_t video_driver_display = 0; +static uintptr_t video_driver_window = 0; + +static rarch_softfilter_t *video_driver_state_filter = NULL; +static void *video_driver_state_buffer = NULL; +static unsigned video_driver_state_scale = 0; +static unsigned video_driver_state_out_bpp = 0; +static bool video_driver_state_out_rgb32 = false; +static bool video_driver_crt_switching_active = false; +static bool video_driver_crt_dynamic_super_width = false; + +static enum retro_pixel_format video_driver_pix_fmt = RETRO_PIXEL_FORMAT_0RGB1555; + +static const void *frame_cache_data = NULL; +static unsigned frame_cache_width = 0; +static unsigned frame_cache_height = 0; +static size_t frame_cache_pitch = 0; +static bool video_driver_threaded = false; + +static float video_driver_core_hz = 0.0f; +static float video_driver_aspect_ratio = 0.0f; +static unsigned video_driver_width = 0; +static unsigned video_driver_height = 0; + +static enum rarch_display_type video_driver_display_type = RARCH_DISPLAY_NONE; +static char video_driver_title_buf[64] = {0}; +static char video_driver_window_title[512] = {0}; +static bool video_driver_window_title_update = true; + +static retro_time_t video_driver_frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT]; +static uint64_t video_driver_frame_time_count = 0; +static uint64_t video_driver_frame_count = 0; + +static void *video_driver_data = NULL; +static video_driver_t *current_video = NULL; + +/* Interface for "poking". */ +static const video_poke_interface_t *video_driver_poke = NULL; + +/* Used for 15-bit -> 16-bit conversions that take place before + * being passed to video driver. */ +static video_pixel_scaler_t *video_driver_scaler_ptr = NULL; + +static struct retro_hw_render_callback hw_render; + +static const struct +retro_hw_render_context_negotiation_interface * +hw_render_context_negotiation = NULL; + +/* Graphics driver requires RGBA byte order data (ABGR on little-endian) + * for 32-bit. + * This takes effect for overlay and shader cores that wants to load + * data into graphics driver. Kinda hackish to place it here, it is only + * used for GLES. + * TODO: Refactor this better. */ +static bool video_driver_use_rgba = false; +static bool video_driver_active = false; + +static video_driver_frame_t frame_bak = NULL; + +/* If set during context deinit, the driver should keep + * graphics context alive to avoid having to reset all + * context state. */ +static bool video_driver_cache_context = false; + +/* Set to true by driver if context caching succeeded. */ +static bool video_driver_cache_context_ack = false; + +#ifdef HAVE_THREADS +static slock_t *display_lock = NULL; +static slock_t *context_lock = NULL; +#endif + +static gfx_ctx_driver_t current_video_context; + +static void *video_context_data = NULL; + +/** + * dynamic.c:dynamic_request_hw_context will try to set flag data when the context + * is in the middle of being rebuilt; in these cases we will save flag + * data and set this to true. + * When the context is reinit, it checks this, reads from + * deferred_flag_data and cleans it. + * + * TODO - Dirty hack, fix it better + */ +static bool deferred_video_context_driver_set_flags = false; +static gfx_ctx_flags_t deferred_flag_data = {0}; + +static bool video_started_fullscreen = false; + +static char video_driver_gpu_device_string[128] = {0}; +static char video_driver_gpu_api_version_string[128] = {0}; + +static struct retro_system_av_info video_driver_av_info; + +#ifdef HAVE_AUDIOMIXER +static struct audio_mixer_stream +audio_mixer_streams[AUDIO_MIXER_MAX_SYSTEM_STREAMS] = {{0}}; + +static bool audio_driver_mixer_mute_enable = false; +static bool audio_mixer_active = false; +static float audio_driver_mixer_volume_gain = 0.0f; +#endif + +static size_t audio_driver_chunk_size = 0; +static size_t audio_driver_chunk_nonblock_size = 0; +static size_t audio_driver_chunk_block_size = 0; + +static size_t audio_driver_rewind_ptr = 0; +static size_t audio_driver_rewind_size = 0; + +static int16_t *audio_driver_rewind_buf = NULL; +static int16_t *audio_driver_output_samples_conv_buf = NULL; + +static unsigned audio_driver_free_samples_buf[AUDIO_BUFFER_FREE_SAMPLES_COUNT]; +static uint64_t audio_driver_free_samples_count = 0; + +static size_t audio_driver_buffer_size = 0; +static size_t audio_driver_data_ptr = 0; + +static bool audio_driver_control = false; +static bool audio_driver_mute_enable = false; +static bool audio_driver_use_float = false; +static bool audio_driver_active = false; + +static float audio_driver_rate_control_delta = 0.0f; +static float audio_driver_input = 0.0f; +static float audio_driver_volume_gain = 0.0f; + +static float *audio_driver_input_data = NULL; +static float *audio_driver_output_samples_buf = NULL; + +static double audio_source_ratio_original = 0.0f; +static double audio_source_ratio_current = 0.0f; + +static struct retro_audio_callback audio_callback = {0}; + +static retro_dsp_filter_t *audio_driver_dsp = NULL; +static struct string_list *audio_driver_devices_list = NULL; +static const retro_resampler_t *audio_driver_resampler = NULL; + +static void *audio_driver_resampler_data = NULL; +static const audio_driver_t *current_audio = NULL; +static void *audio_driver_context_audio_data = NULL; + +static bool audio_suspended = false; +static bool audio_is_threaded = false; + +typedef struct input_list_element_t +{ + unsigned port; + unsigned device; + unsigned index; + int16_t *state; + unsigned int state_size; +} input_list_element; + +#ifdef HAVE_RUNAHEAD +static size_t runahead_save_state_size = 0; + +static bool runahead_save_state_size_known = false; +static bool request_fast_savestate = false; +static bool hard_disable_audio = false; + +/* Save State List for Run Ahead */ +typedef void *(*constructor_t)(void); +typedef void (*destructor_t )(void*); + +typedef struct MyList_t +{ + void **data; + int capacity; + int size; + constructor_t constructor; + destructor_t destructor; +} MyList; + +static MyList *runahead_save_state_list = NULL; +static MyList *input_state_list = NULL; + +static bool input_is_dirty = false; + +typedef bool(*runahead_load_state_function)(const void*, size_t); + +static retro_input_state_t input_state_callback_original; +static function_t retro_reset_callback_original = NULL; +static runahead_load_state_function +retro_unserialize_callback_original = NULL; + +static function_t original_retro_deinit = NULL; +static function_t original_retro_unload = NULL; + +static bool runahead_video_driver_is_active = true; +static bool runahead_available = true; +static bool runahead_secondary_core_available = true; +static bool runahead_force_input_dirty = true; +static uint64_t runahead_last_frame_count = 0; +#endif + +#if defined(HAVE_NETWORKING) +static bool has_set_netplay_mode = false; +static bool has_set_netplay_ip_address = false; +static bool has_set_netplay_ip_port = false; +static bool has_set_netplay_stateless_mode = false; +static bool has_set_netplay_check_frames = false; +#endif + +struct remote_message +{ + int port; + int device; + int index; + int id; + uint16_t state; +}; + +struct input_remote +{ + bool state[RARCH_BIND_LIST_END]; +#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) + int net_fd[MAX_USERS]; +#endif +}; + +typedef struct input_remote input_remote_t; + +typedef struct input_remote_state +{ + /* Left X, Left Y, Right X, Right Y */ + int16_t analog[4][MAX_USERS]; + /* This is a bitmask of (1 << key_bind_id). */ + uint64_t buttons[MAX_USERS]; +} input_remote_state_t; + +#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) +static input_remote_state_t remote_st_ptr; +#endif + +#ifdef HAVE_OVERLAY +static enum overlay_visibility* visibility = NULL; + +typedef struct input_overlay_state +{ + /* Left X, Left Y, Right X, Right Y */ + int16_t analog[4]; + uint32_t keys[RETROK_LAST / 32 + 1]; + /* This is a bitmask of (1 << key_bind_id). */ + input_bits_t buttons; +} input_overlay_state_t; + +struct input_overlay +{ + enum overlay_status state; + + bool enable; + bool blocked; + bool alive; + + unsigned next_index; + + size_t index; + size_t size; + + struct overlay *overlays; + const struct overlay *active; + void *iface_data; + const video_overlay_interface_t *iface; + + input_overlay_state_t overlay_state; +}; + +static input_overlay_t *overlay_ptr = NULL; +#endif + +/* Input config. */ +struct input_bind_map +{ + bool valid; + + /* Meta binds get input as prefix, not input_playerN". + * 0 = libretro related. + * 1 = Common hotkey. + * 2 = Uncommon/obscure hotkey. + */ + uint8_t meta; + + const char *base; + enum msg_hash_enums desc; + uint8_t retro_key; +}; + +static pad_connection_listener_t *pad_connection_listener = NULL; + +static uint16_t input_config_vid[MAX_USERS]; +static uint16_t input_config_pid[MAX_USERS]; + +static char input_device_display_names[MAX_INPUT_DEVICES][64]; +static char input_device_config_names [MAX_INPUT_DEVICES][64]; +static char input_device_config_paths [MAX_INPUT_DEVICES][64]; +char input_device_names [MAX_INPUT_DEVICES][64]; + +uint64_t lifecycle_state; +struct retro_keybind input_config_binds[MAX_USERS][RARCH_BIND_LIST_END]; +struct retro_keybind input_autoconf_binds[MAX_USERS][RARCH_BIND_LIST_END]; +static const struct retro_keybind *libretro_input_binds[MAX_USERS]; + +const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { + DECLARE_BIND(b, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B), + DECLARE_BIND(y, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y), + DECLARE_BIND(select, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT), + DECLARE_BIND(start, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START), + DECLARE_BIND(up, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP), + DECLARE_BIND(down, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN), + DECLARE_BIND(left, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT), + DECLARE_BIND(right, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT), + DECLARE_BIND(a, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A), + DECLARE_BIND(x, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X), + DECLARE_BIND(l, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L), + DECLARE_BIND(r, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R), + DECLARE_BIND(l2, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2), + DECLARE_BIND(r2, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2), + DECLARE_BIND(l3, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3), + DECLARE_BIND(r3, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3), + DECLARE_BIND(l_x_plus, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS), + DECLARE_BIND(l_x_minus, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS), + DECLARE_BIND(l_y_plus, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS), + DECLARE_BIND(l_y_minus, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS), + DECLARE_BIND(r_x_plus, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS), + DECLARE_BIND(r_x_minus, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS), + DECLARE_BIND(r_y_plus, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS), + DECLARE_BIND(r_y_minus, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS), + + DECLARE_BIND( gun_trigger, RARCH_LIGHTGUN_TRIGGER, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER ), + DECLARE_BIND( gun_offscreen_shot, RARCH_LIGHTGUN_RELOAD, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD ), + DECLARE_BIND( gun_aux_a, RARCH_LIGHTGUN_AUX_A, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A ), + DECLARE_BIND( gun_aux_b, RARCH_LIGHTGUN_AUX_B, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B ), + DECLARE_BIND( gun_aux_c, RARCH_LIGHTGUN_AUX_C, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C ), + DECLARE_BIND( gun_start, RARCH_LIGHTGUN_START, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START ), + DECLARE_BIND( gun_select, RARCH_LIGHTGUN_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT ), + DECLARE_BIND( gun_dpad_up, RARCH_LIGHTGUN_DPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP ), + DECLARE_BIND( gun_dpad_down, RARCH_LIGHTGUN_DPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN ), + DECLARE_BIND( gun_dpad_left, RARCH_LIGHTGUN_DPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT ), + DECLARE_BIND( gun_dpad_right, RARCH_LIGHTGUN_DPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT ), + + DECLARE_BIND(turbo, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE), + + DECLARE_META_BIND(1, toggle_fast_forward, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY), + DECLARE_META_BIND(2, hold_fast_forward, RARCH_FAST_FORWARD_HOLD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY), + DECLARE_META_BIND(1, toggle_slowmotion, RARCH_SLOWMOTION_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION_KEY), + DECLARE_META_BIND(2, hold_slowmotion, RARCH_SLOWMOTION_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION_HOLD_KEY), + DECLARE_META_BIND(1, load_state, RARCH_LOAD_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY), + DECLARE_META_BIND(1, save_state, RARCH_SAVE_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY), + DECLARE_META_BIND(2, toggle_fullscreen, RARCH_FULLSCREEN_TOGGLE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY), +#ifdef HAVE_LAKKA + DECLARE_META_BIND(2, exit_emulator, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_RESTART_KEY), +#else + DECLARE_META_BIND(2, exit_emulator, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY), +#endif + DECLARE_META_BIND(2, state_slot_increase, RARCH_STATE_SLOT_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS), + DECLARE_META_BIND(2, state_slot_decrease, RARCH_STATE_SLOT_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS), + DECLARE_META_BIND(1, rewind, RARCH_REWIND, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND), + DECLARE_META_BIND(2, movie_record_toggle, RARCH_BSV_RECORD_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_BSV_RECORD_TOGGLE), + DECLARE_META_BIND(2, pause_toggle, RARCH_PAUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE), + DECLARE_META_BIND(2, frame_advance, RARCH_FRAMEADVANCE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE), + DECLARE_META_BIND(2, reset, RARCH_RESET, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET), + DECLARE_META_BIND(2, shader_next, RARCH_SHADER_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT), + DECLARE_META_BIND(2, shader_prev, RARCH_SHADER_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV), + DECLARE_META_BIND(2, cheat_index_plus, RARCH_CHEAT_INDEX_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS), + DECLARE_META_BIND(2, cheat_index_minus, RARCH_CHEAT_INDEX_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS), + DECLARE_META_BIND(2, cheat_toggle, RARCH_CHEAT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE), + DECLARE_META_BIND(2, screenshot, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT), + DECLARE_META_BIND(2, audio_mute, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE), + DECLARE_META_BIND(2, osk_toggle, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK), + DECLARE_META_BIND(2, fps_toggle, RARCH_FPS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE), + DECLARE_META_BIND(2, send_debug_info, RARCH_SEND_DEBUG_INFO, MENU_ENUM_LABEL_VALUE_INPUT_META_SEND_DEBUG_INFO), + DECLARE_META_BIND(2, netplay_host_toggle, RARCH_NETPLAY_HOST_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_HOST_TOGGLE), + DECLARE_META_BIND(2, netplay_game_watch, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH), + DECLARE_META_BIND(2, enable_hotkey, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY), + DECLARE_META_BIND(2, volume_up, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP), + DECLARE_META_BIND(2, volume_down, RARCH_VOLUME_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN), + DECLARE_META_BIND(2, overlay_next, RARCH_OVERLAY_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT), + DECLARE_META_BIND(2, disk_eject_toggle, RARCH_DISK_EJECT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE), + DECLARE_META_BIND(2, disk_next, RARCH_DISK_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT), + DECLARE_META_BIND(2, disk_prev, RARCH_DISK_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV), + DECLARE_META_BIND(2, grab_mouse_toggle, RARCH_GRAB_MOUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE), + DECLARE_META_BIND(2, game_focus_toggle, RARCH_GAME_FOCUS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE), + DECLARE_META_BIND(2, desktop_menu_toggle, RARCH_UI_COMPANION_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_UI_COMPANION_TOGGLE), +#ifdef HAVE_MENU + DECLARE_META_BIND(1, menu_toggle, RARCH_MENU_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE), +#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, ai_service, RARCH_AI_SERVICE, MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE), +}; + +typedef struct turbo_buttons turbo_buttons_t; + +/* Turbo support. */ +struct turbo_buttons +{ + bool frame_enable[MAX_USERS]; + uint16_t enable[MAX_USERS]; + bool mode1_enable[MAX_USERS]; + int32_t turbo_pressed[MAX_USERS]; + unsigned count; +}; + +struct input_keyboard_line +{ + char *buffer; + size_t ptr; + size_t size; + + /** Line complete callback. + * Calls back after return is + * pressed with the completed line. + * Line can be NULL. + **/ + input_keyboard_line_complete_t cb; + void *userdata; +}; + +static bool input_driver_keyboard_linefeed_enable = false; +static input_keyboard_line_t *g_keyboard_line = NULL; + +static void *g_keyboard_press_data = NULL; + +static unsigned osk_last_codepoint = 0; +static unsigned osk_last_codepoint_len = 0; + +static input_keyboard_press_t g_keyboard_press_cb; + +static turbo_buttons_t input_driver_turbo_btns; +#ifdef HAVE_COMMAND +static command_t *input_driver_command = NULL; +#endif +#ifdef HAVE_NETWORKGAMEPAD +static input_remote_t *input_driver_remote = NULL; +#endif +static input_mapper_t *input_driver_mapper = NULL; +static input_driver_t *current_input = NULL; +static void *current_input_data = NULL; +static bool input_driver_block_hotkey = false; +static bool input_driver_block_libretro_input = false; +static bool input_driver_nonblock_state = false; +static unsigned input_driver_flushing_input = 0; +static float input_driver_axis_threshold = 0.0f; +static unsigned input_driver_max_users = 0; + +#ifdef HAVE_HID +static const void *hid_data = NULL; +#endif + +#if defined(HAVE_RUNAHEAD) +static enum rarch_core_type last_core_type; +static retro_ctx_load_content_info_t *load_content_info; + +#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB) +static int port_map[16]; + +static dylib_t secondary_module; +static struct retro_core_t secondary_core; +static struct retro_callbacks secondary_callbacks; +static char *secondary_library_path = NULL; +#endif +#endif /* Forward declarations */ static void retroarch_core_options_intl_init(const struct @@ -1314,6 +1962,72 @@ static void retroarch_deinit_core_options(void); static void retroarch_init_core_variables(const struct retro_variable *vars); static void rarch_init_core_options( const struct retro_core_option_definition *option_defs); +static bool secondary_core_create(void); +static int16_t input_state_get_last(unsigned port, + unsigned device, unsigned index, unsigned id); +static void video_driver_frame(const void *data, unsigned width, + unsigned height, size_t pitch); +static void retro_frame_null(const void *data, unsigned width, + unsigned height, size_t pitch); +static void retro_run_null(void); +static void retro_input_poll_null(void); + +static void uninit_libretro_symbols(struct retro_core_t *current_core); +static bool init_libretro_symbols(enum rarch_core_type type, + struct retro_core_t *current_core); + +static void ui_companion_driver_deinit(void); + +static bool audio_driver_stop(void); +static bool audio_driver_start(bool is_shutdown); + +static bool recording_init(void); +static bool recording_deinit(void); + +#ifdef HAVE_OVERLAY +static void retroarch_overlay_init(void); +static void retroarch_overlay_deinit(void); +#endif + +static void video_driver_gpu_record_deinit(void); +static retro_proc_address_t video_driver_get_proc_address(const char *sym); +static uintptr_t video_driver_get_current_framebuffer(void); +static bool video_driver_find_driver(void); + +static int16_t input_state(unsigned port, unsigned device, + unsigned idx, unsigned id); + +#ifdef HAVE_OVERLAY +static void input_overlay_set_alpha_mod(input_overlay_t *ol, float mod); +static void input_overlay_set_scale_factor(input_overlay_t *ol, float scale); +static void input_overlay_load_active(input_overlay_t *ol, float opacity); +static void input_overlay_auto_rotate(input_overlay_t *ol); +#endif + +static void bsv_movie_deinit(void); +static bool bsv_movie_init(void); +static bool bsv_movie_check(void); + +static void driver_uninit(int flags); +static void drivers_init(int flags); + +#if defined(HAVE_RUNAHEAD) +static void core_free_retro_game_info(struct retro_game_info *dest); +#endif +static bool core_load(unsigned poll_type_behavior); +static bool core_unload_game(void); + +static bool rarch_environment_cb(unsigned cmd, void *data); + +static bool driver_location_get_position(double *lat, double *lon, + double *horiz_accuracy, double *vert_accuracy); +static void driver_location_set_interval(unsigned interval_msecs, + unsigned interval_distance); +static void driver_location_stop(void); +static bool driver_location_start(void); +static void driver_camera_stop(void); +static bool driver_camera_start(void); + struct string_list *dir_list_new_special(const char *input_dir, enum dir_list_type type, const char *filter, @@ -2627,11 +3341,6 @@ void dir_check_defaults(void) } #ifdef HAVE_ACCESSIBILITY -/* Is text-to-speech accessibility turned on? */ -static bool accessibility_enabled = false; - -/* Accessibility */ - bool is_accessibility_enabled(void) { settings_t *settings = configuration_settings; @@ -2642,13 +3351,6 @@ bool is_accessibility_enabled(void) } #endif -#ifdef HAVE_GFX_WIDGETS -/* Status icons */ -static bool gfx_widgets_paused = false; -static bool gfx_widgets_fast_forward = false; -static bool gfx_widgets_rewinding = false; -#endif - bool gfx_widgets_ready(void) { #ifdef HAVE_GFX_WIDGETS @@ -2659,24 +3361,6 @@ bool gfx_widgets_ready(void) } #ifdef HAVE_MENU -/* MENU INPUT GLOBAL VARIABLES */ -static const char **menu_input_dialog_keyboard_buffer = {NULL}; -static unsigned menu_input_dialog_keyboard_type = 0; -static unsigned menu_input_dialog_keyboard_idx = 0; -static char menu_input_dialog_keyboard_label_setting[256] = {0}; -static char menu_input_dialog_keyboard_label[256] = {0}; -static bool menu_input_dialog_keyboard_display = false; -static unsigned char menu_keyboard_key_state[RETROK_LAST] = {0}; - -/* Since these are static/global, they are initialised to zero */ -static menu_input_pointer_hw_state_t menu_input_pointer_hw_state; -static menu_input_t menu_input_state; - -/* Is the menu driver still running? */ -static bool menu_driver_alive = false; -/* Are we binding a button inside the menu? */ -static bool menu_driver_is_binding = false; - #ifdef HAVE_LIBNX #define LIBNX_SWKBD_LIMIT 500 /* enforced by HOS */ extern u32 __nx_applet_type; @@ -2877,24 +3561,7 @@ void menu_driver_set_binding_state(bool on) #endif -/* RECORDING GLOBAL VARIABLES */ -static unsigned recording_width = 0; -static unsigned recording_height = 0; -static size_t recording_gpu_width = 0; -static size_t recording_gpu_height = 0; -static bool recording_enable = false; -static bool streaming_enable = false; - -static const record_driver_t *recording_driver = NULL; -static void *recording_data = NULL; - -static uint8_t *video_driver_record_gpu_buffer = NULL; - -/* MESSAGE QUEUE GLOBAL VARIABLES */ - #ifdef HAVE_THREADS -static slock_t *_runloop_msg_queue_lock = NULL; - #define runloop_msg_queue_lock() slock_lock(_runloop_msg_queue_lock) #define runloop_msg_queue_unlock() slock_unlock(_runloop_msg_queue_lock) #else @@ -2902,71 +3569,6 @@ static slock_t *_runloop_msg_queue_lock = NULL; #define runloop_msg_queue_unlock() #endif -/* CAMERA GLOBAL VARIABLES */ - -static struct retro_camera_callback camera_cb; -static const camera_driver_t *camera_driver = NULL; -static void *camera_data = NULL; -static bool camera_driver_active = false; - -/* MIDI GLOBAL VARIABLES */ - -#define MIDI_DRIVER_BUF_SIZE 4096 - -static midi_driver_t *midi_drv = &midi_null; -static void *midi_drv_data = NULL; -static struct string_list *midi_drv_inputs = NULL; -static struct string_list *midi_drv_outputs = NULL; -static bool midi_drv_input_enabled = false; -static bool midi_drv_output_enabled = false; -static uint8_t *midi_drv_input_buffer = NULL; -static uint8_t *midi_drv_output_buffer = NULL; -static midi_event_t midi_drv_input_event; -static midi_event_t midi_drv_output_event; -static bool midi_drv_output_pending = false; - -static const uint8_t midi_drv_ev_sizes[128] = -{ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 0, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 -}; - - -/* UI COMPANION GLOBAL VARIABLES */ - -static bool main_ui_companion_is_on_foreground = false; -static const ui_companion_driver_t *ui_companion = NULL; -static void *ui_companion_data = NULL; - -#ifdef HAVE_QT -static void *ui_companion_qt_data = NULL; -static bool qt_is_inited = false; -#endif - -/* LOCATION GLOBAL VARIABLES */ -static const location_driver_t *location_driver = NULL; -static void *location_data = NULL; - -static bool location_driver_active = false; - -/* WIFI GLOBAL VARIABLES */ -static const wifi_driver_t *wifi_driver = NULL; -static void *wifi_data = NULL; -static bool wifi_driver_active = false; - -/* VIDEO GLOBAL VARIABLES */ - -static const video_display_server_t *current_display_server = &dispserv_null; -static void *current_display_server_data = NULL; -static enum rotation initial_screen_orientation = ORIENTATION_NORMAL; -static enum rotation current_screen_orientation = ORIENTATION_NORMAL; - #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) static void retroarch_set_runtime_shader_preset(const char *arg) { @@ -2984,10 +3586,6 @@ static void retroarch_unset_runtime_shader_preset(void) #endif } -#define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024) - -#define TIME_TO_FPS(last_time, new_time, frames) ((1000000.0f * (frames)) / ((new_time) - (last_time))) - #ifdef HAVE_THREADS #define video_driver_is_threaded_internal() ((!video_driver_is_hw_context() && video_driver_threaded) ? true : false) #else @@ -3034,549 +3632,6 @@ static void retroarch_unset_runtime_shader_preset(void) #define video_driver_context_unlock() ((void)0) #endif -typedef struct video_pixel_scaler -{ - struct scaler_ctx *scaler; - void *scaler_out; -} video_pixel_scaler_t; - -typedef struct -{ - enum gfx_ctx_api api; - struct string_list *list; -} gfx_api_gpu_map; - -struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { - { "4:3", 1.3333f }, - { "16:9", 1.7778f }, - { "16:10", 1.6f }, - { "16:15", 16.0f / 15.0f }, - { "21:9", 21.0f / 9.0f }, - { "1:1", 1.0f }, - { "2:1", 2.0f }, - { "3:2", 1.5f }, - { "3:4", 0.75f }, - { "4:1", 4.0f }, - { "9:16", 0.5625f }, - { "5:4", 1.25f }, - { "6:5", 1.2f }, - { "7:9", 0.7777f }, - { "8:3", 2.6666f }, - { "8:7", 1.1428f }, - { "19:12", 1.5833f }, - { "19:14", 1.3571f }, - { "30:17", 1.7647f }, - { "32:9", 3.5555f }, - { "Config", 0.0f }, - { "Square pixel", 1.0f }, - { "Core provided", 1.0f }, - { "Custom", 0.0f } -}; - -static gfx_api_gpu_map gpu_map[] = { - { GFX_CTX_VULKAN_API, NULL }, - { GFX_CTX_DIRECT3D10_API, NULL }, - { GFX_CTX_DIRECT3D11_API, NULL }, - { GFX_CTX_DIRECT3D12_API, NULL } -}; - - -/* Opaque handles to currently running window. - * Used by e.g. input drivers which bind to a window. - * Drivers are responsible for setting these if an input driver - * could potentially make use of this. */ -static uintptr_t video_driver_display_userdata = 0; -static uintptr_t video_driver_display = 0; -static uintptr_t video_driver_window = 0; - -static rarch_softfilter_t *video_driver_state_filter = NULL; -static void *video_driver_state_buffer = NULL; -static unsigned video_driver_state_scale = 0; -static unsigned video_driver_state_out_bpp = 0; -static bool video_driver_state_out_rgb32 = false; -static bool video_driver_crt_switching_active = false; -static bool video_driver_crt_dynamic_super_width = false; - -static enum retro_pixel_format video_driver_pix_fmt = RETRO_PIXEL_FORMAT_0RGB1555; - -static const void *frame_cache_data = NULL; -static unsigned frame_cache_width = 0; -static unsigned frame_cache_height = 0; -static size_t frame_cache_pitch = 0; -static bool video_driver_threaded = false; - -static float video_driver_core_hz = 0.0f; -static float video_driver_aspect_ratio = 0.0f; -static unsigned video_driver_width = 0; -static unsigned video_driver_height = 0; - -static enum rarch_display_type video_driver_display_type = RARCH_DISPLAY_NONE; -static char video_driver_title_buf[64] = {0}; -static char video_driver_window_title[512] = {0}; -static bool video_driver_window_title_update = true; - -static retro_time_t video_driver_frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT]; -static uint64_t video_driver_frame_time_count = 0; -static uint64_t video_driver_frame_count = 0; - -static void *video_driver_data = NULL; -static video_driver_t *current_video = NULL; - -/* Interface for "poking". */ -static const video_poke_interface_t *video_driver_poke = NULL; - -/* Used for 15-bit -> 16-bit conversions that take place before - * being passed to video driver. */ -static video_pixel_scaler_t *video_driver_scaler_ptr = NULL; - -static struct retro_hw_render_callback hw_render; - -static const struct -retro_hw_render_context_negotiation_interface * -hw_render_context_negotiation = NULL; - -/* Graphics driver requires RGBA byte order data (ABGR on little-endian) - * for 32-bit. - * This takes effect for overlay and shader cores that wants to load - * data into graphics driver. Kinda hackish to place it here, it is only - * used for GLES. - * TODO: Refactor this better. */ -static bool video_driver_use_rgba = false; -static bool video_driver_active = false; - -static video_driver_frame_t frame_bak = NULL; - -/* If set during context deinit, the driver should keep - * graphics context alive to avoid having to reset all - * context state. */ -static bool video_driver_cache_context = false; - -/* Set to true by driver if context caching succeeded. */ -static bool video_driver_cache_context_ack = false; - -#ifdef HAVE_THREADS -static slock_t *display_lock = NULL; -static slock_t *context_lock = NULL; -#endif - -static gfx_ctx_driver_t current_video_context; - -static void *video_context_data = NULL; - -/** - * dynamic.c:dynamic_request_hw_context will try to set flag data when the context - * is in the middle of being rebuilt; in these cases we will save flag - * data and set this to true. - * When the context is reinit, it checks this, reads from - * deferred_flag_data and cleans it. - * - * TODO - Dirty hack, fix it better - */ -static bool deferred_video_context_driver_set_flags = false; -static gfx_ctx_flags_t deferred_flag_data = {0}; - -static bool video_started_fullscreen = false; - -static char video_driver_gpu_device_string[128] = {0}; -static char video_driver_gpu_api_version_string[128] = {0}; - -static struct retro_system_av_info video_driver_av_info; - -/* AUDIO GLOBAL VARIABLES */ -#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024) - -#define MENU_SOUND_FORMATS "ogg|mod|xm|s3m|mp3|flac" - -/** - * db_to_gain: - * @db : Decibels. - * - * Converts decibels to voltage gain. - * - * Returns: voltage gain value. - **/ -#define db_to_gain(db) (powf(10.0f, (db) / 20.0f)) - - -#ifdef HAVE_AUDIOMIXER -static struct audio_mixer_stream -audio_mixer_streams[AUDIO_MIXER_MAX_SYSTEM_STREAMS] = {{0}}; - -static bool audio_driver_mixer_mute_enable = false; -static bool audio_mixer_active = false; -static float audio_driver_mixer_volume_gain = 0.0f; -#endif - -static size_t audio_driver_chunk_size = 0; -static size_t audio_driver_chunk_nonblock_size = 0; -static size_t audio_driver_chunk_block_size = 0; - -static size_t audio_driver_rewind_ptr = 0; -static size_t audio_driver_rewind_size = 0; - -static int16_t *audio_driver_rewind_buf = NULL; -static int16_t *audio_driver_output_samples_conv_buf = NULL; - -static unsigned audio_driver_free_samples_buf[AUDIO_BUFFER_FREE_SAMPLES_COUNT]; -static uint64_t audio_driver_free_samples_count = 0; - -static size_t audio_driver_buffer_size = 0; -static size_t audio_driver_data_ptr = 0; - -static bool audio_driver_control = false; -static bool audio_driver_mute_enable = false; -static bool audio_driver_use_float = false; -static bool audio_driver_active = false; - -static float audio_driver_rate_control_delta = 0.0f; -static float audio_driver_input = 0.0f; -static float audio_driver_volume_gain = 0.0f; - -static float *audio_driver_input_data = NULL; -static float *audio_driver_output_samples_buf = NULL; - -static double audio_source_ratio_original = 0.0f; -static double audio_source_ratio_current = 0.0f; - -static struct retro_audio_callback audio_callback = {0}; - -static retro_dsp_filter_t *audio_driver_dsp = NULL; -static struct string_list *audio_driver_devices_list = NULL; -static const retro_resampler_t *audio_driver_resampler = NULL; - -static void *audio_driver_resampler_data = NULL; -static const audio_driver_t *current_audio = NULL; -static void *audio_driver_context_audio_data = NULL; - -static bool audio_suspended = false; -static bool audio_is_threaded = false; - -/* RUNAHEAD GLOBAL VARIABLES */ - -typedef struct input_list_element_t -{ - unsigned port; - unsigned device; - unsigned index; - int16_t *state; - unsigned int state_size; -} input_list_element; - -#ifdef HAVE_RUNAHEAD -static size_t runahead_save_state_size = 0; - -static bool runahead_save_state_size_known = false; -static bool request_fast_savestate = false; -static bool hard_disable_audio = false; - -/* Save State List for Run Ahead */ -typedef void *(*constructor_t)(void); -typedef void (*destructor_t )(void*); - -typedef struct MyList_t -{ - void **data; - int capacity; - int size; - constructor_t constructor; - destructor_t destructor; -} MyList; - -static MyList *runahead_save_state_list = NULL; -static MyList *input_state_list = NULL; - -static bool input_is_dirty = false; - -typedef bool(*runahead_load_state_function)(const void*, size_t); - -static retro_input_state_t input_state_callback_original; -static function_t retro_reset_callback_original = NULL; -static runahead_load_state_function -retro_unserialize_callback_original = NULL; - -static function_t original_retro_deinit = NULL; -static function_t original_retro_unload = NULL; - -static bool runahead_video_driver_is_active = true; -static bool runahead_available = true; -static bool runahead_secondary_core_available = true; -static bool runahead_force_input_dirty = true; -static uint64_t runahead_last_frame_count = 0; -#endif - -#if defined(HAVE_NETWORKING) -/* NETWORKING GLOBAL VARIABLES */ - -static bool has_set_netplay_mode = false; -static bool has_set_netplay_ip_address = false; -static bool has_set_netplay_ip_port = false; -static bool has_set_netplay_stateless_mode = false; -static bool has_set_netplay_check_frames = false; -#endif - -/* INPUT REMOTE GLOBAL VARIABLES */ - -#define DEFAULT_NETWORK_GAMEPAD_PORT 55400 -#define UDP_FRAME_PACKETS 16 - -struct remote_message -{ - int port; - int device; - int index; - int id; - uint16_t state; -}; - -struct input_remote -{ - bool state[RARCH_BIND_LIST_END]; -#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) - int net_fd[MAX_USERS]; -#endif -}; - -typedef struct input_remote input_remote_t; - -typedef struct input_remote_state -{ - /* Left X, Left Y, Right X, Right Y */ - int16_t analog[4][MAX_USERS]; - /* This is a bitmask of (1 << key_bind_id). */ - uint64_t buttons[MAX_USERS]; -} input_remote_state_t; - -#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) -static input_remote_state_t remote_st_ptr; -#endif - -/* INPUT OVERLAY GLOBAL VARIABLES */ -#ifdef HAVE_OVERLAY - -#define OVERLAY_GET_KEY(state, key) (((state)->keys[(key) / 32] >> ((key) % 32)) & 1) -#define OVERLAY_SET_KEY(state, key) (state)->keys[(key) / 32] |= 1 << ((key) % 32) - -#define MAX_VISIBILITY 32 - -static enum overlay_visibility* visibility = NULL; - -typedef struct input_overlay_state -{ - /* Left X, Left Y, Right X, Right Y */ - int16_t analog[4]; - uint32_t keys[RETROK_LAST / 32 + 1]; - /* This is a bitmask of (1 << key_bind_id). */ - input_bits_t buttons; -} input_overlay_state_t; - -struct input_overlay -{ - enum overlay_status state; - - bool enable; - bool blocked; - bool alive; - - unsigned next_index; - - size_t index; - size_t size; - - struct overlay *overlays; - const struct overlay *active; - void *iface_data; - const video_overlay_interface_t *iface; - - input_overlay_state_t overlay_state; -}; - -static input_overlay_t *overlay_ptr = NULL; -#endif - -/* INPUT GLOBAL VARIABLES */ - -/* Input config. */ -struct input_bind_map -{ - bool valid; - - /* Meta binds get input as prefix, not input_playerN". - * 0 = libretro related. - * 1 = Common hotkey. - * 2 = Uncommon/obscure hotkey. - */ - uint8_t meta; - - const char *base; - enum msg_hash_enums desc; - uint8_t retro_key; -}; - -static pad_connection_listener_t *pad_connection_listener = NULL; - -static uint16_t input_config_vid[MAX_USERS]; -static uint16_t input_config_pid[MAX_USERS]; - -static char input_device_display_names[MAX_INPUT_DEVICES][64]; -static char input_device_config_names [MAX_INPUT_DEVICES][64]; -static char input_device_config_paths [MAX_INPUT_DEVICES][64]; -char input_device_names [MAX_INPUT_DEVICES][64]; - -uint64_t lifecycle_state; -struct retro_keybind input_config_binds[MAX_USERS][RARCH_BIND_LIST_END]; -struct retro_keybind input_autoconf_binds[MAX_USERS][RARCH_BIND_LIST_END]; -static const struct retro_keybind *libretro_input_binds[MAX_USERS]; - -#define DECLARE_BIND(x, bind, desc) { true, 0, #x, desc, bind } -#define DECLARE_META_BIND(level, x, bind, desc) { true, level, #x, desc, bind } - -const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { - DECLARE_BIND(b, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B), - DECLARE_BIND(y, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y), - DECLARE_BIND(select, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT), - DECLARE_BIND(start, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START), - DECLARE_BIND(up, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP), - DECLARE_BIND(down, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN), - DECLARE_BIND(left, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT), - DECLARE_BIND(right, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT), - DECLARE_BIND(a, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A), - DECLARE_BIND(x, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X), - DECLARE_BIND(l, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L), - DECLARE_BIND(r, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R), - DECLARE_BIND(l2, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2), - DECLARE_BIND(r2, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2), - DECLARE_BIND(l3, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3), - DECLARE_BIND(r3, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3), - DECLARE_BIND(l_x_plus, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS), - DECLARE_BIND(l_x_minus, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS), - DECLARE_BIND(l_y_plus, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS), - DECLARE_BIND(l_y_minus, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS), - DECLARE_BIND(r_x_plus, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS), - DECLARE_BIND(r_x_minus, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS), - DECLARE_BIND(r_y_plus, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS), - DECLARE_BIND(r_y_minus, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS), - - DECLARE_BIND( gun_trigger, RARCH_LIGHTGUN_TRIGGER, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER ), - DECLARE_BIND( gun_offscreen_shot, RARCH_LIGHTGUN_RELOAD, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD ), - DECLARE_BIND( gun_aux_a, RARCH_LIGHTGUN_AUX_A, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A ), - DECLARE_BIND( gun_aux_b, RARCH_LIGHTGUN_AUX_B, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B ), - DECLARE_BIND( gun_aux_c, RARCH_LIGHTGUN_AUX_C, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C ), - DECLARE_BIND( gun_start, RARCH_LIGHTGUN_START, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START ), - DECLARE_BIND( gun_select, RARCH_LIGHTGUN_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT ), - DECLARE_BIND( gun_dpad_up, RARCH_LIGHTGUN_DPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP ), - DECLARE_BIND( gun_dpad_down, RARCH_LIGHTGUN_DPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN ), - DECLARE_BIND( gun_dpad_left, RARCH_LIGHTGUN_DPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT ), - DECLARE_BIND( gun_dpad_right, RARCH_LIGHTGUN_DPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT ), - - DECLARE_BIND(turbo, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE), - - DECLARE_META_BIND(1, toggle_fast_forward, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY), - DECLARE_META_BIND(2, hold_fast_forward, RARCH_FAST_FORWARD_HOLD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY), - DECLARE_META_BIND(1, toggle_slowmotion, RARCH_SLOWMOTION_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION_KEY), - DECLARE_META_BIND(2, hold_slowmotion, RARCH_SLOWMOTION_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION_HOLD_KEY), - DECLARE_META_BIND(1, load_state, RARCH_LOAD_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY), - DECLARE_META_BIND(1, save_state, RARCH_SAVE_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY), - DECLARE_META_BIND(2, toggle_fullscreen, RARCH_FULLSCREEN_TOGGLE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY), -#ifdef HAVE_LAKKA - DECLARE_META_BIND(2, exit_emulator, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_RESTART_KEY), -#else - DECLARE_META_BIND(2, exit_emulator, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY), -#endif - DECLARE_META_BIND(2, state_slot_increase, RARCH_STATE_SLOT_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS), - DECLARE_META_BIND(2, state_slot_decrease, RARCH_STATE_SLOT_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS), - DECLARE_META_BIND(1, rewind, RARCH_REWIND, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND), - DECLARE_META_BIND(2, movie_record_toggle, RARCH_BSV_RECORD_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_BSV_RECORD_TOGGLE), - DECLARE_META_BIND(2, pause_toggle, RARCH_PAUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE), - DECLARE_META_BIND(2, frame_advance, RARCH_FRAMEADVANCE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE), - DECLARE_META_BIND(2, reset, RARCH_RESET, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET), - DECLARE_META_BIND(2, shader_next, RARCH_SHADER_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT), - DECLARE_META_BIND(2, shader_prev, RARCH_SHADER_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV), - DECLARE_META_BIND(2, cheat_index_plus, RARCH_CHEAT_INDEX_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS), - DECLARE_META_BIND(2, cheat_index_minus, RARCH_CHEAT_INDEX_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS), - DECLARE_META_BIND(2, cheat_toggle, RARCH_CHEAT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE), - DECLARE_META_BIND(2, screenshot, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT), - DECLARE_META_BIND(2, audio_mute, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE), - DECLARE_META_BIND(2, osk_toggle, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK), - DECLARE_META_BIND(2, fps_toggle, RARCH_FPS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE), - DECLARE_META_BIND(2, send_debug_info, RARCH_SEND_DEBUG_INFO, MENU_ENUM_LABEL_VALUE_INPUT_META_SEND_DEBUG_INFO), - DECLARE_META_BIND(2, netplay_host_toggle, RARCH_NETPLAY_HOST_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_HOST_TOGGLE), - DECLARE_META_BIND(2, netplay_game_watch, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH), - DECLARE_META_BIND(2, enable_hotkey, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY), - DECLARE_META_BIND(2, volume_up, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP), - DECLARE_META_BIND(2, volume_down, RARCH_VOLUME_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN), - DECLARE_META_BIND(2, overlay_next, RARCH_OVERLAY_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT), - DECLARE_META_BIND(2, disk_eject_toggle, RARCH_DISK_EJECT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE), - DECLARE_META_BIND(2, disk_next, RARCH_DISK_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT), - DECLARE_META_BIND(2, disk_prev, RARCH_DISK_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV), - DECLARE_META_BIND(2, grab_mouse_toggle, RARCH_GRAB_MOUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE), - DECLARE_META_BIND(2, game_focus_toggle, RARCH_GAME_FOCUS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE), - DECLARE_META_BIND(2, desktop_menu_toggle, RARCH_UI_COMPANION_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_UI_COMPANION_TOGGLE), -#ifdef HAVE_MENU - DECLARE_META_BIND(1, menu_toggle, RARCH_MENU_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE), -#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, ai_service, RARCH_AI_SERVICE, MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE), -}; - -typedef struct turbo_buttons turbo_buttons_t; - -/* Turbo support. */ -struct turbo_buttons -{ - bool frame_enable[MAX_USERS]; - uint16_t enable[MAX_USERS]; - bool mode1_enable[MAX_USERS]; - int32_t turbo_pressed[MAX_USERS]; - unsigned count; -}; - -struct input_keyboard_line -{ - char *buffer; - size_t ptr; - size_t size; - - /** Line complete callback. - * Calls back after return is - * pressed with the completed line. - * Line can be NULL. - **/ - input_keyboard_line_complete_t cb; - void *userdata; -}; - -static bool input_driver_keyboard_linefeed_enable = false; -static input_keyboard_line_t *g_keyboard_line = NULL; - -static void *g_keyboard_press_data = NULL; - -static unsigned osk_last_codepoint = 0; -static unsigned osk_last_codepoint_len = 0; - -static input_keyboard_press_t g_keyboard_press_cb; - -static turbo_buttons_t input_driver_turbo_btns; -#ifdef HAVE_COMMAND -static command_t *input_driver_command = NULL; -#endif -#ifdef HAVE_NETWORKGAMEPAD -static input_remote_t *input_driver_remote = NULL; -#endif -static input_mapper_t *input_driver_mapper = NULL; -static input_driver_t *current_input = NULL; -static void *current_input_data = NULL; -static bool input_driver_block_hotkey = false; -static bool input_driver_block_libretro_input = false; -static bool input_driver_nonblock_state = false; -static unsigned input_driver_flushing_input = 0; -static float input_driver_axis_threshold = 0.0f; -static unsigned input_driver_max_users = 0; - -#ifdef HAVE_HID -static const void *hid_data = NULL; -#endif - #ifdef HAVE_THREADS #define video_driver_get_ptr_internal(force) ((video_driver_is_threaded_internal() && !force) ? video_thread_get_ptr(NULL) : video_driver_data) #else @@ -3584,9 +3639,6 @@ static const void *hid_data = NULL; #endif #if defined(HAVE_RUNAHEAD) -static enum rarch_core_type last_core_type; -static retro_ctx_load_content_info_t *load_content_info; - #if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB) static char *strcpy_alloc(const char *src) { @@ -3609,85 +3661,9 @@ static char *strcpy_alloc_force(const char *src) return result; } -/* Forward declarations */ -static bool secondary_core_create(void); -static int16_t input_state_get_last(unsigned port, - unsigned device, unsigned index, unsigned id); - -/* RUNAHEAD - SECONDARY CORE GLOBAL VARIABLES */ -static int port_map[16]; - -static dylib_t secondary_module; -static struct retro_core_t secondary_core; -static struct retro_callbacks secondary_callbacks; -static char *secondary_library_path = NULL; #endif #endif -/* Forward declarations */ -static void video_driver_frame(const void *data, unsigned width, - unsigned height, size_t pitch); -static void retro_frame_null(const void *data, unsigned width, - unsigned height, size_t pitch); -static void retro_run_null(void); -static void retro_input_poll_null(void); - -static void uninit_libretro_symbols(struct retro_core_t *current_core); -static bool init_libretro_symbols(enum rarch_core_type type, - struct retro_core_t *current_core); - -static void ui_companion_driver_deinit(void); - -static bool audio_driver_stop(void); -static bool audio_driver_start(bool is_shutdown); - -static bool recording_init(void); -static bool recording_deinit(void); - -#ifdef HAVE_OVERLAY -static void retroarch_overlay_init(void); -static void retroarch_overlay_deinit(void); -#endif - -static void video_driver_gpu_record_deinit(void); -static retro_proc_address_t video_driver_get_proc_address(const char *sym); -static uintptr_t video_driver_get_current_framebuffer(void); -static bool video_driver_find_driver(void); - -static int16_t input_state(unsigned port, unsigned device, - unsigned idx, unsigned id); - -#ifdef HAVE_OVERLAY -static void input_overlay_set_alpha_mod(input_overlay_t *ol, float mod); -static void input_overlay_set_scale_factor(input_overlay_t *ol, float scale); -static void input_overlay_load_active(input_overlay_t *ol, float opacity); -static void input_overlay_auto_rotate(input_overlay_t *ol); -#endif - -static void bsv_movie_deinit(void); -static bool bsv_movie_init(void); -static bool bsv_movie_check(void); - -static void driver_uninit(int flags); -static void drivers_init(int flags); - -#if defined(HAVE_RUNAHEAD) -static void core_free_retro_game_info(struct retro_game_info *dest); -#endif -static bool core_load(unsigned poll_type_behavior); -static bool core_unload_game(void); - -static bool rarch_environment_cb(unsigned cmd, void *data); - -static bool driver_location_get_position(double *lat, double *lon, - double *horiz_accuracy, double *vert_accuracy); -static void driver_location_set_interval(unsigned interval_msecs, - unsigned interval_distance); -static void driver_location_stop(void); -static bool driver_location_start(void); -static void driver_camera_stop(void); -static bool driver_camera_start(void); - /* GLOBAL POINTER GETTERS */ #define video_driver_get_hw_context_internal() (&hw_render)