mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-22 23:49:50 +00:00
Revert "static variables are initialized to '0' automatically as per C rules"
Some checks are pending
CI 3DS / build (push) Waiting to run
CI Android / build (push) Waiting to run
CI DOS/DJGPP / build (push) Waiting to run
CI Emscripten / build (push) Waiting to run
CI GameCube / build (push) Waiting to run
CI Linux (i686) / build (push) Waiting to run
CI Windows (MSVC) / msvc (Debug, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Debug, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, UWP) (push) Waiting to run
CI Windows (MSVC) / msvc (ReleaseAngle, x64, UWP) (push) Waiting to run
CI macOS / build (push) Waiting to run
CI Miyoo ARM32 / build (push) Waiting to run
CI PS2 / build (push) Waiting to run
CI PS4/ORBIS / build (push) Waiting to run
CI PSP / build (push) Waiting to run
CI PSVita / build (push) Waiting to run
CI RS90 Odbeta MIPS32 / build (push) Waiting to run
CI RetroFW MIPS32 / build (push) Waiting to run
CI Switch/libnx / build (push) Waiting to run
CI Wii / build (push) Waiting to run
CI WiiU / build (push) Waiting to run
CI Windows i686 (MXE) / build (push) Waiting to run
CI Windows x64 (MXE) / build (push) Waiting to run
RetroArch CI / linux-c89 (push) Waiting to run
CI webOS / build (push) Waiting to run
Some checks are pending
CI 3DS / build (push) Waiting to run
CI Android / build (push) Waiting to run
CI DOS/DJGPP / build (push) Waiting to run
CI Emscripten / build (push) Waiting to run
CI GameCube / build (push) Waiting to run
CI Linux (i686) / build (push) Waiting to run
CI Windows (MSVC) / msvc (Debug, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Debug, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, UWP) (push) Waiting to run
CI Windows (MSVC) / msvc (ReleaseAngle, x64, UWP) (push) Waiting to run
CI macOS / build (push) Waiting to run
CI Miyoo ARM32 / build (push) Waiting to run
CI PS2 / build (push) Waiting to run
CI PS4/ORBIS / build (push) Waiting to run
CI PSP / build (push) Waiting to run
CI PSVita / build (push) Waiting to run
CI RS90 Odbeta MIPS32 / build (push) Waiting to run
CI RetroFW MIPS32 / build (push) Waiting to run
CI Switch/libnx / build (push) Waiting to run
CI Wii / build (push) Waiting to run
CI WiiU / build (push) Waiting to run
CI Windows i686 (MXE) / build (push) Waiting to run
CI Windows x64 (MXE) / build (push) Waiting to run
RetroArch CI / linux-c89 (push) Waiting to run
CI webOS / build (push) Waiting to run
This reverts commit 2a0984b6e4
.
This commit is contained in:
parent
82e4504968
commit
2809421d4e
@ -172,7 +172,7 @@ audio_driver_t *audio_drivers[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static audio_driver_state_t audio_driver_st; /* double alignment */
|
||||
static audio_driver_state_t audio_driver_st = {0}; /* double alignment */
|
||||
|
||||
/**************************************/
|
||||
|
||||
@ -1872,7 +1872,7 @@ bool audio_compute_buffer_statistics(audio_statistics_t *stats)
|
||||
#ifdef HAVE_MENU
|
||||
void audio_driver_menu_sample(void)
|
||||
{
|
||||
static int16_t samples_buf[1024];
|
||||
static int16_t samples_buf[1024] = {0};
|
||||
settings_t *settings = config_get_ptr();
|
||||
video_driver_state_t *video_st = video_state_get_ptr();
|
||||
uint32_t runloop_flags = runloop_get_flags();
|
||||
|
@ -85,7 +85,7 @@ static uint8_t g_plat_win32_flags = PLAT_WIN32_FLAG_USE_POWERSHELL;
|
||||
VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL);
|
||||
|
||||
/* TODO/FIXME - static global variables */
|
||||
static char win32_cpu_model_name[64];
|
||||
static char win32_cpu_model_name[64] = {0};
|
||||
#ifdef HAVE_DYLIB
|
||||
/* We only load this library once, so we let it be
|
||||
* unloaded at application shutdown, since unloading
|
||||
|
@ -43,10 +43,10 @@ static void android_display_server_set_screen_orientation(void *data,
|
||||
|
||||
static void android_display_dpi_get_density(char *s, size_t len)
|
||||
{
|
||||
static char string[PROP_VALUE_MAX];
|
||||
static char string2[PROP_VALUE_MAX];
|
||||
static bool inited_once = false;
|
||||
static bool inited2_once = false;
|
||||
static char string[PROP_VALUE_MAX] = {0};
|
||||
static char string2[PROP_VALUE_MAX] = {0};
|
||||
if (!inited_once)
|
||||
{
|
||||
system_property_get("getprop", "ro.sf.lcd_density", string);
|
||||
|
@ -85,7 +85,7 @@ typedef struct omapfb_data
|
||||
|
||||
static const char *omapfb_get_fb_device(void)
|
||||
{
|
||||
static char fbname[12];
|
||||
static char fbname[12] = {0};
|
||||
settings_t *settings = config_get_ptr();
|
||||
const int fbidx = settings->uints.video_monitor_index;
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
static uintptr_t gfx_white_texture;
|
||||
|
||||
/* ptr alignment */
|
||||
static gfx_display_t dispgfx_st;
|
||||
static gfx_display_t dispgfx_st = {0};
|
||||
|
||||
gfx_display_t *disp_get_ptr(void)
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ typedef struct
|
||||
gfx_thumbnail_t *thumbnail;
|
||||
} gfx_thumbnail_tag_t;
|
||||
|
||||
static gfx_thumbnail_state_t gfx_thumb_st; /* uint64_t alignment */
|
||||
static gfx_thumbnail_state_t gfx_thumb_st = {0}; /* uint64_t alignment */
|
||||
|
||||
gfx_thumbnail_state_t *gfx_thumb_get_ptr(void)
|
||||
{
|
||||
@ -289,10 +289,10 @@ void gfx_thumbnail_request(
|
||||
/* Handle on demand thumbnail downloads */
|
||||
else if (network_on_demand_thumbnails)
|
||||
{
|
||||
static char last_img_name[NAME_MAX_LENGTH];
|
||||
enum playlist_thumbnail_name_flags curr_flag;
|
||||
const char *system = NULL;
|
||||
const char *img_name = NULL;
|
||||
static char last_img_name[NAME_MAX_LENGTH] = {0};
|
||||
settings_t *settings = config_get_ptr();
|
||||
if (!playlist)
|
||||
goto end;
|
||||
|
@ -65,7 +65,7 @@ static const char
|
||||
"menu_achievements.png"
|
||||
};
|
||||
|
||||
static dispgfx_widget_t dispwidget_st; /* uint64_t alignment */
|
||||
static dispgfx_widget_t dispwidget_st = {0}; /* uint64_t alignment */
|
||||
|
||||
static void INLINE gfx_widgets_font_free(gfx_widget_font_data_t *font_data)
|
||||
{
|
||||
|
@ -515,12 +515,12 @@ static void crt_rpi_switch(videocrt_switch_t *p_switch,
|
||||
{
|
||||
int w;
|
||||
char buffer[1024];
|
||||
static char output1[250];
|
||||
static char output2[250];
|
||||
static char set_hdmi[250];
|
||||
static char set_hdmi_timing[250];
|
||||
VCHI_INSTANCE_T vchi_instance;
|
||||
VCHI_CONNECTION_T *vchi_connection = NULL;
|
||||
static char output1[250] = {0};
|
||||
static char output2[250] = {0};
|
||||
static char set_hdmi[250] = {0};
|
||||
static char set_hdmi_timing[250] = {0};
|
||||
int i = 0;
|
||||
int hfp = 0;
|
||||
int hsp = 0;
|
||||
|
@ -3229,10 +3229,10 @@ const char* video_driver_get_gpu_api_version_string(void)
|
||||
bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
|
||||
{
|
||||
video_info_t video;
|
||||
static uint16_t dummy_pixels[32];
|
||||
unsigned max_dim, scale, width, height;
|
||||
video_viewport_t *custom_vp = NULL;
|
||||
input_driver_t *tmp = NULL;
|
||||
static uint16_t dummy_pixels[32] = {0};
|
||||
runloop_state_t *runloop_st = runloop_state_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
input_driver_state_t *input_st = input_state_get_ptr();
|
||||
|
@ -63,7 +63,7 @@ enum sdl_webos_special_key
|
||||
sdl_webos_spkey_size,
|
||||
};
|
||||
|
||||
static uint8_t sdl_webos_special_keymap[sdl_webos_spkey_size];
|
||||
static uint8_t sdl_webos_special_keymap[sdl_webos_spkey_size] = {0};
|
||||
#endif
|
||||
|
||||
static void *sdl_input_init(const char *joypad_driver)
|
||||
@ -249,7 +249,7 @@ static int16_t sdl_input_state(
|
||||
if (idx == 0)
|
||||
{
|
||||
struct video_viewport vp;
|
||||
bool screen = device ==
|
||||
bool screen = device ==
|
||||
RARCH_DEVICE_POINTER_SCREEN;
|
||||
const int edge_detect = 32700;
|
||||
bool inside = false;
|
||||
@ -275,7 +275,7 @@ static int16_t sdl_input_state(
|
||||
res_y = res_screen_y;
|
||||
}
|
||||
|
||||
inside = (res_x >= -edge_detect)
|
||||
inside = (res_x >= -edge_detect)
|
||||
&& (res_y >= -edge_detect)
|
||||
&& (res_x <= edge_detect)
|
||||
&& (res_y <= edge_detect);
|
||||
@ -397,7 +397,7 @@ static void sdl_input_poll(void *data)
|
||||
switch ((int) event.key.keysym.scancode)
|
||||
{
|
||||
case SDL_WEBOS_SCANCODE_BACK:
|
||||
/* Because webOS is sending DOWN/UP at the same time,
|
||||
/* Because webOS is sending DOWN/UP at the same time,
|
||||
we save this flag for later */
|
||||
sdl_webos_special_keymap[sdl_webos_spkey_back] |= event.type == SDL_KEYDOWN;
|
||||
code = RETROK_BACKSPACE;
|
||||
|
@ -396,7 +396,7 @@ hid_driver_t *hid_drivers[] = {
|
||||
};
|
||||
#endif
|
||||
|
||||
static input_driver_state_t input_driver_st; /* double alignment */
|
||||
static input_driver_state_t input_driver_st = {0}; /* double alignment */
|
||||
|
||||
/**************************************/
|
||||
|
||||
|
@ -518,7 +518,7 @@ static const char *menu_hash_to_str_us_label_enum(enum msg_hash_enums msg)
|
||||
if ( msg <= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END
|
||||
&& msg >= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN)
|
||||
{
|
||||
static char hotkey_lbl[128];
|
||||
static char hotkey_lbl[128] = {0};
|
||||
unsigned idx = msg - MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN;
|
||||
snprintf(hotkey_lbl, sizeof(hotkey_lbl), "input_hotkey_binds_%d", idx);
|
||||
return hotkey_lbl;
|
||||
|
@ -97,7 +97,7 @@ static bool rzipstream_read_file_header(rzipstream_t *stream)
|
||||
/* Check 'magic numbers' - first 8 bytes
|
||||
* of header */
|
||||
if (
|
||||
(length < RZIP_HEADER_SIZE) ||
|
||||
(length < RZIP_HEADER_SIZE) ||
|
||||
(header_bytes[0] != 35) || /* # */
|
||||
(header_bytes[1] != 82) || /* R */
|
||||
(header_bytes[2] != 90) || /* Z */
|
||||
@ -270,7 +270,7 @@ static bool rzipstream_init_stream(
|
||||
stream->in_buf_size = stream->chunk_size;
|
||||
stream->out_buf_size = stream->chunk_size * 2;
|
||||
/* > Account for minimum zlib overhead
|
||||
* of 11 bytes... */
|
||||
* of 11 bytes... */
|
||||
stream->out_buf_size =
|
||||
(stream->out_buf_size < (stream->in_buf_size + 11)) ?
|
||||
stream->out_buf_size + 11 :
|
||||
@ -846,7 +846,7 @@ int rzipstream_putc(rzipstream_t *stream, int c)
|
||||
* in the event of an error */
|
||||
int rzipstream_vprintf(rzipstream_t *stream, const char* format, va_list args)
|
||||
{
|
||||
static char buffer[8 * 1024];
|
||||
static char buffer[8 * 1024] = {0};
|
||||
int64_t num_chars = vsnprintf(buffer,
|
||||
sizeof(buffer), format, args);
|
||||
|
||||
|
@ -211,10 +211,10 @@ static struct rmsgpack_dom_value query_func_between(
|
||||
|
||||
if (argc != 2)
|
||||
return res;
|
||||
if ( argv[0].type != AT_VALUE
|
||||
if ( argv[0].type != AT_VALUE
|
||||
|| argv[1].type != AT_VALUE)
|
||||
return res;
|
||||
if ( argv[0].a.value.type != RDT_INT
|
||||
if ( argv[0].a.value.type != RDT_INT
|
||||
|| argv[1].a.value.type != RDT_INT)
|
||||
return res;
|
||||
|
||||
@ -301,7 +301,7 @@ static void query_argument_free(struct argument *arg)
|
||||
}
|
||||
|
||||
static struct buffer query_parse_integer(
|
||||
char *s, size_t len,
|
||||
char *s, size_t len,
|
||||
struct buffer buff,
|
||||
struct rmsgpack_dom_value *value,
|
||||
const char **error)
|
||||
@ -495,7 +495,7 @@ static struct buffer query_parse_value(
|
||||
}
|
||||
else if (
|
||||
query_peek(buff, "b", STRLEN_CONST("b"))
|
||||
|| query_peek(buff, "\"", STRLEN_CONST("\""))
|
||||
|| query_peek(buff, "\"", STRLEN_CONST("\""))
|
||||
|| query_peek(buff, "'", STRLEN_CONST("'")))
|
||||
buff = query_parse_string(s, len,
|
||||
buff, value, error);
|
||||
@ -921,7 +921,7 @@ void *libretrodb_query_compile(libretrodb_t *db,
|
||||
{
|
||||
struct buffer buff;
|
||||
/* TODO/FIXME - static local variable */
|
||||
static char tmp_error_buff [MAX_ERROR_LEN];
|
||||
static char tmp_error_buff [MAX_ERROR_LEN] = {0};
|
||||
struct query *q = (struct query*)malloc(sizeof(*q));
|
||||
size_t error_buff_len = sizeof(tmp_error_buff);
|
||||
|
||||
|
@ -5212,7 +5212,7 @@ void cb_generic_download(retro_task_t *task,
|
||||
case MENU_ENUM_LABEL_CB_UPDATE_SHADERS_SLANG:
|
||||
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
|
||||
{
|
||||
static char shaderdir[DIR_MAX_LENGTH];
|
||||
static char shaderdir[DIR_MAX_LENGTH] = {0};
|
||||
const char *dirname = NULL;
|
||||
const char *dir_video_shader = settings->paths.directory_video_shader;
|
||||
|
||||
|
@ -1,245 +1,245 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2021 - Daniel De Matteis
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
#include "../driver.h"
|
||||
#include "../list_special.h"
|
||||
#include "../retroarch.h"
|
||||
#include "../runloop.h"
|
||||
#include "../verbosity.h"
|
||||
|
||||
#include "wifi_driver.h"
|
||||
|
||||
wifi_driver_t wifi_null = {
|
||||
NULL, /* init */
|
||||
NULL, /* free */
|
||||
NULL, /* start */
|
||||
NULL, /* stop */
|
||||
NULL, /* enable */
|
||||
NULL, /* connection_info */
|
||||
NULL, /* scan */
|
||||
NULL, /* get_ssids */
|
||||
NULL, /* ssid_is_online */
|
||||
NULL, /* connect_ssid */
|
||||
NULL, /* disconnect_ssid */
|
||||
NULL, /* tether_start_stop */
|
||||
"null",
|
||||
};
|
||||
|
||||
const wifi_driver_t *wifi_drivers[] = {
|
||||
#ifdef HAVE_LAKKA
|
||||
&wifi_connmanctl,
|
||||
#endif
|
||||
#ifdef HAVE_WIFI
|
||||
&wifi_nmcli,
|
||||
#endif
|
||||
&wifi_null,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static wifi_driver_state_t wifi_driver_st; /* double alignment */
|
||||
|
||||
wifi_driver_state_t *wifi_state_get_ptr(void)
|
||||
{
|
||||
return &wifi_driver_st;
|
||||
}
|
||||
|
||||
/**
|
||||
* config_get_wifi_driver_options:
|
||||
*
|
||||
* Get an enumerated list of all wifi driver names,
|
||||
* separated by '|'.
|
||||
*
|
||||
* Returns: string listing of all wifi driver names,
|
||||
* separated by '|'.
|
||||
**/
|
||||
const char* config_get_wifi_driver_options(void)
|
||||
{
|
||||
return char_list_new_special(STRING_LIST_WIFI_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
void driver_wifi_scan(void)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
wifi_st->drv->scan(wifi_st->data);
|
||||
}
|
||||
|
||||
bool driver_wifi_enable(bool enabled)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
return wifi_st->drv->enable(wifi_st->data, enabled);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool driver_wifi_connection_info(wifi_network_info_t *netinfo)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
return wifi_st->drv->connection_info(wifi_st->data, netinfo);
|
||||
return false;
|
||||
}
|
||||
|
||||
wifi_network_scan_t* driver_wifi_get_ssids(void)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
return wifi_st->drv->get_ssids(wifi_st->data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool driver_wifi_ssid_is_online(unsigned i)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
return wifi_st->drv->ssid_is_online(wifi_st->data, i);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool driver_wifi_connect_ssid(const wifi_network_info_t* net)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
return wifi_st->drv->connect_ssid(wifi_st->data, net);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool driver_wifi_disconnect_ssid(const wifi_network_info_t* net)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
return wifi_st->drv->disconnect_ssid(wifi_st->data, net);
|
||||
return false;
|
||||
}
|
||||
|
||||
void driver_wifi_tether_start_stop(bool start, char* configfile)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
wifi_st->drv->tether_start_stop(wifi_st->data, start, configfile);
|
||||
}
|
||||
|
||||
bool wifi_driver_ctl(enum rarch_wifi_ctl_state state, void *data)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case RARCH_WIFI_CTL_DESTROY:
|
||||
wifi_st->active = false;
|
||||
wifi_st->drv = NULL;
|
||||
wifi_st->data = NULL;
|
||||
break;
|
||||
case RARCH_WIFI_CTL_SET_ACTIVE:
|
||||
wifi_st->active = true;
|
||||
break;
|
||||
case RARCH_WIFI_CTL_FIND_DRIVER:
|
||||
{
|
||||
const char *prefix = "wifi driver";
|
||||
int i = (int)driver_find_index(
|
||||
"wifi_driver",
|
||||
settings->arrays.wifi_driver);
|
||||
|
||||
if (i >= 0)
|
||||
wifi_st->drv = (const wifi_driver_t*)wifi_drivers[i];
|
||||
else
|
||||
{
|
||||
if (verbosity_is_enabled())
|
||||
{
|
||||
unsigned d;
|
||||
RARCH_ERR("Couldn't find any %s named \"%s\"\n", prefix,
|
||||
settings->arrays.wifi_driver);
|
||||
RARCH_LOG_OUTPUT("Available %ss are:\n", prefix);
|
||||
for (d = 0; wifi_drivers[d]; d++)
|
||||
RARCH_LOG_OUTPUT("\t%s\n", wifi_drivers[d]->ident);
|
||||
|
||||
RARCH_WARN("Going to default to first %s...\n", prefix);
|
||||
}
|
||||
|
||||
wifi_st->drv = (const wifi_driver_t*)wifi_drivers[0];
|
||||
|
||||
if (!wifi_st->drv)
|
||||
retroarch_fail(1, "find_wifi_driver()");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RARCH_WIFI_CTL_UNSET_ACTIVE:
|
||||
wifi_st->active = false;
|
||||
break;
|
||||
case RARCH_WIFI_CTL_IS_ACTIVE:
|
||||
return wifi_st->active;
|
||||
case RARCH_WIFI_CTL_DEINIT:
|
||||
if (wifi_st->data && wifi_st->drv)
|
||||
{
|
||||
if (wifi_st->drv->free)
|
||||
wifi_st->drv->free(wifi_st->data);
|
||||
}
|
||||
|
||||
wifi_st->data = NULL;
|
||||
break;
|
||||
case RARCH_WIFI_CTL_STOP:
|
||||
if ( wifi_st->drv
|
||||
&& wifi_st->drv->stop
|
||||
&& wifi_st->data)
|
||||
wifi_st->drv->stop(wifi_st->data);
|
||||
break;
|
||||
case RARCH_WIFI_CTL_START:
|
||||
if ( wifi_st->drv
|
||||
&& wifi_st->data
|
||||
&& wifi_st->drv->start)
|
||||
{
|
||||
bool wifi_allow = settings->bools.wifi_allow;
|
||||
if (wifi_allow)
|
||||
return wifi_st->drv->start(wifi_st->data);
|
||||
}
|
||||
return false;
|
||||
case RARCH_WIFI_CTL_INIT:
|
||||
/* Resource leaks will follow if wifi is initialized twice. */
|
||||
if (wifi_st->data)
|
||||
return false;
|
||||
|
||||
wifi_driver_ctl(RARCH_WIFI_CTL_FIND_DRIVER, NULL);
|
||||
|
||||
if (wifi_st->drv && wifi_st->drv->init)
|
||||
{
|
||||
wifi_st->data = wifi_st->drv->init();
|
||||
|
||||
if (wifi_st->data)
|
||||
{
|
||||
wifi_st->drv->enable(wifi_st->data,
|
||||
settings->bools.wifi_enabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_ERR("Failed to initialize wifi driver. Will continue without wifi.\n");
|
||||
wifi_driver_ctl(RARCH_WIFI_CTL_UNSET_ACTIVE, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2021 - Daniel De Matteis
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
#include "../driver.h"
|
||||
#include "../list_special.h"
|
||||
#include "../retroarch.h"
|
||||
#include "../runloop.h"
|
||||
#include "../verbosity.h"
|
||||
|
||||
#include "wifi_driver.h"
|
||||
|
||||
wifi_driver_t wifi_null = {
|
||||
NULL, /* init */
|
||||
NULL, /* free */
|
||||
NULL, /* start */
|
||||
NULL, /* stop */
|
||||
NULL, /* enable */
|
||||
NULL, /* connection_info */
|
||||
NULL, /* scan */
|
||||
NULL, /* get_ssids */
|
||||
NULL, /* ssid_is_online */
|
||||
NULL, /* connect_ssid */
|
||||
NULL, /* disconnect_ssid */
|
||||
NULL, /* tether_start_stop */
|
||||
"null",
|
||||
};
|
||||
|
||||
const wifi_driver_t *wifi_drivers[] = {
|
||||
#ifdef HAVE_LAKKA
|
||||
&wifi_connmanctl,
|
||||
#endif
|
||||
#ifdef HAVE_WIFI
|
||||
&wifi_nmcli,
|
||||
#endif
|
||||
&wifi_null,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static wifi_driver_state_t wifi_driver_st = {0}; /* double alignment */
|
||||
|
||||
wifi_driver_state_t *wifi_state_get_ptr(void)
|
||||
{
|
||||
return &wifi_driver_st;
|
||||
}
|
||||
|
||||
/**
|
||||
* config_get_wifi_driver_options:
|
||||
*
|
||||
* Get an enumerated list of all wifi driver names,
|
||||
* separated by '|'.
|
||||
*
|
||||
* Returns: string listing of all wifi driver names,
|
||||
* separated by '|'.
|
||||
**/
|
||||
const char* config_get_wifi_driver_options(void)
|
||||
{
|
||||
return char_list_new_special(STRING_LIST_WIFI_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
void driver_wifi_scan(void)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
wifi_st->drv->scan(wifi_st->data);
|
||||
}
|
||||
|
||||
bool driver_wifi_enable(bool enabled)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
return wifi_st->drv->enable(wifi_st->data, enabled);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool driver_wifi_connection_info(wifi_network_info_t *netinfo)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
return wifi_st->drv->connection_info(wifi_st->data, netinfo);
|
||||
return false;
|
||||
}
|
||||
|
||||
wifi_network_scan_t* driver_wifi_get_ssids(void)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
return wifi_st->drv->get_ssids(wifi_st->data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool driver_wifi_ssid_is_online(unsigned i)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
return wifi_st->drv->ssid_is_online(wifi_st->data, i);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool driver_wifi_connect_ssid(const wifi_network_info_t* net)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
return wifi_st->drv->connect_ssid(wifi_st->data, net);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool driver_wifi_disconnect_ssid(const wifi_network_info_t* net)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
return wifi_st->drv->disconnect_ssid(wifi_st->data, net);
|
||||
return false;
|
||||
}
|
||||
|
||||
void driver_wifi_tether_start_stop(bool start, char* configfile)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
if (wifi_st && wifi_st->drv)
|
||||
wifi_st->drv->tether_start_stop(wifi_st->data, start, configfile);
|
||||
}
|
||||
|
||||
bool wifi_driver_ctl(enum rarch_wifi_ctl_state state, void *data)
|
||||
{
|
||||
wifi_driver_state_t *wifi_st = &wifi_driver_st;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case RARCH_WIFI_CTL_DESTROY:
|
||||
wifi_st->active = false;
|
||||
wifi_st->drv = NULL;
|
||||
wifi_st->data = NULL;
|
||||
break;
|
||||
case RARCH_WIFI_CTL_SET_ACTIVE:
|
||||
wifi_st->active = true;
|
||||
break;
|
||||
case RARCH_WIFI_CTL_FIND_DRIVER:
|
||||
{
|
||||
const char *prefix = "wifi driver";
|
||||
int i = (int)driver_find_index(
|
||||
"wifi_driver",
|
||||
settings->arrays.wifi_driver);
|
||||
|
||||
if (i >= 0)
|
||||
wifi_st->drv = (const wifi_driver_t*)wifi_drivers[i];
|
||||
else
|
||||
{
|
||||
if (verbosity_is_enabled())
|
||||
{
|
||||
unsigned d;
|
||||
RARCH_ERR("Couldn't find any %s named \"%s\"\n", prefix,
|
||||
settings->arrays.wifi_driver);
|
||||
RARCH_LOG_OUTPUT("Available %ss are:\n", prefix);
|
||||
for (d = 0; wifi_drivers[d]; d++)
|
||||
RARCH_LOG_OUTPUT("\t%s\n", wifi_drivers[d]->ident);
|
||||
|
||||
RARCH_WARN("Going to default to first %s...\n", prefix);
|
||||
}
|
||||
|
||||
wifi_st->drv = (const wifi_driver_t*)wifi_drivers[0];
|
||||
|
||||
if (!wifi_st->drv)
|
||||
retroarch_fail(1, "find_wifi_driver()");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RARCH_WIFI_CTL_UNSET_ACTIVE:
|
||||
wifi_st->active = false;
|
||||
break;
|
||||
case RARCH_WIFI_CTL_IS_ACTIVE:
|
||||
return wifi_st->active;
|
||||
case RARCH_WIFI_CTL_DEINIT:
|
||||
if (wifi_st->data && wifi_st->drv)
|
||||
{
|
||||
if (wifi_st->drv->free)
|
||||
wifi_st->drv->free(wifi_st->data);
|
||||
}
|
||||
|
||||
wifi_st->data = NULL;
|
||||
break;
|
||||
case RARCH_WIFI_CTL_STOP:
|
||||
if ( wifi_st->drv
|
||||
&& wifi_st->drv->stop
|
||||
&& wifi_st->data)
|
||||
wifi_st->drv->stop(wifi_st->data);
|
||||
break;
|
||||
case RARCH_WIFI_CTL_START:
|
||||
if ( wifi_st->drv
|
||||
&& wifi_st->data
|
||||
&& wifi_st->drv->start)
|
||||
{
|
||||
bool wifi_allow = settings->bools.wifi_allow;
|
||||
if (wifi_allow)
|
||||
return wifi_st->drv->start(wifi_st->data);
|
||||
}
|
||||
return false;
|
||||
case RARCH_WIFI_CTL_INIT:
|
||||
/* Resource leaks will follow if wifi is initialized twice. */
|
||||
if (wifi_st->data)
|
||||
return false;
|
||||
|
||||
wifi_driver_ctl(RARCH_WIFI_CTL_FIND_DRIVER, NULL);
|
||||
|
||||
if (wifi_st->drv && wifi_st->drv->init)
|
||||
{
|
||||
wifi_st->data = wifi_st->drv->init();
|
||||
|
||||
if (wifi_st->data)
|
||||
{
|
||||
wifi_st->drv->enable(wifi_st->data,
|
||||
settings->bools.wifi_enabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_ERR("Failed to initialize wifi driver. Will continue without wifi.\n");
|
||||
wifi_driver_ctl(RARCH_WIFI_CTL_UNSET_ACTIVE, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1334,7 +1334,7 @@ bool playlist_push(playlist_t *playlist,
|
||||
|
||||
if (string_is_empty(core_name))
|
||||
{
|
||||
static char base_path[NAME_MAX_LENGTH];
|
||||
static char base_path[NAME_MAX_LENGTH] = {0};
|
||||
fill_pathname_base(base_path, real_core_path, sizeof(base_path));
|
||||
path_remove_extension(base_path);
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "drivers/record_ffmpeg.h"
|
||||
#include "drivers/record_wav.h"
|
||||
|
||||
static recording_state_t recording_state;
|
||||
static recording_state_t recording_state = {0};
|
||||
|
||||
static const record_driver_t record_null = {
|
||||
NULL, /* new */
|
||||
|
@ -330,14 +330,14 @@ struct rarch_state
|
||||
void libnx_apply_overclock(void);
|
||||
#endif
|
||||
|
||||
static struct rarch_state rarch_st;
|
||||
static struct rarch_state rarch_st = {0};
|
||||
|
||||
#ifdef HAVE_THREAD_STORAGE
|
||||
static const void *MAGIC_POINTER = (void*)(uintptr_t)0x0DEFACED;
|
||||
#endif
|
||||
|
||||
static access_state_t access_state_st;
|
||||
static struct global global_driver_st; /* retro_time_t alignment */
|
||||
static access_state_t access_state_st = {0};
|
||||
static struct global global_driver_st = {0}; /* retro_time_t alignment */
|
||||
|
||||
static void retro_frame_null(const void *data, unsigned width,
|
||||
unsigned height, size_t pitch) { }
|
||||
@ -361,7 +361,7 @@ static const location_driver_t *location_drivers[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static location_driver_state_t location_driver_st;
|
||||
static location_driver_state_t location_driver_st = {0};
|
||||
|
||||
location_driver_state_t *location_state_get_ptr(void)
|
||||
{
|
||||
|
@ -322,7 +322,7 @@
|
||||
#define PERF_LOG_FMT "[PERF]: Avg (%s): %llu ticks, %llu runs.\n"
|
||||
#endif
|
||||
|
||||
static runloop_state_t runloop_state;
|
||||
static runloop_state_t runloop_state = {0};
|
||||
|
||||
/* GLOBAL POINTER GETTERS */
|
||||
runloop_state_t *runloop_state_get_ptr(void)
|
||||
@ -6740,7 +6740,7 @@ static enum runloop_state_enum runloop_check_state(
|
||||
|
||||
if (settings->bools.video_shader_watch_files)
|
||||
{
|
||||
static rarch_timer_t timer;
|
||||
static rarch_timer_t timer = {0};
|
||||
static bool need_to_apply = false;
|
||||
|
||||
if (video_shader_check_for_changes())
|
||||
|
@ -990,7 +990,7 @@ static unsigned char invader_png[] = {
|
||||
};
|
||||
static unsigned int invader_png_len = 4008;
|
||||
|
||||
static ui_window_qt_t ui_window;
|
||||
static ui_window_qt_t ui_window = {0};
|
||||
|
||||
static const QPixmap getInvader(void)
|
||||
{
|
||||
|
@ -1,259 +1,259 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2021 - Daniel De Matteis
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
#include "../list_special.h"
|
||||
#include "../retroarch.h"
|
||||
#include "../runloop.h"
|
||||
#include "../verbosity.h"
|
||||
|
||||
#include "ui_companion_driver.h"
|
||||
|
||||
static ui_companion_driver_t ui_companion_null = {
|
||||
NULL, /* init */
|
||||
NULL, /* deinit */
|
||||
NULL, /* toggle */
|
||||
NULL, /* event_command */
|
||||
NULL, /* notify_refresh */
|
||||
NULL, /* msg_queue_push */
|
||||
NULL, /* render_messagebox */
|
||||
NULL, /* get_main_window */
|
||||
NULL, /* log_msg */
|
||||
NULL, /* is_active */
|
||||
NULL, /* get_app_icons */
|
||||
NULL, /* set_app_icon */
|
||||
NULL, /* get_app_icon_texture */
|
||||
NULL, /* browser_window */
|
||||
NULL, /* msg_window */
|
||||
NULL, /* window */
|
||||
NULL, /* application */
|
||||
"null", /* ident */
|
||||
};
|
||||
|
||||
static const ui_companion_driver_t *ui_companion_drivers[] = {
|
||||
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
|
||||
&ui_companion_win32,
|
||||
#endif
|
||||
#if defined(OSX)
|
||||
&ui_companion_cocoa,
|
||||
#endif
|
||||
#if defined(IOS)
|
||||
&ui_companion_cocoatouch,
|
||||
#endif
|
||||
&ui_companion_null,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
static uico_driver_state_t uico_driver_st; /* double alignment */
|
||||
|
||||
uico_driver_state_t *uico_state_get_ptr(void)
|
||||
{
|
||||
return &uico_driver_st;
|
||||
}
|
||||
|
||||
uint8_t ui_companion_get_flags(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
if (!uico_st)
|
||||
return 0;
|
||||
return uico_st->flags;
|
||||
}
|
||||
|
||||
void ui_companion_event_command(enum event_command action)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
if (ui && ui->event_command)
|
||||
ui->event_command(uico_st->data, action);
|
||||
#ifdef HAVE_QT
|
||||
if (ui_companion_qt.toggle && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
|
||||
ui_companion_qt.event_command(uico_st->qt_data, action);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ui_companion_driver_deinit(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
|
||||
if (!ui)
|
||||
return;
|
||||
if (ui->deinit)
|
||||
ui->deinit(uico_st->data);
|
||||
|
||||
#ifdef HAVE_QT
|
||||
if (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)
|
||||
{
|
||||
ui_companion_qt.deinit(uico_st->qt_data);
|
||||
uico_st->qt_data = NULL;
|
||||
}
|
||||
#endif
|
||||
uico_st->data = NULL;
|
||||
}
|
||||
|
||||
void ui_companion_driver_toggle(
|
||||
bool desktop_menu_enable,
|
||||
bool ui_companion_toggle,
|
||||
bool force)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
if (uico_st && uico_st->drv && uico_st->drv->toggle)
|
||||
uico_st->drv->toggle(uico_st->data, false);
|
||||
|
||||
#ifdef HAVE_QT
|
||||
if (desktop_menu_enable)
|
||||
{
|
||||
if ((ui_companion_toggle || force) && (!(uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)))
|
||||
{
|
||||
uico_st->qt_data = ui_companion_qt.init();
|
||||
uico_st->flags |= UICO_ST_FLAG_QT_IS_INITED;
|
||||
}
|
||||
|
||||
if (ui_companion_qt.toggle && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
|
||||
ui_companion_qt.toggle(uico_st->qt_data, force);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ui_companion_driver_init_first(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
settings_t *settings = config_get_ptr();
|
||||
#ifdef HAVE_QT
|
||||
bool desktop_menu_enable = settings->bools.desktop_menu_enable;
|
||||
bool ui_companion_toggle = settings->bools.ui_companion_toggle;
|
||||
|
||||
if (desktop_menu_enable && ui_companion_toggle)
|
||||
{
|
||||
uico_st->qt_data = ui_companion_qt.init();
|
||||
uico_st->flags |= UICO_ST_FLAG_QT_IS_INITED;
|
||||
}
|
||||
#else
|
||||
bool desktop_menu_enable = false;
|
||||
bool ui_companion_toggle = false;
|
||||
#endif
|
||||
unsigned ui_companion_start_on_boot =
|
||||
settings->bools.ui_companion_start_on_boot;
|
||||
uico_st->drv = (ui_companion_driver_t*)ui_companion_drivers[0];
|
||||
|
||||
if (!uico_st->drv)
|
||||
return;
|
||||
if (!ui_companion_start_on_boot)
|
||||
return;
|
||||
if (uico_st->drv->init)
|
||||
uico_st->data = uico_st->drv->init();
|
||||
|
||||
ui_companion_driver_toggle(desktop_menu_enable,
|
||||
ui_companion_toggle, false);
|
||||
}
|
||||
|
||||
void ui_companion_driver_notify_refresh(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
if (!ui)
|
||||
return;
|
||||
if (ui->notify_refresh)
|
||||
ui->notify_refresh(uico_st->data);
|
||||
|
||||
#ifdef HAVE_QT
|
||||
if (config_get_ptr()->bools.desktop_menu_enable)
|
||||
if (ui_companion_qt.notify_refresh && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
|
||||
ui_companion_qt.notify_refresh(uico_st->qt_data);
|
||||
#endif
|
||||
}
|
||||
|
||||
const ui_msg_window_t *ui_companion_driver_get_msg_window_ptr(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
if (ui)
|
||||
return ui->msg_window;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const ui_window_t *ui_companion_driver_get_window_ptr(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
if (ui)
|
||||
return ui->window;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const ui_browser_window_t *ui_companion_driver_get_browser_window_ptr(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
if (ui)
|
||||
return ui->browser_window;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ui_companion_driver_msg_queue_push(
|
||||
const char *msg, unsigned priority,
|
||||
unsigned duration, bool flush)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
|
||||
if (ui && ui->msg_queue_push)
|
||||
ui->msg_queue_push(uico_st->data, msg, priority, duration, flush);
|
||||
|
||||
#ifdef HAVE_QT
|
||||
if (config_get_ptr()->bools.desktop_menu_enable)
|
||||
if (ui_companion_qt.msg_queue_push && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
|
||||
ui_companion_qt.msg_queue_push(
|
||||
uico_st->qt_data,
|
||||
msg, priority, duration, flush);
|
||||
#endif
|
||||
}
|
||||
|
||||
void *ui_companion_driver_get_main_window(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
if (!ui || !ui->get_main_window)
|
||||
return NULL;
|
||||
return ui->get_main_window(uico_st->data);
|
||||
}
|
||||
|
||||
const char *ui_companion_driver_get_ident(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
if (ui)
|
||||
return ui->ident;
|
||||
return "null";
|
||||
}
|
||||
|
||||
void ui_companion_driver_log_msg(const char *msg)
|
||||
{
|
||||
#ifdef HAVE_QT
|
||||
uico_driver_state_t *uico_st= &uico_driver_st;
|
||||
bool window_is_active = uico_st->qt_data && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)
|
||||
&& ui_companion_qt.is_active(uico_st->qt_data);
|
||||
if (config_get_ptr()->bools.desktop_menu_enable)
|
||||
if (window_is_active)
|
||||
ui_companion_qt.log_msg(uico_st->qt_data, msg);
|
||||
#endif
|
||||
}
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2021 - Daniel De Matteis
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
#include "../list_special.h"
|
||||
#include "../retroarch.h"
|
||||
#include "../runloop.h"
|
||||
#include "../verbosity.h"
|
||||
|
||||
#include "ui_companion_driver.h"
|
||||
|
||||
static ui_companion_driver_t ui_companion_null = {
|
||||
NULL, /* init */
|
||||
NULL, /* deinit */
|
||||
NULL, /* toggle */
|
||||
NULL, /* event_command */
|
||||
NULL, /* notify_refresh */
|
||||
NULL, /* msg_queue_push */
|
||||
NULL, /* render_messagebox */
|
||||
NULL, /* get_main_window */
|
||||
NULL, /* log_msg */
|
||||
NULL, /* is_active */
|
||||
NULL, /* get_app_icons */
|
||||
NULL, /* set_app_icon */
|
||||
NULL, /* get_app_icon_texture */
|
||||
NULL, /* browser_window */
|
||||
NULL, /* msg_window */
|
||||
NULL, /* window */
|
||||
NULL, /* application */
|
||||
"null", /* ident */
|
||||
};
|
||||
|
||||
static const ui_companion_driver_t *ui_companion_drivers[] = {
|
||||
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
|
||||
&ui_companion_win32,
|
||||
#endif
|
||||
#if defined(OSX)
|
||||
&ui_companion_cocoa,
|
||||
#endif
|
||||
#if defined(IOS)
|
||||
&ui_companion_cocoatouch,
|
||||
#endif
|
||||
&ui_companion_null,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
static uico_driver_state_t uico_driver_st = {0}; /* double alignment */
|
||||
|
||||
uico_driver_state_t *uico_state_get_ptr(void)
|
||||
{
|
||||
return &uico_driver_st;
|
||||
}
|
||||
|
||||
uint8_t ui_companion_get_flags(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
if (!uico_st)
|
||||
return 0;
|
||||
return uico_st->flags;
|
||||
}
|
||||
|
||||
void ui_companion_event_command(enum event_command action)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
if (ui && ui->event_command)
|
||||
ui->event_command(uico_st->data, action);
|
||||
#ifdef HAVE_QT
|
||||
if (ui_companion_qt.toggle && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
|
||||
ui_companion_qt.event_command(uico_st->qt_data, action);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ui_companion_driver_deinit(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
|
||||
if (!ui)
|
||||
return;
|
||||
if (ui->deinit)
|
||||
ui->deinit(uico_st->data);
|
||||
|
||||
#ifdef HAVE_QT
|
||||
if (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)
|
||||
{
|
||||
ui_companion_qt.deinit(uico_st->qt_data);
|
||||
uico_st->qt_data = NULL;
|
||||
}
|
||||
#endif
|
||||
uico_st->data = NULL;
|
||||
}
|
||||
|
||||
void ui_companion_driver_toggle(
|
||||
bool desktop_menu_enable,
|
||||
bool ui_companion_toggle,
|
||||
bool force)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
if (uico_st && uico_st->drv && uico_st->drv->toggle)
|
||||
uico_st->drv->toggle(uico_st->data, false);
|
||||
|
||||
#ifdef HAVE_QT
|
||||
if (desktop_menu_enable)
|
||||
{
|
||||
if ((ui_companion_toggle || force) && (!(uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)))
|
||||
{
|
||||
uico_st->qt_data = ui_companion_qt.init();
|
||||
uico_st->flags |= UICO_ST_FLAG_QT_IS_INITED;
|
||||
}
|
||||
|
||||
if (ui_companion_qt.toggle && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
|
||||
ui_companion_qt.toggle(uico_st->qt_data, force);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ui_companion_driver_init_first(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
settings_t *settings = config_get_ptr();
|
||||
#ifdef HAVE_QT
|
||||
bool desktop_menu_enable = settings->bools.desktop_menu_enable;
|
||||
bool ui_companion_toggle = settings->bools.ui_companion_toggle;
|
||||
|
||||
if (desktop_menu_enable && ui_companion_toggle)
|
||||
{
|
||||
uico_st->qt_data = ui_companion_qt.init();
|
||||
uico_st->flags |= UICO_ST_FLAG_QT_IS_INITED;
|
||||
}
|
||||
#else
|
||||
bool desktop_menu_enable = false;
|
||||
bool ui_companion_toggle = false;
|
||||
#endif
|
||||
unsigned ui_companion_start_on_boot =
|
||||
settings->bools.ui_companion_start_on_boot;
|
||||
uico_st->drv = (ui_companion_driver_t*)ui_companion_drivers[0];
|
||||
|
||||
if (!uico_st->drv)
|
||||
return;
|
||||
if (!ui_companion_start_on_boot)
|
||||
return;
|
||||
if (uico_st->drv->init)
|
||||
uico_st->data = uico_st->drv->init();
|
||||
|
||||
ui_companion_driver_toggle(desktop_menu_enable,
|
||||
ui_companion_toggle, false);
|
||||
}
|
||||
|
||||
void ui_companion_driver_notify_refresh(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
if (!ui)
|
||||
return;
|
||||
if (ui->notify_refresh)
|
||||
ui->notify_refresh(uico_st->data);
|
||||
|
||||
#ifdef HAVE_QT
|
||||
if (config_get_ptr()->bools.desktop_menu_enable)
|
||||
if (ui_companion_qt.notify_refresh && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
|
||||
ui_companion_qt.notify_refresh(uico_st->qt_data);
|
||||
#endif
|
||||
}
|
||||
|
||||
const ui_msg_window_t *ui_companion_driver_get_msg_window_ptr(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
if (ui)
|
||||
return ui->msg_window;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const ui_window_t *ui_companion_driver_get_window_ptr(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
if (ui)
|
||||
return ui->window;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const ui_browser_window_t *ui_companion_driver_get_browser_window_ptr(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
if (ui)
|
||||
return ui->browser_window;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ui_companion_driver_msg_queue_push(
|
||||
const char *msg, unsigned priority,
|
||||
unsigned duration, bool flush)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
|
||||
if (ui && ui->msg_queue_push)
|
||||
ui->msg_queue_push(uico_st->data, msg, priority, duration, flush);
|
||||
|
||||
#ifdef HAVE_QT
|
||||
if (config_get_ptr()->bools.desktop_menu_enable)
|
||||
if (ui_companion_qt.msg_queue_push && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
|
||||
ui_companion_qt.msg_queue_push(
|
||||
uico_st->qt_data,
|
||||
msg, priority, duration, flush);
|
||||
#endif
|
||||
}
|
||||
|
||||
void *ui_companion_driver_get_main_window(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
if (!ui || !ui->get_main_window)
|
||||
return NULL;
|
||||
return ui->get_main_window(uico_st->data);
|
||||
}
|
||||
|
||||
const char *ui_companion_driver_get_ident(void)
|
||||
{
|
||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||
const ui_companion_driver_t *ui = uico_st->drv;
|
||||
if (ui)
|
||||
return ui->ident;
|
||||
return "null";
|
||||
}
|
||||
|
||||
void ui_companion_driver_log_msg(const char *msg)
|
||||
{
|
||||
#ifdef HAVE_QT
|
||||
uico_driver_state_t *uico_st= &uico_driver_st;
|
||||
bool window_is_active = uico_st->qt_data && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)
|
||||
&& ui_companion_qt.is_active(uico_st->qt_data);
|
||||
if (config_get_ptr()->bools.desktop_menu_enable)
|
||||
if (window_is_active)
|
||||
ui_companion_qt.log_msg(uico_st->qt_data, msg);
|
||||
#endif
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ void rarch_log_file_init(
|
||||
char log_file_path[PATH_MAX_LENGTH];
|
||||
verbosity_state_t *g_verbosity = &main_verbosity_st;
|
||||
static bool log_file_created = false;
|
||||
static char timestamped_log_file_name[64];
|
||||
static char timestamped_log_file_name[64] = {0};
|
||||
bool logging_to_file = g_verbosity->initialized;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user