Skip to content

Commit

Permalink
Revert "(pt. 2) static variables are initialized to '0' automatically…
Browse files Browse the repository at this point in the history
… as per C rules"

This reverts commit 47410df.
  • Loading branch information
LibretroAdmin committed Nov 19, 2024
1 parent 47410df commit 82e4504
Show file tree
Hide file tree
Showing 21 changed files with 909 additions and 910 deletions.
412 changes: 206 additions & 206 deletions bluetooth/bluetooth_driver.c

Large diffs are not rendered by default.

292 changes: 146 additions & 146 deletions camera/camera_driver.c
Original file line number Diff line number Diff line change
@@ -1,146 +1,146 @@
/* 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>

#include <libretro.h>

#include "../configuration.h"
#include "../driver.h"
#include "../list_special.h"
#include "../runloop.h"
#include "../verbosity.h"

#include "camera_driver.h"

static void *nullcamera_init(const char *device, uint64_t caps,
unsigned width, unsigned height) { return (void*)-1; }
static void nullcamera_free(void *data) { }
static void nullcamera_stop(void *data) { }
static bool nullcamera_start(void *data) { return true; }
static bool nullcamera_poll(void *a,
retro_camera_frame_raw_framebuffer_t b,
retro_camera_frame_opengl_texture_t c) { return true; }

static camera_driver_t camera_null = {
nullcamera_init,
nullcamera_free,
nullcamera_start,
nullcamera_stop,
nullcamera_poll,
"null",
};

const camera_driver_t *camera_drivers[] = {
#ifdef HAVE_V4L2
&camera_v4l2,
#endif
#ifdef EMSCRIPTEN
&camera_rwebcam,
#endif
#ifdef ANDROID
&camera_android,
#endif
&camera_null,
NULL,
};

static camera_driver_state_t camera_driver_st;

camera_driver_state_t *camera_state_get_ptr(void)
{
return &camera_driver_st;
}

/**
* config_get_camera_driver_options:
*
* Get an enumerated list of all camera driver names,
* separated by '|'.
*
* Returns: string listing of all camera driver names,
* separated by '|'.
**/
const char *config_get_camera_driver_options(void)
{
return char_list_new_special(STRING_LIST_CAMERA_DRIVERS, NULL);
}

bool driver_camera_start(void)
{
camera_driver_state_t *camera_st = &camera_driver_st;
if ( camera_st
&& camera_st->data
&& camera_st->driver
&& camera_st->driver->start)
{
settings_t *settings = config_get_ptr();
bool camera_allow = settings->bools.camera_allow;
if (camera_allow)
return camera_st->driver->start(camera_st->data);

runloop_msg_queue_push(
"Camera is explicitly disabled.\n", 1, 180, false,
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
return true;
}

void driver_camera_stop(void)
{
camera_driver_state_t *camera_st = &camera_driver_st;
if ( camera_st->driver
&& camera_st->driver->stop
&& camera_st->data)
camera_st->driver->stop(camera_st->data);
}

bool camera_driver_find_driver(const char *prefix,
bool verbosity_enabled)
{
settings_t *settings = config_get_ptr();
camera_driver_state_t
*camera_st = &camera_driver_st;
int i = (int)driver_find_index(
"camera_driver",
settings->arrays.camera_driver);

if (i >= 0)
camera_st->driver = (const camera_driver_t*)camera_drivers[i];
else
{
if (verbosity_enabled)
{
unsigned d;
RARCH_ERR("Couldn't find any %s named \"%s\"\n", prefix,
settings->arrays.camera_driver);
RARCH_LOG_OUTPUT("Available %ss are:\n", prefix);
for (d = 0; camera_drivers[d]; d++)
{
if (camera_drivers[d])
{
RARCH_LOG_OUTPUT("\t%s\n", camera_drivers[d]->ident);
}
}

RARCH_WARN("Going to default to first %s...\n", prefix);
}

if (!(camera_st->driver = (const camera_driver_t*)camera_drivers[0]))
return false;
}
return true;
}
/* 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>

#include <libretro.h>

#include "../configuration.h"
#include "../driver.h"
#include "../list_special.h"
#include "../runloop.h"
#include "../verbosity.h"

#include "camera_driver.h"

static void *nullcamera_init(const char *device, uint64_t caps,
unsigned width, unsigned height) { return (void*)-1; }
static void nullcamera_free(void *data) { }
static void nullcamera_stop(void *data) { }
static bool nullcamera_start(void *data) { return true; }
static bool nullcamera_poll(void *a,
retro_camera_frame_raw_framebuffer_t b,
retro_camera_frame_opengl_texture_t c) { return true; }

static camera_driver_t camera_null = {
nullcamera_init,
nullcamera_free,
nullcamera_start,
nullcamera_stop,
nullcamera_poll,
"null",
};

const camera_driver_t *camera_drivers[] = {
#ifdef HAVE_V4L2
&camera_v4l2,
#endif
#ifdef EMSCRIPTEN
&camera_rwebcam,
#endif
#ifdef ANDROID
&camera_android,
#endif
&camera_null,
NULL,
};

static camera_driver_state_t camera_driver_st = {0};

camera_driver_state_t *camera_state_get_ptr(void)
{
return &camera_driver_st;
}

/**
* config_get_camera_driver_options:
*
* Get an enumerated list of all camera driver names,
* separated by '|'.
*
* Returns: string listing of all camera driver names,
* separated by '|'.
**/
const char *config_get_camera_driver_options(void)
{
return char_list_new_special(STRING_LIST_CAMERA_DRIVERS, NULL);
}

bool driver_camera_start(void)
{
camera_driver_state_t *camera_st = &camera_driver_st;
if ( camera_st
&& camera_st->data
&& camera_st->driver
&& camera_st->driver->start)
{
settings_t *settings = config_get_ptr();
bool camera_allow = settings->bools.camera_allow;
if (camera_allow)
return camera_st->driver->start(camera_st->data);

runloop_msg_queue_push(
"Camera is explicitly disabled.\n", 1, 180, false,
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
return true;
}

void driver_camera_stop(void)
{
camera_driver_state_t *camera_st = &camera_driver_st;
if ( camera_st->driver
&& camera_st->driver->stop
&& camera_st->data)
camera_st->driver->stop(camera_st->data);
}

bool camera_driver_find_driver(const char *prefix,
bool verbosity_enabled)
{
settings_t *settings = config_get_ptr();
camera_driver_state_t
*camera_st = &camera_driver_st;
int i = (int)driver_find_index(
"camera_driver",
settings->arrays.camera_driver);

if (i >= 0)
camera_st->driver = (const camera_driver_t*)camera_drivers[i];
else
{
if (verbosity_enabled)
{
unsigned d;
RARCH_ERR("Couldn't find any %s named \"%s\"\n", prefix,
settings->arrays.camera_driver);
RARCH_LOG_OUTPUT("Available %ss are:\n", prefix);
for (d = 0; camera_drivers[d]; d++)
{
if (camera_drivers[d])
{
RARCH_LOG_OUTPUT("\t%s\n", camera_drivers[d]->ident);
}
}

RARCH_WARN("Going to default to first %s...\n", prefix);
}

if (!(camera_st->driver = (const camera_driver_t*)camera_drivers[0]))
return false;
}
return true;
}
14 changes: 7 additions & 7 deletions cores/libretro-net-retropad/net_retropad_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ struct remote_joypad_message
uint16_t state;
};

static float tilt_sensor_values[3];
static float gyro_sensor_values[3];
static bool keyboard_state[RETROK_LAST];
static bool keyboard_state_validated[RETROK_LAST];
static bool tilt_sensor_enabled = false;
static bool gyro_sensor_enabled = false;
static bool lux_sensor_enabled = false;
static float tilt_sensor_values[3] = {0};
static float gyro_sensor_values[3] = {0};
static float lux_sensor_value = 0.0f;
static unsigned mouse_type = 0;
static int pointer_x = 0;
Expand Down Expand Up @@ -727,7 +727,7 @@ static void retropad_update_input(void)
pointer_y = (int16_t)state;
}
}

/* Do not send extra descriptor state - RA side is not prepared to receive it */
if (i>1)
continue;
Expand Down Expand Up @@ -1034,7 +1034,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
sensor_item_colors[median_index] = (uint16_t)(fabsf(32*4*value)) << 11;
}
}

