From 49fbed2423cb83695f2921092b9d3b8623b1723b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 30 Sep 2021 23:22:50 +0200 Subject: [PATCH] Get rid of input_mouse_grabbed - move retroarch types to retroarch_types.h --- cheevos/cheevos_client.c | 3 +- command.h | 3 +- core.h | 122 +--- core_type.h | 32 -- dynamic.h | 2 +- gfx/common/win32_common.c | 12 +- input/input_driver.h | 32 +- input/input_remapping.h | 12 - input/input_types.h | 23 + .../RetroArch_Metal.xcodeproj/project.pbxproj | 2 - .../project.pbxproj | 2 - retroarch.c | 451 ++++++++------- retroarch.h | 380 +------------ retroarch_data.h | 32 -- retroarch_types.h | 528 ++++++++++++++++++ tasks/task_content.h | 2 +- ui/drivers/ui_qt.cpp | 2 +- 17 files changed, 833 insertions(+), 807 deletions(-) delete mode 100644 core_type.h create mode 100644 retroarch_types.h diff --git a/cheevos/cheevos_client.c b/cheevos/cheevos_client.c index 138ad8e09a..98e8ce9521 100644 --- a/cheevos/cheevos_client.c +++ b/cheevos/cheevos_client.c @@ -19,6 +19,7 @@ #include "../configuration.h" #include "../paths.h" +#include "../retroarch.h" #include "../version.h" #include @@ -34,8 +35,6 @@ #include "../deps/rcheevos/include/rc_api_runtime.h" - - /* Define this macro to log URLs. */ #undef CHEEVOS_LOG_URLS diff --git a/command.h b/command.h index 087c9b9bb0..e05d708ce9 100644 --- a/command.h +++ b/command.h @@ -29,9 +29,10 @@ #include -#include "retroarch.h" +#include "retroarch_types.h" #include "input/input_defines.h" +#include "configuration.h" RETRO_BEGIN_DECLS diff --git a/core.h b/core.h index 5f2c733cbd..a054d11404 100644 --- a/core.h +++ b/core.h @@ -23,130 +23,10 @@ #include -#include "core_type.h" -#include "input/input_defines.h" -#include "disk_control_interface.h" +#include "retroarch_types.h" RETRO_BEGIN_DECLS -enum -{ - /* Polling is performed before - * call to retro_run. */ - POLL_TYPE_EARLY = 0, - - /* Polling is performed when requested. */ - POLL_TYPE_NORMAL, - - /* Polling is performed on first call to - * retro_input_state per frame. */ - POLL_TYPE_LATE -}; - -typedef struct rarch_memory_descriptor -{ - struct retro_memory_descriptor core; /* uint64_t alignment */ - size_t disconnect_mask; -} rarch_memory_descriptor_t; - -typedef struct rarch_memory_map -{ - rarch_memory_descriptor_t *descriptors; - unsigned num_descriptors; -} rarch_memory_map_t; - -typedef struct rarch_system_info -{ - struct retro_location_callback location_cb; /* ptr alignment */ - disk_control_interface_t disk_control; /* ptr alignment */ - struct retro_system_info info; /* ptr alignment */ - rarch_memory_map_t mmaps; /* ptr alignment */ - const char *input_desc_btn[MAX_USERS][RARCH_FIRST_META_KEY]; - struct - { - struct retro_subsystem_info *data; - unsigned size; - } subsystem; - struct - { - struct retro_controller_info *data; - unsigned size; - } ports; - unsigned rotation; - unsigned performance_level; - char valid_extensions[255]; - bool load_no_content; - bool supports_vfs; -} rarch_system_info_t; - -typedef struct retro_ctx_input_state_info -{ - retro_input_state_t cb; -} retro_ctx_input_state_info_t; - -typedef struct retro_ctx_cheat_info -{ - const char *code; - unsigned index; - bool enabled; -} retro_ctx_cheat_info_t; - -typedef struct retro_ctx_api_info -{ - unsigned version; -} retro_ctx_api_info_t; - -typedef struct retro_ctx_region_info -{ - unsigned region; -} retro_ctx_region_info_t; - -typedef struct retro_ctx_controller_info -{ - unsigned port; - unsigned device; -} retro_ctx_controller_info_t; - -typedef struct retro_ctx_memory_info -{ - void *data; - size_t size; - unsigned id; -} retro_ctx_memory_info_t; - -typedef struct retro_ctx_load_content_info -{ - struct retro_game_info *info; - const struct string_list *content; - const struct retro_subsystem_info *special; -} retro_ctx_load_content_info_t; - -typedef struct retro_ctx_serialize_info -{ - const void *data_const; - void *data; - size_t size; -} retro_ctx_serialize_info_t; - -typedef struct retro_ctx_size_info -{ - size_t size; -} retro_ctx_size_info_t; - -typedef struct retro_ctx_environ_info -{ - retro_environment_t env; -} retro_ctx_environ_info_t; - -typedef struct retro_callbacks -{ - retro_video_refresh_t frame_cb; - retro_audio_sample_t sample_cb; - retro_audio_sample_batch_t sample_batch_cb; - retro_input_state_t state_cb; - retro_input_poll_t poll_cb; -} retro_callbacks_t; - #ifdef HAVE_REWIND bool core_set_rewind_callbacks(void); #endif diff --git a/core_type.h b/core_type.h deleted file mode 100644 index 5c477f2396..0000000000 --- a/core_type.h +++ /dev/null @@ -1,32 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2011-2017 - Daniel De Matteis - * Copyright (C) 2016-2019 - Brad Parker - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#ifndef __CORE_TYPE_H -#define __CORE_TYPE_H - -enum rarch_core_type -{ - CORE_TYPE_PLAIN = 0, - CORE_TYPE_DUMMY, - CORE_TYPE_FFMPEG, - CORE_TYPE_MPV, - CORE_TYPE_IMAGEVIEWER, - CORE_TYPE_NETRETROPAD, - CORE_TYPE_VIDEO_PROCESSOR, - CORE_TYPE_GONG -}; - -#endif diff --git a/dynamic.h b/dynamic.h index cdb9d46743..76169e327c 100644 --- a/dynamic.h +++ b/dynamic.h @@ -22,7 +22,7 @@ #include #include -#include "core_type.h" +#include "retroarch_types.h" RETRO_BEGIN_DECLS diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index cf9180a128..f4bd98a052 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -1053,11 +1053,11 @@ static LRESULT CALLBACK wnd_proc_common_internal(HWND hwnd, break; #ifdef HAVE_CLIP_WINDOW case WM_SETFOCUS: - if (input_mouse_grabbed()) + if (input_state_get_ptr()->grab_mouse_state) win32_clip_window(true); break; case WM_KILLFOCUS: - if (input_mouse_grabbed()) + if (input_state_get_ptr()->grab_mouse_state) win32_clip_window(false); break; #endif @@ -1128,7 +1128,7 @@ static LRESULT CALLBACK wnd_proc_winraw_common_internal(HWND hwnd, break; case WM_SETFOCUS: #ifdef HAVE_CLIP_WINDOW - if (input_mouse_grabbed()) + if (input_state_get_ptr()->grab_mouse_state) win32_clip_window(true); #endif #if !defined(_XBOX) @@ -1138,7 +1138,7 @@ static LRESULT CALLBACK wnd_proc_winraw_common_internal(HWND hwnd, break; case WM_KILLFOCUS: #ifdef HAVE_CLIP_WINDOW - if (input_mouse_grabbed()) + if (input_state_get_ptr()->grab_mouse_state) win32_clip_window(false); #endif #if !defined(_XBOX) @@ -1264,11 +1264,11 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd, break; #ifdef HAVE_CLIP_WINDOW case WM_SETFOCUS: - if (input_mouse_grabbed()) + if (input_state_get_ptr()->grab_mouse_state) win32_clip_window(true); break; case WM_KILLFOCUS: - if (input_mouse_grabbed()) + if (input_state_get_ptr()->grab_mouse_state) win32_clip_window(false); break; #endif diff --git a/input/input_driver.h b/input/input_driver.h index 9b6a46af88..ccb9bcdb3c 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -45,6 +45,10 @@ #include "../configuration.h" #include "../performance_counters.h" +#ifdef HAVE_COMMAND +#include "../command.h" +#endif + RETRO_BEGIN_DECLS /** @@ -294,19 +298,37 @@ struct rarch_joypad_driver typedef struct { + /** + * Array of timers, one for each entry in enum input_combo_type. + */ + rarch_timer_t combo_timers[INPUT_COMBO_LAST]; + /* pointers */ input_driver_t *current_driver; void *current_data; const input_device_driver_t *primary_joypad; /* ptr alignment */ const input_device_driver_t *secondary_joypad; /* ptr alignment */ +#ifdef HAVE_COMMAND + command_t *command[MAX_CMD_DRIVERS]; +#endif +#ifdef HAVE_NETWORKGAMEPAD + input_remote_t *remote; +#endif + + turbo_buttons_t turbo_btns; /* int32_t alignment */ + + input_mapper_t mapper; /* uint32_t alignment */ /* primitives */ bool nonblocking_flag; + bool keyboard_linefeed_enable; + + bool block_hotkey; + bool block_libretro_input; + bool grab_mouse_state; + bool analog_requested[MAX_USERS]; + bool keyboard_mapping_blocked; - /** - * Array of timers, one for each entry in enum input_combo_type. - */ - rarch_timer_t combo_timers[INPUT_COMBO_LAST]; } input_driver_state_t; @@ -802,8 +824,6 @@ float input_get_sensor_state(unsigned port, unsigned id); bool input_set_sensor_state(unsigned port, enum retro_sensor_action action, unsigned rate); -bool input_mouse_grabbed(void); - void *input_driver_init_wrap(input_driver_t *input, const char *name); const struct retro_keybind *input_config_get_bind_auto(unsigned port, unsigned id); diff --git a/input/input_remapping.h b/input/input_remapping.h index 37eee5ef02..285c53127a 100644 --- a/input/input_remapping.h +++ b/input/input_remapping.h @@ -26,18 +26,6 @@ #include "input_defines.h" #include "input_types.h" -typedef struct input_mapper -{ - /* Left X, Left Y, Right X, Right Y */ - int16_t analog_value[MAX_USERS][8]; - /* The whole keyboard state */ - uint32_t keys[RETROK_LAST / 32 + 1]; - /* RetroPad button state of remapped keyboard keys */ - unsigned key_button[RETROK_LAST]; - /* This is a bitmask of (1 << key_bind_id). */ - input_bits_t buttons[MAX_USERS]; -} input_mapper_t; - RETRO_BEGIN_DECLS /** diff --git a/input/input_types.h b/input/input_types.h index 715c932249..4d2f42c6a3 100644 --- a/input/input_types.h +++ b/input/input_types.h @@ -27,6 +27,16 @@ enum input_auto_game_focus_type AUTO_GAME_FOCUS_LAST }; +/* Turbo support. */ +struct turbo_buttons +{ + int32_t turbo_pressed[MAX_USERS]; + unsigned count; + uint16_t enable[MAX_USERS]; + bool frame_enable[MAX_USERS]; + bool mode1_enable[MAX_USERS]; +}; + struct retro_keybind { /* Human-readable label for the control. */ @@ -65,6 +75,18 @@ typedef struct uint16_t analog_buttons[16]; } input_bits_t; +typedef struct input_mapper +{ + /* Left X, Left Y, Right X, Right Y */ + int16_t analog_value[MAX_USERS][8]; + /* The whole keyboard state */ + uint32_t keys[RETROK_LAST / 32 + 1]; + /* RetroPad button state of remapped keyboard keys */ + unsigned key_button[RETROK_LAST]; + /* This is a bitmask of (1 << key_bind_id). */ + input_bits_t buttons[MAX_USERS]; +} input_mapper_t; + typedef struct rarch_joypad_driver input_device_driver_t; typedef struct input_keyboard_line input_keyboard_line_t; typedef struct rarch_joypad_info rarch_joypad_info_t; @@ -73,5 +95,6 @@ typedef struct input_keyboard_ctx_wait input_keyboard_ctx_wait_t; typedef struct joypad_connection joypad_connection_t; typedef struct pad_connection_listener_interface pad_connection_listener_t; +typedef struct turbo_buttons turbo_buttons_t; #endif /* __INPUT_TYPES__H */ diff --git a/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj index 48a85dad67..825d640c75 100644 --- a/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj @@ -416,7 +416,6 @@ 05A8E23920A63CED0084ABDA /* IOSurface.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOSurface.framework; path = System/Library/Frameworks/IOSurface.framework; sourceTree = SDKROOT; }; 05A8E23B20A63CF50084ABDA /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 05B5F90D20ED6A03009C521F /* content.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = content.h; path = ../../content.h; sourceTree = ""; }; - 05B5F90E20ED6A03009C521F /* core_type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = core_type.h; path = ../../core_type.h; sourceTree = ""; }; 05B5F90F20ED6A03009C521F /* command.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = command.c; path = ../../command.c; sourceTree = ""; }; 05B5F91120ED6AAE009C521F /* retroarch.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = retroarch.c; path = ../../retroarch.c; sourceTree = ""; }; 05B5F91220ED6AAF009C521F /* retroarch.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = retroarch.h; path = ../../retroarch.h; sourceTree = ""; }; @@ -1180,7 +1179,6 @@ 05BF821520ED69D100D95B19 /* core_impl.c */, 05BF821820ED69D100D95B19 /* core_info.c */, 05BF821B20ED69D100D95B19 /* core_info.h */, - 05B5F90E20ED6A03009C521F /* core_type.h */, 05BF821920ED69D100D95B19 /* core.h */, 0548E2B220F976E10094A083 /* driver.c */, 0548E2B520F976E20094A083 /* driver.h */, diff --git a/pkg/apple/RetroArch_iOS11_Metal.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_iOS11_Metal.xcodeproj/project.pbxproj index c4b6d2321f..7bbc214a62 100644 --- a/pkg/apple/RetroArch_iOS11_Metal.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_iOS11_Metal.xcodeproj/project.pbxproj @@ -254,7 +254,6 @@ 92B9EC9824E0537500E6CFB2 /* config.def.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = config.def.h; path = ../../config.def.h; sourceTree = ""; }; 92B9EC9924E0537500E6CFB2 /* config.features.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = config.features.h; path = ../../config.features.h; sourceTree = ""; }; 92B9EC9A24E0537500E6CFB2 /* content.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = content.h; path = ../../content.h; sourceTree = ""; }; - 92B9EC9B24E0539000E6CFB2 /* core_type.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = core_type.h; path = ../../core_type.h; sourceTree = ""; }; 92B9EC9C24E0539000E6CFB2 /* core_info.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = core_info.c; path = ../../core_info.c; sourceTree = ""; }; 92B9EC9D24E0539000E6CFB2 /* core_info.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = core_info.h; path = ../../core_info.h; sourceTree = ""; }; 92B9EC9E24E0539000E6CFB2 /* core.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = core.h; path = ../../core.h; sourceTree = ""; }; @@ -847,7 +846,6 @@ 92B9ECBF24E054B500E6CFB2 /* core_backup.h */, 92B9EC9C24E0539000E6CFB2 /* core_info.c */, 92B9EC9D24E0539000E6CFB2 /* core_info.h */, - 92B9EC9B24E0539000E6CFB2 /* core_type.h */, 92B9ECB024E054B400E6CFB2 /* core_updater_list.c */, 92B9ECB624E054B500E6CFB2 /* core_updater_list.h */, 92B9EC9E24E0539000E6CFB2 /* core.h */, diff --git a/retroarch.c b/retroarch.c index ebd803d236..3bd8b11282 100644 --- a/retroarch.c +++ b/retroarch.c @@ -208,7 +208,6 @@ #include "config.features.h" #include "cores/internal_cores.h" #include "content.h" -#include "core_type.h" #include "core_info.h" #include "dynamic.h" #include "defaults.h" @@ -647,7 +646,7 @@ bool menu_input_key_bind_set_mode( settings->floats.input_axis_threshold, settings->uints.input_joypad_index[binds->port], binds, false, - p_rarch->keyboard_mapping_blocked); + input_st->keyboard_mapping_blocked); current_usec = cpu_features_get_time_usec(); @@ -665,7 +664,7 @@ bool menu_input_key_bind_set_mode( p_rarch->keyboard_press_data = menu; /* While waiting for input, we have to block all hotkeys. */ - p_rarch->keyboard_mapping_blocked = true; + input_st->keyboard_mapping_blocked = true; /* Upon triggering an input bind operation, * pointer input must be inhibited - otherwise @@ -684,6 +683,7 @@ static bool menu_input_key_bind_iterate( retro_time_t current_time) { bool timed_out = false; + input_driver_state_t *input_st = input_state_get_ptr(); struct menu_state *menu_st = menu_state_get_ptr(); struct menu_bind_state *_binds = &menu_st->input_binds; menu_input_t *menu_input = &menu_st->input_state; @@ -703,9 +703,9 @@ static bool menu_input_key_bind_iterate( if (RARCH_TIMER_HAS_EXPIRED(_binds->timer_timeout)) { - uint64_t current_usec = cpu_features_get_time_usec(); + uint64_t current_usec = cpu_features_get_time_usec(); - p_rarch->keyboard_mapping_blocked = false; + input_st->keyboard_mapping_blocked = false; /*skip to next bind*/ _binds->begin++; @@ -731,27 +731,27 @@ static bool menu_input_key_bind_iterate( /* We won't be getting any key events, so just cancel early. */ if (timed_out) { - p_rarch->keyboard_press_cb = NULL; - p_rarch->keyboard_press_data = NULL; - p_rarch->keyboard_mapping_blocked = false; + p_rarch->keyboard_press_cb = NULL; + p_rarch->keyboard_press_data = NULL; + input_st->keyboard_mapping_blocked = false; } return true; } { - bool complete = false; - struct menu_bind_state new_binds = *_binds; + bool complete = false; + struct menu_bind_state new_binds = *_binds; - p_rarch->keyboard_mapping_blocked = false; + input_st->keyboard_mapping_blocked = false; menu_input_key_bind_poll_bind_state( - input_state_get_ptr(), + input_st, p_rarch->libretro_input_binds, settings->floats.input_axis_threshold, settings->uints.input_joypad_index[new_binds.port], &new_binds, timed_out, - p_rarch->keyboard_mapping_blocked); + input_st->keyboard_mapping_blocked); #ifdef ANDROID /* Keep resetting bind during the hold period, @@ -800,11 +800,11 @@ static bool menu_input_key_bind_iterate( if (complete) { - uint64_t current_usec = cpu_features_get_time_usec(); - /* Update bind */ - *(new_binds.output) = new_binds.buffer; + /* Update bind */ + uint64_t current_usec = cpu_features_get_time_usec(); + *(new_binds.output) = new_binds.buffer; - p_rarch->keyboard_mapping_blocked = false; + input_st->keyboard_mapping_blocked= false; /* Avoid new binds triggering things right away. */ /* Inhibits input for 2 frames @@ -816,9 +816,9 @@ static bool menu_input_key_bind_iterate( if (new_binds.begin > new_binds.last) { - p_rarch->keyboard_press_cb = NULL; - p_rarch->keyboard_press_data = NULL; - p_rarch->keyboard_mapping_blocked = false; + p_rarch->keyboard_press_cb = NULL; + p_rarch->keyboard_press_data = NULL; + input_st->keyboard_mapping_blocked = false; return true; } @@ -2584,9 +2584,11 @@ void input_poll_net(void) netplay_t *netplay = p_rarch->netplay_data; if (!netplay_should_skip(netplay) && netplay && netplay->can_poll) { + input_driver_state_t + *input_st = input_state_get_ptr(); netplay->can_poll = false; netplay_poll( - p_rarch->input_driver_block_libretro_input, + input_st->block_libretro_input, p_rarch->configuration_settings, netplay); } @@ -4685,8 +4687,10 @@ bool gfx_widgets_ready(void) bool menu_input_dialog_start_search(void) { struct rarch_state *p_rarch = &rarch_st; + input_driver_state_t + *input_st = input_state_get_ptr(); #ifdef HAVE_ACCESSIBILITY - settings_t *settings = p_rarch->configuration_settings; + settings_t *settings = config_get_ptr(); bool accessibility_enable = settings->bools.accessibility_enable; unsigned accessibility_narrator_speech_speed = settings->uints.accessibility_narrator_speech_speed; #endif @@ -4725,7 +4729,7 @@ bool menu_input_dialog_start_search(void) &p_rarch->keyboard_line, menu_input_search_cb); /* While reading keyboard line input, we have to block all hotkeys. */ - p_rarch->keyboard_mapping_blocked = true; + input_st->keyboard_mapping_blocked = true; return true; } @@ -4733,6 +4737,7 @@ bool menu_input_dialog_start_search(void) bool menu_input_dialog_start(menu_input_ctx_line_t *line) { struct rarch_state *p_rarch = &rarch_st; + input_driver_state_t *input_st = input_state_get_ptr(); #ifdef HAVE_ACCESSIBILITY settings_t *settings = p_rarch->configuration_settings; bool accessibility_enable = settings->bools.accessibility_enable; @@ -4782,7 +4787,7 @@ bool menu_input_dialog_start(menu_input_ctx_line_t *line) &p_rarch->keyboard_line, line->cb); /* While reading keyboard line input, we have to block all hotkeys. */ - p_rarch->keyboard_mapping_blocked= true; + input_st->keyboard_mapping_blocked = true; return true; } @@ -7602,10 +7607,13 @@ bool command_event(enum event_command cmd, void *data) command_event(CMD_EVENT_RECORD_INIT, NULL); break; case CMD_EVENT_OSK_TOGGLE: - if (p_rarch->input_driver_keyboard_linefeed_enable) - p_rarch->input_driver_keyboard_linefeed_enable = false; - else - p_rarch->input_driver_keyboard_linefeed_enable = true; + { + input_driver_state_t *input_st = input_state_get_ptr(); + if (input_st->keyboard_linefeed_enable) + input_st->keyboard_linefeed_enable = false; + else + input_st->keyboard_linefeed_enable = true; + } break; case CMD_EVENT_SET_PER_GAME_RESOLUTION: #if defined(GEKKO) @@ -7826,9 +7834,10 @@ bool command_event(enum event_command cmd, void *data) if (!settings->bools.video_fullscreen) { + input_driver_state_t *input_st = input_state_get_ptr(); video_driver_show_mouse(); if (input_driver_ungrab_mouse()) - p_rarch->input_driver_grab_mouse_state = false; + input_st->grab_mouse_state = false; } } #endif @@ -8752,6 +8761,8 @@ bool command_event(enum event_command cmd, void *data) #endif case CMD_EVENT_FULLSCREEN_TOGGLE: { + input_driver_state_t + *input_st = input_state_get_ptr(); bool *userdata = (bool*)data; bool video_fullscreen = settings->bools.video_fullscreen; bool ra_is_forced_fs = p_rarch->rarch_force_fullscreen; @@ -8781,14 +8792,14 @@ bool command_event(enum event_command cmd, void *data) video_driver_hide_mouse(); if (!settings->bools.video_windowed_fullscreen) if (input_driver_grab_mouse()) - p_rarch->input_driver_grab_mouse_state = true; + input_st->grab_mouse_state = true; } else { video_driver_show_mouse(); if (!settings->bools.video_windowed_fullscreen) if (input_driver_ungrab_mouse()) - p_rarch->input_driver_grab_mouse_state = false; + input_st->grab_mouse_state = false; } p_rarch->rarch_is_switching_display_mode = false; @@ -8953,17 +8964,19 @@ bool command_event(enum event_command cmd, void *data) case CMD_EVENT_GRAB_MOUSE_TOGGLE: { bool ret = false; - bool grab_mouse_state = !p_rarch->input_driver_grab_mouse_state; + input_driver_state_t + *input_st = input_state_get_ptr(); + bool grab_mouse_state = !input_st->grab_mouse_state; if (grab_mouse_state) { if ((ret = input_driver_grab_mouse())) - p_rarch->input_driver_grab_mouse_state = true; + input_st->grab_mouse_state = true; } else { if ((ret = input_driver_ungrab_mouse())) - p_rarch->input_driver_grab_mouse_state = false; + input_st->grab_mouse_state = false; } if (!ret) @@ -9049,10 +9062,13 @@ bool command_event(enum event_command cmd, void *data) if (apply_update) { + input_driver_state_t + *input_st = input_state_get_ptr(); + if (p_rarch->game_focus_state.enabled) { if (input_driver_grab_mouse()) - p_rarch->input_driver_grab_mouse_state = true; + input_st->grab_mouse_state = true; video_driver_hide_mouse(); } /* Ungrab only if windowed and auto mouse grab is disabled */ @@ -9060,13 +9076,13 @@ bool command_event(enum event_command cmd, void *data) !settings->bools.input_auto_mouse_grab) { if (input_driver_ungrab_mouse()) - p_rarch->input_driver_grab_mouse_state = false; + input_st->grab_mouse_state = false; video_driver_show_mouse(); } - p_rarch->input_driver_block_hotkey = + input_st->block_hotkey = p_rarch->game_focus_state.enabled; - p_rarch->keyboard_mapping_blocked = + input_st->keyboard_mapping_blocked = p_rarch->game_focus_state.enabled; if (show_message) @@ -12645,6 +12661,8 @@ static void uninit_libretro_symbols( struct rarch_state *p_rarch, struct retro_core_t *current_core) { + input_driver_state_t + *input_st = input_state_get_ptr(); #ifdef HAVE_DYNAMIC if (p_rarch->lib_handle) dylib_close(p_rarch->lib_handle); @@ -12678,8 +12696,8 @@ static void uninit_libretro_symbols( /* Core has finished utilising the input driver; * reset 'analog input requested' flags */ - memset(&p_rarch->input_driver_analog_requested, 0, - sizeof(p_rarch->input_driver_analog_requested)); + memset(&input_st->analog_requested, 0, + sizeof(input_st->analog_requested)); /* Performance counters no longer valid. */ p_rarch->perf_ptr_libretro = 0; @@ -14936,12 +14954,12 @@ static void input_driver_poll(void) && input_st->current_driver->poll) input_st->current_driver->poll(input_st->current_data); - p_rarch->input_driver_turbo_btns.count++; + input_st->turbo_btns.count++; - if (p_rarch->input_driver_block_libretro_input) + if (input_st->block_libretro_input) { for (i = 0; i < max_users; i++) - p_rarch->input_driver_turbo_btns.frame_enable[i] = 0; + input_st->turbo_btns.frame_enable[i] = 0; return; } @@ -14954,7 +14972,7 @@ static void input_driver_poll(void) joypad_info[i].joy_idx = settings->uints.input_joypad_index[i]; joypad_info[i].auto_binds = input_autoconf_binds[joypad_info[i].joy_idx]; - p_rarch->input_driver_turbo_btns.frame_enable[i] = p_rarch->libretro_input_binds[i][RARCH_TURBO_ENABLE].valid ? + input_st->turbo_btns.frame_enable[i] = p_rarch->libretro_input_binds[i][RARCH_TURBO_ENABLE].valid ? input_state_wrap( input_st->current_driver, input_st->current_data, @@ -14962,7 +14980,7 @@ static void input_driver_poll(void) sec_joypad, &joypad_info[i], p_rarch->libretro_input_binds, - p_rarch->keyboard_mapping_blocked, + input_st->keyboard_mapping_blocked, (unsigned)i, RETRO_DEVICE_JOYPAD, 0, @@ -14980,8 +14998,7 @@ static void input_driver_poll(void) case ANALOG_DPAD_RSTICK: { unsigned mapped_port = settings->uints.input_remap_ports[0]; - - if (p_rarch->input_driver_analog_requested[mapped_port]) + if (input_st->analog_requested[mapped_port]) input_analog_dpad_mode = ANALOG_DPAD_NONE; } break; @@ -14996,7 +15013,7 @@ static void input_driver_poll(void) } input_poll_overlay( - p_rarch->keyboard_mapping_blocked, + input_st->keyboard_mapping_blocked, settings, p_rarch->overlay_ptr, p_rarch->overlay_visibility, @@ -15015,7 +15032,7 @@ static void input_driver_poll(void) input_overlay_t *overlay_pointer = (input_overlay_t*)p_rarch->overlay_ptr; bool poll_overlay = (p_rarch->overlay_ptr && p_rarch->overlay_ptr->alive); #endif - input_mapper_t *handle = &p_rarch->input_driver_mapper; + input_mapper_t *handle = &input_st->mapper; float input_analog_deadzone = settings->floats.input_analog_deadzone; float input_analog_sensitivity = settings->floats.input_analog_sensitivity; @@ -15032,7 +15049,7 @@ static void input_driver_poll(void) { case ANALOG_DPAD_LSTICK: case ANALOG_DPAD_RSTICK: - if (p_rarch->input_driver_analog_requested[mapped_port]) + if (input_st->analog_requested[mapped_port]) input_analog_dpad_mode = ANALOG_DPAD_NONE; break; case ANALOG_DPAD_LSTICK_FORCED: @@ -15061,7 +15078,7 @@ static void input_driver_poll(void) sec_joypad, &joypad_info[i], p_rarch->libretro_input_binds, - p_rarch->keyboard_mapping_blocked, + input_st->keyboard_mapping_blocked, (unsigned)i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_MASK); @@ -15303,22 +15320,22 @@ static void input_driver_poll(void) } #ifdef HAVE_COMMAND - for (i = 0; i < ARRAY_SIZE(p_rarch->input_driver_command); i++) + for (i = 0; i < ARRAY_SIZE(input_st->command); i++) { - if (p_rarch->input_driver_command[i]) + if (input_st->command[i]) { - memset(p_rarch->input_driver_command[i]->state, - 0, sizeof(p_rarch->input_driver_command[i]->state)); + memset(input_st->command[i]->state, + 0, sizeof(input_st->command[i]->state)); - p_rarch->input_driver_command[i]->poll( - p_rarch->input_driver_command[i]); + input_st->command[i]->poll( + input_st->command[i]); } } #endif #ifdef HAVE_NETWORKGAMEPAD /* Poll remote */ - if (p_rarch->input_driver_remote) + if (input_st->remote) { unsigned user; @@ -15331,13 +15348,13 @@ static void input_driver_poll(void) ssize_t ret; struct remote_message msg; - if (p_rarch->input_driver_remote->net_fd[user] < 0) + if (input_st->remote->net_fd[user] < 0) return; FD_ZERO(&fds); - FD_SET(p_rarch->input_driver_remote->net_fd[user], &fds); + FD_SET(input_st->remote->net_fd[user], &fds); - ret = recvfrom(p_rarch->input_driver_remote->net_fd[user], + ret = recvfrom(input_st->remote->net_fd[user], (char*)&msg, sizeof(msg), 0, NULL, NULL); @@ -15361,6 +15378,7 @@ static void input_driver_poll(void) static int16_t input_state_device( struct rarch_state *p_rarch, + input_driver_state_t *input_st, settings_t *settings, input_mapper_t *handle, unsigned input_analog_dpad_mode, @@ -15369,7 +15387,7 @@ static int16_t input_state_device( unsigned idx, unsigned id, bool button_mask) { - int16_t res = 0; + int16_t res = 0; switch (device) { @@ -15379,7 +15397,7 @@ static int16_t input_state_device( { #ifdef HAVE_NETWORKGAMEPAD /* Don't process binds if input is coming from Remote RetroPad */ - if ( p_rarch->input_driver_remote + if ( input_st->remote && INPUT_REMOTE_KEY_PRESSED(p_rarch, id, port)) res |= 1; else @@ -15458,13 +15476,13 @@ static int16_t input_state_device( */ /* Avoid detecting the turbo button being held as multiple toggles */ - if (!p_rarch->input_driver_turbo_btns.frame_enable[port]) - p_rarch->input_driver_turbo_btns.turbo_pressed[port] &= ~(1 << 31); - else if (p_rarch->input_driver_turbo_btns.turbo_pressed[port]>=0) + if (!input_st->turbo_btns.frame_enable[port]) + input_st->turbo_btns.turbo_pressed[port] &= ~(1 << 31); + else if (input_st->turbo_btns.turbo_pressed[port]>=0) { - p_rarch->input_driver_turbo_btns.turbo_pressed[port] |= (1 << 31); + input_st->turbo_btns.turbo_pressed[port] |= (1 << 31); /* Toggle turbo for selected buttons. */ - if (p_rarch->input_driver_turbo_btns.enable[port] + if (input_st->turbo_btns.enable[port] != (1 << settings->uints.input_turbo_default_button)) { static const int button_map[]={ @@ -15478,44 +15496,44 @@ static int16_t input_state_device( RETRO_DEVICE_ID_JOYPAD_R2, RETRO_DEVICE_ID_JOYPAD_L3, RETRO_DEVICE_ID_JOYPAD_R3}; - p_rarch->input_driver_turbo_btns.enable[port] = 1 << button_map[ + input_st->turbo_btns.enable[port] = 1 << button_map[ MIN( ARRAY_SIZE(button_map) - 1, settings->uints.input_turbo_default_button)]; } - p_rarch->input_driver_turbo_btns.mode1_enable[port] ^= 1; + input_st->turbo_btns.mode1_enable[port] ^= 1; } - if (p_rarch->input_driver_turbo_btns.turbo_pressed[port] & (1 << 31)) + if (input_st->turbo_btns.turbo_pressed[port] & (1 << 31)) { /* Avoid detecting buttons being held as multiple toggles */ if (!res) - p_rarch->input_driver_turbo_btns.turbo_pressed[port] &= ~(1 << id); - else if (!(p_rarch->input_driver_turbo_btns.turbo_pressed[port] & (1 << id)) && + input_st->turbo_btns.turbo_pressed[port] &= ~(1 << id); + else if (!(input_st->turbo_btns.turbo_pressed[port] & (1 << id)) && turbo_mode == INPUT_TURBO_MODE_SINGLEBUTTON) { uint16_t enable_new; - p_rarch->input_driver_turbo_btns.turbo_pressed[port] |= 1 << id; + input_st->turbo_btns.turbo_pressed[port] |= 1 << id; /* Toggle turbo for pressed button but make * sure at least one button has turbo */ - enable_new = p_rarch->input_driver_turbo_btns.enable[port] ^ (1 << id); + enable_new = input_st->turbo_btns.enable[port] ^ (1 << id); if (enable_new) - p_rarch->input_driver_turbo_btns.enable[port] = enable_new; + input_st->turbo_btns.enable[port] = enable_new; } } else if (turbo_mode == INPUT_TURBO_MODE_SINGLEBUTTON_HOLD && - p_rarch->input_driver_turbo_btns.enable[port] && - p_rarch->input_driver_turbo_btns.mode1_enable[port]) + input_st->turbo_btns.enable[port] && + input_st->turbo_btns.mode1_enable[port]) { /* Hold mode stops turbo on release */ - p_rarch->input_driver_turbo_btns.mode1_enable[port] = 0; + input_st->turbo_btns.mode1_enable[port] = 0; } - if (!res && p_rarch->input_driver_turbo_btns.mode1_enable[port] && - p_rarch->input_driver_turbo_btns.enable[port] & (1 << id)) + if (!res && input_st->turbo_btns.mode1_enable[port] && + input_st->turbo_btns.enable[port] & (1 << id)) { /* if turbo button is enabled for this key ID */ - res = ((p_rarch->input_driver_turbo_btns.count + res = (( input_st->turbo_btns.count % settings->uints.input_turbo_period) < settings->uints.input_turbo_duty_cycle); } @@ -15529,17 +15547,17 @@ static int16_t input_state_device( */ if (res) { - if (p_rarch->input_driver_turbo_btns.frame_enable[port]) - p_rarch->input_driver_turbo_btns.enable[port] |= (1 << id); + if (input_st->turbo_btns.frame_enable[port]) + input_st->turbo_btns.enable[port] |= (1 << id); - if (p_rarch->input_driver_turbo_btns.enable[port] & (1 << id)) + if (input_st->turbo_btns.enable[port] & (1 << id)) /* if turbo button is enabled for this key ID */ - res = ((p_rarch->input_driver_turbo_btns.count + res = ((input_st->turbo_btns.count % settings->uints.input_turbo_period) < settings->uints.input_turbo_duty_cycle); } else - p_rarch->input_driver_turbo_btns.enable[port] &= ~(1 << id); + input_st->turbo_btns.enable[port] &= ~(1 << id); } } } @@ -15586,7 +15604,7 @@ static int16_t input_state_device( if (id == RETRO_DEVICE_ID_ANALOG_Y) base += 1; #ifdef HAVE_NETWORKGAMEPAD - if (p_rarch->input_driver_remote + if ( input_st->remote && input_state && input_state->analog[base][port]) res = input_state->analog[base][port]; else @@ -15716,7 +15734,7 @@ int16_t input_state_internal(unsigned port, unsigned device, float input_analog_deadzone = settings->floats.input_analog_deadzone; float input_analog_sensitivity = settings->floats.input_analog_sensitivity; unsigned *input_remap_port_map = settings->uints.input_remap_port_map[port]; - bool input_driver_analog_requested = p_rarch->input_driver_analog_requested[port]; + bool input_driver_analog_requested = input_st->analog_requested[port]; const input_device_driver_t *joypad = input_st->primary_joypad; #ifdef HAVE_MFI const input_device_driver_t *sec_joypad = input_st->secondary_joypad; @@ -15726,9 +15744,9 @@ int16_t input_state_internal(unsigned port, unsigned device, #ifdef HAVE_MENU struct menu_state *menu_st = menu_state_get_ptr(); bool input_blocked = (menu_st->input_driver_flushing_input > 0) || - p_rarch->input_driver_block_libretro_input; + input_st->block_libretro_input; #else - bool input_blocked = p_rarch->input_driver_block_libretro_input; + bool input_blocked = input_st->block_libretro_input; #endif bool bitmask_enabled = false; unsigned max_users = settings->uints.input_max_users; @@ -15784,7 +15802,7 @@ int16_t input_state_internal(unsigned port, unsigned device, sec_joypad, &joypad_info, p_rarch->libretro_input_binds, - p_rarch->keyboard_mapping_blocked, + input_st->keyboard_mapping_blocked, mapped_port, device, idx, id); if ((device == RETRO_DEVICE_ANALOG) && @@ -15847,21 +15865,23 @@ int16_t input_state_internal(unsigned port, unsigned device, if (!input_blocked) { - input_mapper_t *handle = &p_rarch->input_driver_mapper; + input_mapper_t *handle = &input_st->mapper; if (bitmask_enabled) { unsigned i; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) - if (input_state_device(p_rarch, settings, handle, - input_analog_dpad_mode, ret, mapped_port, - device, idx, i, true)) + if (input_state_device(p_rarch, input_st, + settings, handle, + input_analog_dpad_mode, ret, mapped_port, + device, idx, i, true)) port_result |= (1 << i); } else - port_result = input_state_device(p_rarch, settings, handle, + port_result = input_state_device(p_rarch, input_st, + settings, handle, input_analog_dpad_mode, ret, mapped_port, - device, idx, id, false); + device, idx, id, false); } /* Digital values are represented by a bitmap; @@ -15919,6 +15939,8 @@ static int16_t input_state(unsigned port, unsigned device, unsigned idx, unsigned id) { struct rarch_state *p_rarch = &rarch_st; + input_driver_state_t + *input_st = input_state_get_ptr(); int16_t result = 0; #ifdef HAVE_BSV_MOVIE @@ -15948,7 +15970,7 @@ static int16_t input_state(unsigned port, unsigned device, if ( (device == RETRO_DEVICE_ANALOG) && ( (idx == RETRO_DEVICE_INDEX_ANALOG_LEFT) || (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT))) - p_rarch->input_driver_analog_requested[port] = true; + input_st->analog_requested[port] = true; #ifdef HAVE_BSV_MOVIE /* Save input to BSV record, if enabled */ @@ -16014,7 +16036,7 @@ static unsigned menu_event( gfx_display_t *p_disp = disp_get_ptr(); menu_input_pointer_hw_state_t *pointer_hw_state = &menu_st->input_pointer_hw_state; menu_handle_t *menu = menu_st->driver_data; - bool keyboard_mapping_blocked = p_rarch->keyboard_mapping_blocked; + bool keyboard_mapping_blocked = input_st->keyboard_mapping_blocked; bool menu_mouse_enable = settings->bools.menu_mouse_enable; bool menu_pointer_enable = settings->bools.menu_pointer_enable; bool swap_ok_cancel_btns = settings->bools.input_menu_swap_ok_cancel_buttons; @@ -16973,14 +16995,15 @@ static int menu_input_post_iterate( static INLINE bool input_keys_pressed_other_sources( struct rarch_state *p_rarch, + input_driver_state_t *input_st, unsigned i, input_bits_t* p_new_state) { #ifdef HAVE_COMMAND int j; - for (j = 0; j < ARRAY_SIZE(p_rarch->input_driver_command); j++) - if ((i < RARCH_BIND_LIST_END) && p_rarch->input_driver_command[j] - && p_rarch->input_driver_command[j]->state[i]) + for (j = 0; j < ARRAY_SIZE(input_st->command); j++) + if ((i < RARCH_BIND_LIST_END) && input_st->command[j] + && input_st->command[j]->state[i]) return true; #endif @@ -16993,7 +17016,7 @@ static INLINE bool input_keys_pressed_other_sources( #ifdef HAVE_NETWORKGAMEPAD /* Only process key presses related to game input if using Remote RetroPad */ if (i < RARCH_CUSTOM_BIND_LIST_END - && p_rarch->input_driver_remote + && input_st->remote && INPUT_REMOTE_KEY_PRESSED(p_rarch, i, 0)) return true; #endif @@ -17033,19 +17056,19 @@ static void input_keys_pressed( sec_joypad, joypad_info, &binds[port], - p_rarch->keyboard_mapping_blocked, + input_st->keyboard_mapping_blocked, port, RETRO_DEVICE_JOYPAD, 0, RARCH_ENABLE_HOTKEY)) { if (p_rarch->input_hotkey_block_counter < input_hotkey_block_delay) p_rarch->input_hotkey_block_counter++; else - p_rarch->input_driver_block_libretro_input = true; + input_st->block_libretro_input = true; } else { p_rarch->input_hotkey_block_counter = 0; - p_rarch->input_driver_block_hotkey = true; + input_st->block_hotkey = true; } } @@ -17069,10 +17092,10 @@ static void input_keys_pressed( sec_joypad, joypad_info, &binds[port], - p_rarch->keyboard_mapping_blocked, + input_st->keyboard_mapping_blocked, port, RETRO_DEVICE_JOYPAD, 0, RARCH_GAME_FOCUS_TOGGLE)) - p_rarch->input_driver_block_hotkey = false; + input_st->block_hotkey = false; } } @@ -17080,14 +17103,14 @@ static void input_keys_pressed( int16_t ret = 0; /* Check the libretro input first */ - if (!p_rarch->input_driver_block_libretro_input) + if (!input_st->block_libretro_input) ret = input_state_wrap( input_st->current_driver, input_st->current_data, input_st->primary_joypad, sec_joypad, joypad_info, &binds[port], - p_rarch->keyboard_mapping_blocked, + input_st->keyboard_mapping_blocked, port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_MASK); @@ -17095,7 +17118,7 @@ static void input_keys_pressed( { if ( (ret & (UINT64_C(1) << i)) || - input_keys_pressed_other_sources(p_rarch, + input_keys_pressed_other_sources(p_rarch, input_st, i, p_new_state)) { BIT256_SET_PTR(p_new_state, i); @@ -17104,13 +17127,14 @@ static void input_keys_pressed( } /* Check the hotkeys */ - if (p_rarch->input_driver_block_hotkey) + if (input_st->block_hotkey) { for (i = RARCH_FIRST_META_KEY; i < RARCH_BIND_LIST_END; i++) { if ( BIT64_GET(lifecycle_state, i) - || input_keys_pressed_other_sources(p_rarch, i, p_new_state)) + || input_keys_pressed_other_sources(p_rarch, input_st, + i, p_new_state)) { BIT256_SET_PTR(p_new_state, i); } @@ -17128,11 +17152,12 @@ static void input_keys_pressed( sec_joypad, joypad_info, &binds[port], - p_rarch->keyboard_mapping_blocked, + input_st->keyboard_mapping_blocked, port, RETRO_DEVICE_JOYPAD, 0, i); if ( bit_pressed || BIT64_GET(lifecycle_state, i) - || input_keys_pressed_other_sources(p_rarch, i, p_new_state)) + || input_keys_pressed_other_sources(p_rarch, input_st, + i, p_new_state)) { BIT256_SET_PTR(p_new_state, i); } @@ -17142,6 +17167,7 @@ static void input_keys_pressed( #ifdef HAVE_COMMAND static void input_driver_init_command(struct rarch_state *p_rarch, + input_driver_state_t *input_st, settings_t *settings) { bool input_network_cmd_enable = settings->bools.network_cmd_enable; @@ -17163,8 +17189,8 @@ static void input_driver_init_command(struct rarch_state *p_rarch, } else { - p_rarch->input_driver_command[0] = command_stdin_new(); - if (!p_rarch->input_driver_command[1]) + input_st->command[0] = command_stdin_new(); + if (!input_st->command[1]) RARCH_ERR("Failed to initialize the stdin command interface.\n"); } } @@ -17174,29 +17200,30 @@ static void input_driver_init_command(struct rarch_state *p_rarch, #ifdef HAVE_NETWORK_CMD if (input_network_cmd_enable) { - p_rarch->input_driver_command[1] = command_network_new(network_cmd_port); - if (!p_rarch->input_driver_command[1]) + input_st->command[1] = command_network_new(network_cmd_port); + if (!input_st->command[1]) RARCH_ERR("Failed to initialize the network command interface.\n"); } #endif #ifdef HAVE_LAKKA - p_rarch->input_driver_command[2] = command_uds_new(); - if (!p_rarch->input_driver_command[2]) + input_st->command[2] = command_uds_new(); + if (!input_st->command[2]) RARCH_ERR("Failed to initialize the UDS command interface.\n"); #endif } -static void input_driver_deinit_command(struct rarch_state *p_rarch) +static void input_driver_deinit_command(struct rarch_state *p_rarch, + input_driver_state_t *input_st) { int i; - for (i = 0; i < ARRAY_SIZE(p_rarch->input_driver_command); i++) + for (i = 0; i < ARRAY_SIZE(input_st->command); i++) { - if (p_rarch->input_driver_command[i]) - p_rarch->input_driver_command[i]->destroy( - p_rarch->input_driver_command[i]); + if (input_st->command[i]) + input_st->command[i]->destroy( + input_st->command[i]); - p_rarch->input_driver_command[i] = NULL; + input_st->command[i] = NULL; } } #endif @@ -17213,12 +17240,6 @@ const char* config_get_joypad_driver_options(void) return char_list_new_special(STRING_LIST_INPUT_JOYPAD_DRIVERS, NULL); } -bool input_mouse_grabbed(void) -{ - struct rarch_state *p_rarch = &rarch_st; - return p_rarch->input_driver_grab_mouse_state; -} - void input_pad_connect(unsigned port, input_device_driver_t *driver) { struct rarch_state *p_rarch = &rarch_st; @@ -17471,6 +17492,8 @@ void input_keyboard_event(bool down, unsigned code, { static bool deferred_wait_keys; struct rarch_state *p_rarch = &rarch_st; + input_driver_state_t + *input_st = input_state_get_ptr(); #ifdef HAVE_ACCESSIBILITY settings_t *settings = p_rarch->configuration_settings; bool accessibility_enable = settings->bools.accessibility_enable; @@ -17578,7 +17601,7 @@ void input_keyboard_event(bool down, unsigned code, p_rarch->keyboard_press_cb = NULL; p_rarch->keyboard_press_data = NULL; - p_rarch->keyboard_mapping_blocked = false; + input_st->keyboard_mapping_blocked = false; deferred_wait_keys = false; } else if (p_rarch->keyboard_press_cb) @@ -17618,7 +17641,7 @@ void input_keyboard_event(bool down, unsigned code, p_rarch->keyboard_line.enabled = false; /* Unblock all hotkeys. */ - p_rarch->keyboard_mapping_blocked = false; + input_st->keyboard_mapping_blocked = false; } else { @@ -17631,7 +17654,7 @@ void input_keyboard_event(bool down, unsigned code, if (!p_rarch->game_focus_state.enabled && BIT512_GET(p_rarch->keyboard_mapping_bits, code)) { - input_mapper_t *handle = &p_rarch->input_driver_mapper; + input_mapper_t *handle = &input_st->mapper; struct retro_keybind hotkey = input_config_binds[0][RARCH_ENABLE_HOTKEY]; bool hotkey_pressed = (p_rarch->input_hotkey_block_counter > 0) || (hotkey.key == code); @@ -20298,12 +20321,12 @@ static void video_driver_free_internal(struct rarch_state *p_rarch) if (input_st->secondary_joypad) { const input_device_driver_t *tmp = input_st->secondary_joypad; - input_st->secondary_joypad = NULL; + input_st->secondary_joypad = NULL; tmp->destroy(); } #endif - p_rarch->keyboard_mapping_blocked = false; - input_st->current_data = NULL; + input_st->keyboard_mapping_blocked = false; + input_st->current_data = NULL; } if (p_rarch->video_driver_data @@ -20407,6 +20430,7 @@ static bool video_driver_init_internal( video_viewport_t *custom_vp = NULL; input_driver_t *tmp = NULL; static uint16_t dummy_pixels[32] = {0}; + input_driver_state_t *input_st = input_state_get_ptr(); struct retro_game_geometry *geom = &p_rarch->video_driver_av_info.geometry; const enum retro_pixel_format video_driver_pix_fmt = p_rarch->video_driver_pix_fmt; @@ -20703,18 +20727,18 @@ static bool video_driver_init_internal( /* Ensure that we preserve the 'grab mouse' * state if it was enabled prior to driver * (re-)initialisation */ - if (p_rarch->input_driver_grab_mouse_state) + if (input_st->grab_mouse_state) { video_driver_hide_mouse(); if (input_driver_grab_mouse()) - p_rarch->input_driver_grab_mouse_state = true; + input_st->grab_mouse_state = true; } else if (video.fullscreen) { video_driver_hide_mouse(); if (!settings->bools.video_windowed_fullscreen) if (input_driver_grab_mouse()) - p_rarch->input_driver_grab_mouse_state = true; + input_st->grab_mouse_state = true; } return true; @@ -22448,7 +22472,7 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->input_driver_nonblock_state = input_st ? input_st->nonblocking_flag : false; - video_info->input_driver_grab_mouse_state = p_rarch->input_driver_grab_mouse_state; + video_info->input_driver_grab_mouse_state = input_st->grab_mouse_state; video_info->disp_userdata = disp_get_ptr(); video_info->userdata = VIDEO_DRIVER_GET_PTR_INTERNAL(p_rarch); @@ -23455,16 +23479,16 @@ static void retroarch_deinit_drivers( p_rarch->current_audio = NULL; /* Input */ - p_rarch->input_driver_keyboard_linefeed_enable = false; - p_rarch->input_driver_block_hotkey = false; - p_rarch->input_driver_block_libretro_input = false; + input_st->keyboard_linefeed_enable = false; + input_st->block_hotkey = false; + input_st->block_libretro_input = false; if (input_st) input_st->nonblocking_flag = false; - memset(&p_rarch->input_driver_turbo_btns, 0, sizeof(turbo_buttons_t)); - memset(&p_rarch->input_driver_analog_requested, 0, - sizeof(p_rarch->input_driver_analog_requested)); + memset(&input_st->turbo_btns, 0, sizeof(turbo_buttons_t)); + memset(&input_st->analog_requested, 0, + sizeof(input_st->analog_requested)); input_st->current_driver = NULL; #ifdef HAVE_MENU @@ -25311,6 +25335,8 @@ bool retroarch_main_init(int argc, char *argv[]) bool verbosity_enabled = false; bool init_failed = false; struct rarch_state *p_rarch = &rarch_st; + input_driver_state_t + *input_st = input_state_get_ptr(); settings_t *settings = p_rarch->configuration_settings; global_t *global = &p_rarch->g_extern; #ifdef HAVE_ACCESSIBILITY @@ -25562,20 +25588,20 @@ bool retroarch_main_init(int argc, char *argv[]) #endif drivers_init(p_rarch, settings, DRIVERS_CMD_ALL, verbosity_enabled); #ifdef HAVE_COMMAND - input_driver_deinit_command(p_rarch); - input_driver_init_command(p_rarch, settings); + input_driver_deinit_command(p_rarch, input_st); + input_driver_init_command(p_rarch, input_st, settings); #endif #ifdef HAVE_NETWORKGAMEPAD - if (p_rarch->input_driver_remote) - input_remote_free(p_rarch->input_driver_remote, + if (input_st->remote) + input_remote_free(input_st->remote, settings->uints.input_max_users); - p_rarch->input_driver_remote = NULL; + input_st->remote = NULL; if (settings->bools.network_remote_enable) - p_rarch->input_driver_remote = input_driver_init_remote( + input_st->remote = input_driver_init_remote( settings, settings->uints.input_max_users); #endif - input_mapper_reset(&p_rarch->input_driver_mapper); + input_mapper_reset(&input_st->mapper); #ifdef HAVE_REWIND command_event(CMD_EVENT_REWIND_INIT, NULL); #endif @@ -26080,51 +26106,54 @@ bool retroarch_ctl(enum rarch_ctl_state state, void *data) case RARCH_CTL_IS_INITED: return p_rarch->rarch_is_inited; case RARCH_CTL_MAIN_DEINIT: - if (!p_rarch->rarch_is_inited) - return false; - command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); + { + input_driver_state_t *input_st = input_state_get_ptr(); + if (!p_rarch->rarch_is_inited) + return false; + command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); #ifdef HAVE_COMMAND - input_driver_deinit_command(p_rarch); + input_driver_deinit_command(p_rarch, input_st); #endif #ifdef HAVE_NETWORKGAMEPAD - if (p_rarch->input_driver_remote) - input_remote_free(p_rarch->input_driver_remote, - p_rarch->configuration_settings->uints.input_max_users); - p_rarch->input_driver_remote = NULL; + if (input_st->remote) + input_remote_free(input_st->remote, + p_rarch->configuration_settings->uints.input_max_users); + input_st->remote = NULL; #endif - input_mapper_reset(&p_rarch->input_driver_mapper); + input_mapper_reset(&input_st->mapper); #ifdef HAVE_THREADS - if (p_rarch->rarch_use_sram) - autosave_deinit(); + if (p_rarch->rarch_use_sram) + autosave_deinit(); #endif - command_event(CMD_EVENT_RECORD_DEINIT, NULL); + command_event(CMD_EVENT_RECORD_DEINIT, NULL); - command_event(CMD_EVENT_SAVE_FILES, NULL); + command_event(CMD_EVENT_SAVE_FILES, NULL); #ifdef HAVE_REWIND - command_event(CMD_EVENT_REWIND_DEINIT, NULL); + command_event(CMD_EVENT_REWIND_DEINIT, NULL); #endif #ifdef HAVE_CHEATS - cheat_manager_state_free(); + cheat_manager_state_free(); #endif #ifdef HAVE_BSV_MOVIE - bsv_movie_deinit(p_rarch); + bsv_movie_deinit(p_rarch); #endif - command_event(CMD_EVENT_CORE_DEINIT, NULL); + command_event(CMD_EVENT_CORE_DEINIT, NULL); - content_deinit(); + content_deinit(); - path_deinit_subsystem(p_rarch); - path_deinit_savefile(); + path_deinit_subsystem(p_rarch); + path_deinit_savefile(); - p_rarch->rarch_is_inited = false; + p_rarch->rarch_is_inited = false; #ifdef HAVE_THREAD_STORAGE - sthread_tls_delete(&p_rarch->rarch_tls); + sthread_tls_delete(&p_rarch->rarch_tls); #endif + } break; #ifdef HAVE_CONFIGFILE case RARCH_CTL_SET_BLOCK_CONFIG_READ: @@ -26228,21 +26257,24 @@ bool retroarch_ctl(enum rarch_ctl_state state, void *data) } break; case RARCH_CTL_STATE_FREE: - runloop_state.perfcnt_enable = false; - runloop_state.idle = false; - runloop_state.paused = false; - runloop_state.slowmotion = false; + { + input_driver_state_t *input_st = input_state_get_ptr(); + runloop_state.perfcnt_enable = false; + runloop_state.idle = false; + runloop_state.paused = false; + runloop_state.slowmotion = false; #ifdef HAVE_CONFIGFILE - runloop_state.overrides_active = false; + runloop_state.overrides_active = false; #endif - runloop_state.autosave = false; - retroarch_frame_time_free(); - retroarch_audio_buffer_status_free(); - retroarch_game_focus_free(&p_rarch->game_focus_state); - retroarch_fastmotion_override_free(p_rarch, &runloop_state); - retroarch_core_options_callback_free(&runloop_state); - memset(&p_rarch->input_driver_analog_requested, 0, - sizeof(p_rarch->input_driver_analog_requested)); + runloop_state.autosave = false; + retroarch_frame_time_free(); + retroarch_audio_buffer_status_free(); + retroarch_game_focus_free(&p_rarch->game_focus_state); + retroarch_fastmotion_override_free(p_rarch, &runloop_state); + retroarch_core_options_callback_free(&runloop_state); + memset(&input_st->analog_requested, 0, + sizeof(input_st->analog_requested)); + } break; case RARCH_CTL_IS_IDLE: return runloop_state.idle; @@ -26715,6 +26747,7 @@ void runloop_msg_queue_push(const char *msg, /* Display the libretro core's framebuffer onscreen. */ static bool menu_display_libretro( struct rarch_state *p_rarch, + input_driver_state_t *input_st, float slowmotion_ratio, bool libretro_running, retro_time_t current_time) @@ -26729,13 +26762,13 @@ static bool menu_display_libretro( if (libretro_running) { - if (!p_rarch->input_driver_block_libretro_input) - p_rarch->input_driver_block_libretro_input = true; + if (!input_st->block_libretro_input) + input_st->block_libretro_input = true; core_run(); - p_rarch->libretro_core_runtime_usec += + p_rarch->libretro_core_runtime_usec += retroarch_core_runtime_tick(p_rarch, slowmotion_ratio, current_time); - p_rarch->input_driver_block_libretro_input = false; + input_st->block_libretro_input = false; return false; } @@ -26882,11 +26915,11 @@ static enum runloop_state runloop_check_state( BIT256_CLEAR_ALL_PTR(¤t_bits); - p_rarch->input_driver_block_libretro_input = false; - p_rarch->input_driver_block_hotkey = false; + input_st->block_libretro_input = false; + input_st->block_hotkey = false; - if (p_rarch->keyboard_mapping_blocked) - p_rarch->input_driver_block_hotkey = true; + if (input_st->keyboard_mapping_blocked) + input_st->block_hotkey = true; { rarch_joypad_info_t joypad_info; @@ -27017,7 +27050,7 @@ static enum runloop_state runloop_check_state( joypad, sec_joypad, &joypad_info, &binds, - p_rarch->keyboard_mapping_blocked, + input_st->keyboard_mapping_blocked, port, RETRO_DEVICE_KEYBOARD, 0, ids[i][0])) BIT256_SET_PTR(¤t_bits, ids[i][1]); @@ -27115,7 +27148,7 @@ static enum runloop_state runloop_check_state( if (settings->bools.input_auto_mouse_grab && is_focused && is_focused != runloop_state.focused && - !p_rarch->input_driver_grab_mouse_state) + !input_st->grab_mouse_state) command_event(CMD_EVENT_GRAB_MOUSE_TOGGLE, NULL); runloop_state.focused = is_focused; @@ -27154,7 +27187,7 @@ static enum runloop_state runloop_check_state( HOTKEY_CHECK(RARCH_OVERLAY_NEXT, CMD_EVENT_OVERLAY_NEXT, true, &check_next_rotation); /* Ensure overlay is restored after displaying osk */ - if (p_rarch->input_driver_keyboard_linefeed_enable) + if (input_st->keyboard_linefeed_enable) prev_overlay_restore = true; else if (prev_overlay_restore) { @@ -27512,7 +27545,7 @@ static enum runloop_state runloop_check_state( } if (menu_st->alive && !runloop_state.idle) - if (menu_display_libretro(p_rarch, + if (menu_display_libretro(p_rarch, input_st, settings->floats.slowmotion_ratio, libretro_running, current_time)) video_driver_cached_frame(); @@ -28244,8 +28277,7 @@ int runloop_iterate(void) case ANALOG_DPAD_RSTICK: { unsigned mapped_port = settings->uints.input_remap_ports[i]; - - if (p_rarch->input_driver_analog_requested[mapped_port]) + if (input_st->analog_requested[mapped_port]) dpad_mode[i] = ANALOG_DPAD_NONE; } break; @@ -28826,7 +28858,8 @@ bool core_set_poll_type(unsigned type) bool core_set_controller_port_device(retro_ctx_controller_info_t *pad) { - struct rarch_state *p_rarch = &rarch_st; + struct rarch_state *p_rarch = &rarch_st; + input_driver_state_t *input_st = input_state_get_ptr(); if (!pad) return false; @@ -28838,8 +28871,8 @@ bool core_set_controller_port_device(retro_ctx_controller_info_t *pad) * to simply reset the flags for all ports. * Correct values will be registered at the next call * of 'input_state()' */ - memset(&p_rarch->input_driver_analog_requested, 0, - sizeof(p_rarch->input_driver_analog_requested)); + memset(&input_st->analog_requested, 0, + sizeof(input_st->analog_requested)); #ifdef HAVE_RUNAHEAD remember_controller_port_device(p_rarch, pad->port, pad->device); diff --git a/retroarch.h b/retroarch.h index d104fd57f6..455d283f3d 100644 --- a/retroarch.h +++ b/retroarch.h @@ -41,14 +41,10 @@ #include "audio/audio_defines.h" #include "gfx/video_driver.h" -#include "core_type.h" #include "core.h" -#ifdef HAVE_MENU -#include "menu/menu_defines.h" -#endif - #include "runloop.h" +#include "retroarch_types.h" RETRO_BEGIN_DECLS @@ -83,285 +79,6 @@ RETRO_BEGIN_DECLS * 3 - Late */ -enum rarch_ctl_state -{ - RARCH_CTL_NONE = 0, - - /* Deinitializes RetroArch. */ - RARCH_CTL_MAIN_DEINIT, - - RARCH_CTL_IS_INITED, - - RARCH_CTL_IS_DUMMY_CORE, - RARCH_CTL_IS_CORE_LOADED, - -#if defined(HAVE_RUNAHEAD) && (defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)) - RARCH_CTL_IS_SECOND_CORE_AVAILABLE, - RARCH_CTL_IS_SECOND_CORE_LOADED, -#endif - - RARCH_CTL_IS_BPS_PREF, - RARCH_CTL_UNSET_BPS_PREF, - - RARCH_CTL_IS_PATCH_BLOCKED, - - RARCH_CTL_IS_UPS_PREF, - RARCH_CTL_UNSET_UPS_PREF, - - RARCH_CTL_IS_IPS_PREF, - RARCH_CTL_UNSET_IPS_PREF, - -#ifdef HAVE_CONFIGFILE - /* Block config read */ - RARCH_CTL_SET_BLOCK_CONFIG_READ, - RARCH_CTL_UNSET_BLOCK_CONFIG_READ, -#endif - - /* Username */ - RARCH_CTL_HAS_SET_USERNAME, - - RARCH_CTL_HAS_SET_SUBSYSTEMS, - - RARCH_CTL_IS_IDLE, - RARCH_CTL_SET_IDLE, - - RARCH_CTL_SET_WINDOWED_SCALE, - -#ifdef HAVE_CONFIGFILE - RARCH_CTL_IS_OVERRIDES_ACTIVE, - - RARCH_CTL_IS_REMAPS_CORE_ACTIVE, - RARCH_CTL_SET_REMAPS_CORE_ACTIVE, - - RARCH_CTL_IS_REMAPS_CONTENT_DIR_ACTIVE, - RARCH_CTL_SET_REMAPS_CONTENT_DIR_ACTIVE, - - RARCH_CTL_IS_REMAPS_GAME_ACTIVE, - RARCH_CTL_SET_REMAPS_GAME_ACTIVE, -#endif - - RARCH_CTL_IS_MISSING_BIOS, - RARCH_CTL_SET_MISSING_BIOS, - RARCH_CTL_UNSET_MISSING_BIOS, - - RARCH_CTL_IS_GAME_OPTIONS_ACTIVE, - RARCH_CTL_IS_FOLDER_OPTIONS_ACTIVE, - - RARCH_CTL_IS_PAUSED, - RARCH_CTL_SET_PAUSED, - - RARCH_CTL_SET_SHUTDOWN, - - /* Runloop state */ - RARCH_CTL_STATE_FREE, - - /* Performance counters */ - RARCH_CTL_GET_PERFCNT, - RARCH_CTL_SET_PERFCNT_ENABLE, - RARCH_CTL_UNSET_PERFCNT_ENABLE, - RARCH_CTL_IS_PERFCNT_ENABLE, - - /* Core options */ - RARCH_CTL_HAS_CORE_OPTIONS, - RARCH_CTL_GET_CORE_OPTION_SIZE, - RARCH_CTL_CORE_OPTIONS_LIST_GET, - RARCH_CTL_CORE_OPTION_PREV, - RARCH_CTL_CORE_OPTION_NEXT, - RARCH_CTL_CORE_OPTION_UPDATE_DISPLAY, - RARCH_CTL_CORE_IS_RUNNING, - - /* BSV Movie */ - RARCH_CTL_BSV_MOVIE_IS_INITED -}; - -enum rarch_capabilities -{ - RARCH_CAPABILITIES_NONE = 0, - RARCH_CAPABILITIES_CPU, - RARCH_CAPABILITIES_COMPILER -}; - -enum rarch_override_setting -{ - RARCH_OVERRIDE_SETTING_NONE = 0, - RARCH_OVERRIDE_SETTING_LIBRETRO, - RARCH_OVERRIDE_SETTING_VERBOSITY, - RARCH_OVERRIDE_SETTING_LIBRETRO_DIRECTORY, - RARCH_OVERRIDE_SETTING_SAVE_PATH, - RARCH_OVERRIDE_SETTING_STATE_PATH, -#ifdef HAVE_NETWORKING - RARCH_OVERRIDE_SETTING_NETPLAY_MODE, - RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS, - RARCH_OVERRIDE_SETTING_NETPLAY_IP_PORT, - RARCH_OVERRIDE_SETTING_NETPLAY_STATELESS_MODE, - RARCH_OVERRIDE_SETTING_NETPLAY_CHECK_FRAMES, -#endif - RARCH_OVERRIDE_SETTING_UPS_PREF, - RARCH_OVERRIDE_SETTING_BPS_PREF, - RARCH_OVERRIDE_SETTING_IPS_PREF, - RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, - RARCH_OVERRIDE_SETTING_LOG_TO_FILE, - RARCH_OVERRIDE_SETTING_LAST -}; - -enum runloop_action -{ - RUNLOOP_ACTION_NONE = 0, - RUNLOOP_ACTION_AUTOSAVE -}; - -struct rarch_main_wrap -{ - char **argv; - const char *content_path; - const char *sram_path; - const char *state_path; - const char *config_path; - const char *libretro_path; - int argc; - bool verbose; - bool no_content; - bool touched; -}; - -typedef struct rarch_resolution -{ - unsigned idx; - unsigned id; -} rarch_resolution_t; - -/* All run-time- / command line flag-related globals go here. */ - -typedef struct global -{ -#ifdef HAVE_MENU - struct - { - retro_time_t prev_start_time; - retro_time_t noop_press_time; - retro_time_t noop_start_time; - retro_time_t action_start_time; - retro_time_t action_press_time; - } menu; -#endif - struct - { - char *remapfile; - char savefile[8192]; - char savestate[8192]; - char cheatfile[8192]; - char ups[8192]; - char bps[8192]; - char ips[8192]; - char label[8192]; - } name; - - /* Recording. */ - struct - { - size_t gpu_width; - size_t gpu_height; - unsigned width; - unsigned height; - char path[8192]; - char config[8192]; - char output_dir[8192]; - char config_dir[8192]; - bool use_output_dir; - } record; - - /* Settings and/or global state that is specific to - * a console-style implementation. */ - struct - { - struct - { - struct - { - uint32_t *list; - unsigned count; - rarch_resolution_t current; - rarch_resolution_t initial; - bool check; - } resolutions; - unsigned gamma_correction; - unsigned int flicker_filter_index; - unsigned char soft_filter_index; - bool pal_enable; - bool pal60_enable; - } screen; - - bool flickerfilter_enable; - bool softfilter_enable; - - } console; - unsigned old_analog_dpad_mode[MAX_USERS]; - unsigned old_libretro_device[MAX_USERS]; - bool old_analog_dpad_mode_set; - bool old_libretro_device_set; - bool remapping_cache_active; - /* Settings and/or global states specific to menus */ -#ifdef HAVE_MENU - enum menu_action menu_prev_action; -#endif - bool launched_from_cli; - bool cli_load_menu_on_error; -} global_t; - -typedef struct content_file_override -{ - char *ext; - bool need_fullpath; - bool persistent_data; -} content_file_override_t; - -typedef struct content_file_info -{ - char *full_path; - char *archive_path; - char *archive_file; - char *dir; - char *name; - char *ext; - char *meta; /* Unused at present */ - void *data; - size_t data_size; - bool file_in_archive; - bool persistent_data; -} content_file_info_t; - -typedef struct content_file_list -{ - content_file_info_t *entries; - struct string_list *temporary_files; - struct retro_game_info *game_info; - struct retro_game_info_ext *game_info_ext; - size_t size; -} content_file_list_t; - -typedef struct content_state -{ - char *pending_subsystem_roms[RARCH_MAX_SUBSYSTEM_ROMS]; - - content_file_override_t *content_override_list; - content_file_list_t *content_list; - - int pending_subsystem_rom_num; - int pending_subsystem_id; - unsigned pending_subsystem_rom_id; - uint32_t rom_crc; - - char companion_ui_crc32[32]; - char pending_subsystem_ident[255]; - char pending_rom_crc_path[PATH_MAX_LENGTH]; - char companion_ui_db_name[PATH_MAX_LENGTH]; - - bool is_inited; - bool core_does_not_need_content; - bool pending_subsystem_init; - bool pending_rom_crc; -} content_state_t; - bool retroarch_ctl(enum rarch_ctl_state state, void *data); int retroarch_get_capabilities(enum rarch_capabilities type, @@ -650,101 +367,6 @@ extern audio_driver_t audio_rwebaudio; /* Recording */ -enum ffemu_pix_format -{ - FFEMU_PIX_RGB565 = 0, - FFEMU_PIX_BGR24, - FFEMU_PIX_ARGB8888 -}; - -enum streaming_mode -{ - STREAMING_MODE_TWITCH = 0, - STREAMING_MODE_YOUTUBE, - STREAMING_MODE_FACEBOOK, - STREAMING_MODE_LOCAL, - STREAMING_MODE_CUSTOM -}; - -enum record_config_type -{ - RECORD_CONFIG_TYPE_RECORDING_CUSTOM = 0, - RECORD_CONFIG_TYPE_RECORDING_LOW_QUALITY, - RECORD_CONFIG_TYPE_RECORDING_MED_QUALITY, - RECORD_CONFIG_TYPE_RECORDING_HIGH_QUALITY, - RECORD_CONFIG_TYPE_RECORDING_LOSSLESS_QUALITY, - RECORD_CONFIG_TYPE_RECORDING_WEBM_FAST, - RECORD_CONFIG_TYPE_RECORDING_WEBM_HIGH_QUALITY, - RECORD_CONFIG_TYPE_RECORDING_GIF, - RECORD_CONFIG_TYPE_RECORDING_APNG, - RECORD_CONFIG_TYPE_STREAMING_CUSTOM, - RECORD_CONFIG_TYPE_STREAMING_LOW_QUALITY, - RECORD_CONFIG_TYPE_STREAMING_MED_QUALITY, - RECORD_CONFIG_TYPE_STREAMING_HIGH_QUALITY, - RECORD_CONFIG_TYPE_STREAMING_NETPLAY - -}; - -/* Parameters passed to ffemu_new() */ -struct record_params -{ - /* Framerate per second of input video. */ - double fps; - /* Sample rate of input audio. */ - double samplerate; - - /* Filename to dump to. */ - const char *filename; - - /* Path to config. Optional. */ - const char *config; - - const char *audio_resampler; - - /* Desired output resolution. */ - unsigned out_width; - unsigned out_height; - - /* Total size of framebuffer used in input. */ - unsigned fb_width; - unsigned fb_height; - - /* Audio channels. */ - unsigned channels; - - unsigned video_record_scale_factor; - unsigned video_stream_scale_factor; - unsigned video_record_threads; - unsigned streaming_mode; - - /* Aspect ratio of input video. Parameters are passed to the muxer, - * the video itself is not scaled. - */ - float aspect_ratio; - - enum record_config_type preset; - - /* Input pixel format. */ - enum ffemu_pix_format pix_fmt; - - bool video_gpu_record; -}; - -struct record_video_data -{ - const void *data; - unsigned width; - unsigned height; - int pitch; - bool is_dupe; -}; - -struct record_audio_data -{ - const void *data; - size_t frames; -}; - typedef struct record_driver { void *(*init)(const struct record_params *params); diff --git a/retroarch_data.h b/retroarch_data.h index 1124ac3d8d..eaa6864ca7 100644 --- a/retroarch_data.h +++ b/retroarch_data.h @@ -765,18 +765,6 @@ typedef struct my_list_t int size; } my_list; -typedef struct turbo_buttons turbo_buttons_t; - -/* Turbo support. */ -struct turbo_buttons -{ - int32_t turbo_pressed[MAX_USERS]; - unsigned count; - uint16_t enable[MAX_USERS]; - bool frame_enable[MAX_USERS]; - bool mode1_enable[MAX_USERS]; -}; - typedef struct input_game_focus_state { bool enabled; @@ -946,12 +934,6 @@ struct rarch_state void *keyboard_press_data; -#ifdef HAVE_COMMAND - command_t *input_driver_command[MAX_CMD_DRIVERS]; -#endif -#ifdef HAVE_NETWORKGAMEPAD - input_remote_t *input_driver_remote; -#endif #ifdef HAVE_HID const void *hid_data; @@ -1054,8 +1036,6 @@ struct rarch_state jmp_buf error_sjlj_context; /* 4-byte alignment, put it right before long */ - - turbo_buttons_t input_driver_turbo_btns; /* int32_t alignment */ int osk_ptr; #if defined(HAVE_COMMAND) #ifdef HAVE_NETWORK_CMD @@ -1157,8 +1137,6 @@ struct rarch_state */ gfx_ctx_flags_t deferred_flag_data; /* uint32_t alignment */ retro_bits_t has_set_libretro_device; /* uint32_t alignment */ - input_mapper_t input_driver_mapper; /* uint32_t alignment */ - #ifdef HAVE_BSV_MOVIE struct bsv_state bsv_movie_state; /* char alignment */ @@ -1328,21 +1306,11 @@ struct rarch_state bool has_set_netplay_check_frames; #endif - bool input_driver_keyboard_linefeed_enable; - - bool input_driver_block_hotkey; - bool input_driver_block_libretro_input; - bool input_driver_grab_mouse_state; - bool input_driver_analog_requested[MAX_USERS]; - input_game_focus_state_t game_focus_state; /* bool alignment */ bool recording_enable; bool streaming_enable; - - bool main_ui_companion_is_on_foreground; - bool keyboard_mapping_blocked; retro_bits_512_t keyboard_mapping_bits; #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) diff --git a/retroarch_types.h b/retroarch_types.h new file mode 100644 index 0000000000..6cbd238ed0 --- /dev/null +++ b/retroarch_types.h @@ -0,0 +1,528 @@ +#ifndef _RETROARCH_TYPES_H +#define _RETROARCH_TYPES_H + +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_MENU +#include "menu/menu_defines.h" +#endif + +#include "input/input_defines.h" +#include "disk_control_interface.h" + +RETRO_BEGIN_DECLS + +enum +{ + /* Polling is performed before + * call to retro_run. */ + POLL_TYPE_EARLY = 0, + + /* Polling is performed when requested. */ + POLL_TYPE_NORMAL, + + /* Polling is performed on first call to + * retro_input_state per frame. */ + POLL_TYPE_LATE +}; + +enum rarch_core_type +{ + CORE_TYPE_PLAIN = 0, + CORE_TYPE_DUMMY, + CORE_TYPE_FFMPEG, + CORE_TYPE_MPV, + CORE_TYPE_IMAGEVIEWER, + CORE_TYPE_NETRETROPAD, + CORE_TYPE_VIDEO_PROCESSOR, + CORE_TYPE_GONG +}; + +enum rarch_ctl_state +{ + RARCH_CTL_NONE = 0, + + /* Deinitializes RetroArch. */ + RARCH_CTL_MAIN_DEINIT, + + RARCH_CTL_IS_INITED, + + RARCH_CTL_IS_DUMMY_CORE, + RARCH_CTL_IS_CORE_LOADED, + +#if defined(HAVE_RUNAHEAD) && (defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)) + RARCH_CTL_IS_SECOND_CORE_AVAILABLE, + RARCH_CTL_IS_SECOND_CORE_LOADED, +#endif + + RARCH_CTL_IS_BPS_PREF, + RARCH_CTL_UNSET_BPS_PREF, + + RARCH_CTL_IS_PATCH_BLOCKED, + + RARCH_CTL_IS_UPS_PREF, + RARCH_CTL_UNSET_UPS_PREF, + + RARCH_CTL_IS_IPS_PREF, + RARCH_CTL_UNSET_IPS_PREF, + +#ifdef HAVE_CONFIGFILE + /* Block config read */ + RARCH_CTL_SET_BLOCK_CONFIG_READ, + RARCH_CTL_UNSET_BLOCK_CONFIG_READ, +#endif + + /* Username */ + RARCH_CTL_HAS_SET_USERNAME, + + RARCH_CTL_HAS_SET_SUBSYSTEMS, + + RARCH_CTL_IS_IDLE, + RARCH_CTL_SET_IDLE, + + RARCH_CTL_SET_WINDOWED_SCALE, + +#ifdef HAVE_CONFIGFILE + RARCH_CTL_IS_OVERRIDES_ACTIVE, + + RARCH_CTL_IS_REMAPS_CORE_ACTIVE, + RARCH_CTL_SET_REMAPS_CORE_ACTIVE, + + RARCH_CTL_IS_REMAPS_CONTENT_DIR_ACTIVE, + RARCH_CTL_SET_REMAPS_CONTENT_DIR_ACTIVE, + + RARCH_CTL_IS_REMAPS_GAME_ACTIVE, + RARCH_CTL_SET_REMAPS_GAME_ACTIVE, +#endif + + RARCH_CTL_IS_MISSING_BIOS, + RARCH_CTL_SET_MISSING_BIOS, + RARCH_CTL_UNSET_MISSING_BIOS, + + RARCH_CTL_IS_GAME_OPTIONS_ACTIVE, + RARCH_CTL_IS_FOLDER_OPTIONS_ACTIVE, + + RARCH_CTL_IS_PAUSED, + RARCH_CTL_SET_PAUSED, + + RARCH_CTL_SET_SHUTDOWN, + + /* Runloop state */ + RARCH_CTL_STATE_FREE, + + /* Performance counters */ + RARCH_CTL_GET_PERFCNT, + RARCH_CTL_SET_PERFCNT_ENABLE, + RARCH_CTL_UNSET_PERFCNT_ENABLE, + RARCH_CTL_IS_PERFCNT_ENABLE, + + /* Core options */ + RARCH_CTL_HAS_CORE_OPTIONS, + RARCH_CTL_GET_CORE_OPTION_SIZE, + RARCH_CTL_CORE_OPTIONS_LIST_GET, + RARCH_CTL_CORE_OPTION_PREV, + RARCH_CTL_CORE_OPTION_NEXT, + RARCH_CTL_CORE_OPTION_UPDATE_DISPLAY, + RARCH_CTL_CORE_IS_RUNNING, + + /* BSV Movie */ + RARCH_CTL_BSV_MOVIE_IS_INITED +}; + +enum rarch_capabilities +{ + RARCH_CAPABILITIES_NONE = 0, + RARCH_CAPABILITIES_CPU, + RARCH_CAPABILITIES_COMPILER +}; + +enum rarch_override_setting +{ + RARCH_OVERRIDE_SETTING_NONE = 0, + RARCH_OVERRIDE_SETTING_LIBRETRO, + RARCH_OVERRIDE_SETTING_VERBOSITY, + RARCH_OVERRIDE_SETTING_LIBRETRO_DIRECTORY, + RARCH_OVERRIDE_SETTING_SAVE_PATH, + RARCH_OVERRIDE_SETTING_STATE_PATH, +#ifdef HAVE_NETWORKING + RARCH_OVERRIDE_SETTING_NETPLAY_MODE, + RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS, + RARCH_OVERRIDE_SETTING_NETPLAY_IP_PORT, + RARCH_OVERRIDE_SETTING_NETPLAY_STATELESS_MODE, + RARCH_OVERRIDE_SETTING_NETPLAY_CHECK_FRAMES, +#endif + RARCH_OVERRIDE_SETTING_UPS_PREF, + RARCH_OVERRIDE_SETTING_BPS_PREF, + RARCH_OVERRIDE_SETTING_IPS_PREF, + RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, + RARCH_OVERRIDE_SETTING_LOG_TO_FILE, + RARCH_OVERRIDE_SETTING_LAST +}; + +enum runloop_action +{ + RUNLOOP_ACTION_NONE = 0, + RUNLOOP_ACTION_AUTOSAVE +}; + + +enum ffemu_pix_format +{ + FFEMU_PIX_RGB565 = 0, + FFEMU_PIX_BGR24, + FFEMU_PIX_ARGB8888 +}; + +enum streaming_mode +{ + STREAMING_MODE_TWITCH = 0, + STREAMING_MODE_YOUTUBE, + STREAMING_MODE_FACEBOOK, + STREAMING_MODE_LOCAL, + STREAMING_MODE_CUSTOM +}; + +enum record_config_type +{ + RECORD_CONFIG_TYPE_RECORDING_CUSTOM = 0, + RECORD_CONFIG_TYPE_RECORDING_LOW_QUALITY, + RECORD_CONFIG_TYPE_RECORDING_MED_QUALITY, + RECORD_CONFIG_TYPE_RECORDING_HIGH_QUALITY, + RECORD_CONFIG_TYPE_RECORDING_LOSSLESS_QUALITY, + RECORD_CONFIG_TYPE_RECORDING_WEBM_FAST, + RECORD_CONFIG_TYPE_RECORDING_WEBM_HIGH_QUALITY, + RECORD_CONFIG_TYPE_RECORDING_GIF, + RECORD_CONFIG_TYPE_RECORDING_APNG, + RECORD_CONFIG_TYPE_STREAMING_CUSTOM, + RECORD_CONFIG_TYPE_STREAMING_LOW_QUALITY, + RECORD_CONFIG_TYPE_STREAMING_MED_QUALITY, + RECORD_CONFIG_TYPE_STREAMING_HIGH_QUALITY, + RECORD_CONFIG_TYPE_STREAMING_NETPLAY +}; + +typedef struct rarch_memory_descriptor +{ + struct retro_memory_descriptor core; /* uint64_t alignment */ + size_t disconnect_mask; +} rarch_memory_descriptor_t; + +typedef struct rarch_memory_map +{ + rarch_memory_descriptor_t *descriptors; + unsigned num_descriptors; +} rarch_memory_map_t; + +typedef struct rarch_system_info +{ + struct retro_location_callback location_cb; /* ptr alignment */ + disk_control_interface_t disk_control; /* ptr alignment */ + struct retro_system_info info; /* ptr alignment */ + rarch_memory_map_t mmaps; /* ptr alignment */ + const char *input_desc_btn[MAX_USERS][RARCH_FIRST_META_KEY]; + struct + { + struct retro_subsystem_info *data; + unsigned size; + } subsystem; + struct + { + struct retro_controller_info *data; + unsigned size; + } ports; + unsigned rotation; + unsigned performance_level; + char valid_extensions[255]; + bool load_no_content; + bool supports_vfs; +} rarch_system_info_t; + +typedef struct retro_ctx_input_state_info +{ + retro_input_state_t cb; +} retro_ctx_input_state_info_t; + +typedef struct retro_ctx_cheat_info +{ + const char *code; + unsigned index; + bool enabled; +} retro_ctx_cheat_info_t; + +typedef struct retro_ctx_api_info +{ + unsigned version; +} retro_ctx_api_info_t; + +typedef struct retro_ctx_region_info +{ + unsigned region; +} retro_ctx_region_info_t; + +typedef struct retro_ctx_controller_info +{ + unsigned port; + unsigned device; +} retro_ctx_controller_info_t; + +typedef struct retro_ctx_memory_info +{ + void *data; + size_t size; + unsigned id; +} retro_ctx_memory_info_t; + +typedef struct retro_ctx_load_content_info +{ + struct retro_game_info *info; + const struct string_list *content; + const struct retro_subsystem_info *special; +} retro_ctx_load_content_info_t; + +typedef struct retro_ctx_serialize_info +{ + const void *data_const; + void *data; + size_t size; +} retro_ctx_serialize_info_t; + +typedef struct retro_ctx_size_info +{ + size_t size; +} retro_ctx_size_info_t; + +typedef struct retro_ctx_environ_info +{ + retro_environment_t env; +} retro_ctx_environ_info_t; + +typedef struct retro_callbacks +{ + retro_video_refresh_t frame_cb; + retro_audio_sample_t sample_cb; + retro_audio_sample_batch_t sample_batch_cb; + retro_input_state_t state_cb; + retro_input_poll_t poll_cb; +} retro_callbacks_t; + +struct rarch_main_wrap +{ + char **argv; + const char *content_path; + const char *sram_path; + const char *state_path; + const char *config_path; + const char *libretro_path; + int argc; + bool verbose; + bool no_content; + bool touched; +}; + +typedef struct rarch_resolution +{ + unsigned idx; + unsigned id; +} rarch_resolution_t; + +/* All run-time- / command line flag-related globals go here. */ + +typedef struct global +{ +#ifdef HAVE_MENU + struct + { + retro_time_t prev_start_time; + retro_time_t noop_press_time; + retro_time_t noop_start_time; + retro_time_t action_start_time; + retro_time_t action_press_time; + } menu; +#endif + struct + { + char *remapfile; + char savefile[8192]; + char savestate[8192]; + char cheatfile[8192]; + char ups[8192]; + char bps[8192]; + char ips[8192]; + char label[8192]; + } name; + + /* Recording. */ + struct + { + size_t gpu_width; + size_t gpu_height; + unsigned width; + unsigned height; + char path[8192]; + char config[8192]; + char output_dir[8192]; + char config_dir[8192]; + bool use_output_dir; + } record; + + /* Settings and/or global state that is specific to + * a console-style implementation. */ + struct + { + struct + { + struct + { + uint32_t *list; + unsigned count; + rarch_resolution_t current; + rarch_resolution_t initial; + bool check; + } resolutions; + unsigned gamma_correction; + unsigned int flicker_filter_index; + unsigned char soft_filter_index; + bool pal_enable; + bool pal60_enable; + } screen; + + bool flickerfilter_enable; + bool softfilter_enable; + + } console; + unsigned old_analog_dpad_mode[MAX_USERS]; + unsigned old_libretro_device[MAX_USERS]; + bool old_analog_dpad_mode_set; + bool old_libretro_device_set; + bool remapping_cache_active; + /* Settings and/or global states specific to menus */ +#ifdef HAVE_MENU + enum menu_action menu_prev_action; +#endif + bool launched_from_cli; + bool cli_load_menu_on_error; +} global_t; + +typedef struct content_file_override +{ + char *ext; + bool need_fullpath; + bool persistent_data; +} content_file_override_t; + +typedef struct content_file_info +{ + char *full_path; + char *archive_path; + char *archive_file; + char *dir; + char *name; + char *ext; + char *meta; /* Unused at present */ + void *data; + size_t data_size; + bool file_in_archive; + bool persistent_data; +} content_file_info_t; + +typedef struct content_file_list +{ + content_file_info_t *entries; + struct string_list *temporary_files; + struct retro_game_info *game_info; + struct retro_game_info_ext *game_info_ext; + size_t size; +} content_file_list_t; + +typedef struct content_state +{ + char *pending_subsystem_roms[RARCH_MAX_SUBSYSTEM_ROMS]; + + content_file_override_t *content_override_list; + content_file_list_t *content_list; + + int pending_subsystem_rom_num; + int pending_subsystem_id; + unsigned pending_subsystem_rom_id; + uint32_t rom_crc; + + char companion_ui_crc32[32]; + char pending_subsystem_ident[255]; + char pending_rom_crc_path[PATH_MAX_LENGTH]; + char companion_ui_db_name[PATH_MAX_LENGTH]; + + bool is_inited; + bool core_does_not_need_content; + bool pending_subsystem_init; + bool pending_rom_crc; +} content_state_t; + +/* Parameters passed to ffemu_new() */ +struct record_params +{ + /* Framerate per second of input video. */ + double fps; + /* Sample rate of input audio. */ + double samplerate; + + /* Filename to dump to. */ + const char *filename; + + /* Path to config. Optional. */ + const char *config; + + const char *audio_resampler; + + /* Desired output resolution. */ + unsigned out_width; + unsigned out_height; + + /* Total size of framebuffer used in input. */ + unsigned fb_width; + unsigned fb_height; + + /* Audio channels. */ + unsigned channels; + + unsigned video_record_scale_factor; + unsigned video_stream_scale_factor; + unsigned video_record_threads; + unsigned streaming_mode; + + /* Aspect ratio of input video. Parameters are passed to the muxer, + * the video itself is not scaled. + */ + float aspect_ratio; + + enum record_config_type preset; + + /* Input pixel format. */ + enum ffemu_pix_format pix_fmt; + + bool video_gpu_record; +}; + +struct record_video_data +{ + const void *data; + unsigned width; + unsigned height; + int pitch; + bool is_dupe; +}; + +struct record_audio_data +{ + const void *data; + size_t frames; +}; + + +RETRO_END_DECLS + +#endif diff --git a/tasks/task_content.h b/tasks/task_content.h index 03f9e4bc2a..6f0f64a424 100644 --- a/tasks/task_content.h +++ b/tasks/task_content.h @@ -29,7 +29,7 @@ #endif #include "../content.h" -#include "../core_type.h" +#include "../retroarch_types.h" RETRO_BEGIN_DECLS diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index 032c9f869c..2536fbfd54 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -4943,7 +4943,7 @@ static void ui_companion_qt_toggle(void *data, bool force) settings_t *settings = config_get_ptr(); bool ui_companion_toggle = settings->bools.ui_companion_toggle; bool video_fullscreen = settings->bools.video_fullscreen; - bool mouse_grabbed = input_mouse_grabbed(); + bool mouse_grabbed = input_state_get_ptr()->grab_mouse_state; if (ui_companion_toggle || force) {