/* Button values for sensor test screen, since they do not follow any pattern, it is *
* provided as a direct list. */
if (mouse_type == NETRETROPAD_MOUSE)
Expand All @@ -1061,7 +1061,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)

offset = DESC_OFFSET(&mouse, 0, 0, RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP);
sensor_item_colors[86] = mouse.value[offset] ? 0xA000 : 0x0000;

offset = DESC_OFFSET(&mouse, 0, 0, RETRO_DEVICE_ID_MOUSE_BUTTON_4);
sensor_item_colors[88] = mouse.value[offset] ? 0xA000 : 0x0000;

Expand Down Expand Up @@ -1093,7 +1093,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)

offset = DESC_OFFSET(&lightgun, 0, 0, RETRO_DEVICE_ID_LIGHTGUN_SELECT);
sensor_item_colors[76] = lightgun.value[offset] ? 0xA000 : 0x0000;

offset = DESC_OFFSET(&lightgun, 0, 0, RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN);
sensor_item_colors[77] = lightgun.value[offset] ? 0xA000 : 0x0000;

Expand Down Expand Up @@ -1386,7 +1386,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
pointer_prev_y = pointer_y_coord;
}
}

NETRETROPAD_CORE_PREFIX(video_cb)(frame_buf, 320, 240, 640);
retro_sleep(4);
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/drivers/platform_darwin.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@
} CFDomainMask;

#if (defined(OSX) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101200))
static int speak_pid = 0;
static int speak_pid = 0;
#endif

static char darwin_cpu_model_name[64];
static char darwin_cpu_model_name[64] = {0};

static void CFSearchPathForDirectoriesInDomains(
char *s, size_t len)
Expand Down
4 changes: 2 additions & 2 deletions frontend/drivers/platform_orbis.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
#define MODULE_PATH "/data/self/system/common/lib/"
#define MODULE_PATH_EXT "/app0/sce_module/"

static char eboot_path[512];
static char eboot_path[512] = {0};
SceKernelModule s_piglet_module;
SceKernelModule s_shacc_module;

Expand Down Expand Up @@ -160,7 +160,7 @@ static void frontend_orbis_get_env(int *argc, char *argv[],

if (!string_is_empty(argv[CONTENT_PATH_ARG_INDEX]))
{
static char path[PATH_MAX_LENGTH];
static char path[PATH_MAX_LENGTH] = {0};
struct rarch_main_wrap *args =
(struct rarch_main_wrap*)params_data;

Expand Down
Loading

0 comments on commit 82e4504

Please sign in to comment.