mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 00:32:49 +00:00
Create location_driver_ctl
This commit is contained in:
parent
a766d1c1c1
commit
ade194b1cc
6
driver.c
6
driver.c
@ -369,7 +369,7 @@ void init_drivers(int flags)
|
||||
if (flags & DRIVER_CAMERA)
|
||||
camera_driver_ctl(RARCH_CAMERA_CTL_UNSET_OWN_DRIVER, NULL);
|
||||
if (flags & DRIVER_LOCATION)
|
||||
driver->location_data_own = false;
|
||||
location_driver_ctl(RARCH_LOCATION_CTL_UNSET_OWN_DRIVER, NULL);
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
/* By default, we want the menu to persist through driver reinits. */
|
||||
@ -403,7 +403,7 @@ void init_drivers(int flags)
|
||||
init_camera();
|
||||
|
||||
/* Only initialize location driver if we're ever going to use it. */
|
||||
if ((flags & DRIVER_LOCATION) && driver->location_active)
|
||||
if ((flags & DRIVER_LOCATION) && location_driver_ctl(RARCH_LOCATION_CTL_IS_ACTIVE, NULL))
|
||||
init_location();
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
@ -446,7 +446,7 @@ void uninit_drivers(int flags)
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((flags & DRIVER_LOCATION) && !driver->location_data_own)
|
||||
if ((flags & DRIVER_LOCATION) && !location_driver_ctl(RARCH_LOCATION_CTL_OWNS_DRIVER, NULL))
|
||||
{
|
||||
uninit_location();
|
||||
driver->location_data = NULL;
|
||||
|
2
driver.h
2
driver.h
@ -189,8 +189,6 @@ typedef struct driver
|
||||
|
||||
const location_driver_t *location;
|
||||
void *location_data;
|
||||
bool location_active;
|
||||
bool location_data_own;
|
||||
|
||||
const record_driver_t *recording;
|
||||
void *recording_data;
|
||||
|
@ -509,8 +509,6 @@ void init_libretro_sym(enum rarch_core_type type)
|
||||
**/
|
||||
void uninit_libretro_sym(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
if (lib_handle)
|
||||
dylib_close(lib_handle);
|
||||
@ -546,7 +544,7 @@ void uninit_libretro_sym(void)
|
||||
rarch_system_info_free();
|
||||
|
||||
camera_driver_ctl(RARCH_CAMERA_CTL_UNSET_ACTIVE, NULL);
|
||||
driver->location_active = false;
|
||||
location_driver_ctl(RARCH_LOCATION_CTL_UNSET_ACTIVE, NULL);
|
||||
|
||||
/* Performance counters no longer valid. */
|
||||
retro_perf_clear();
|
||||
@ -1140,7 +1138,8 @@ bool rarch_environment_cb(unsigned cmd, void *data)
|
||||
cb->get_position = driver_location_get_position;
|
||||
cb->set_interval = driver_location_set_interval;
|
||||
system->location_callback = *cb;
|
||||
driver->location_active = true;
|
||||
|
||||
location_driver_ctl(RARCH_LOCATION_CTL_UNSET_ACTIVE, NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ void init_location(void)
|
||||
if (!driver->location_data)
|
||||
{
|
||||
RARCH_ERR("Failed to initialize location driver. Will continue without location.\n");
|
||||
driver->location_active = false;
|
||||
location_driver_ctl(RARCH_LOCATION_CTL_UNSET_ACTIVE, NULL);
|
||||
}
|
||||
|
||||
if (system->location_callback.initialized)
|
||||
@ -226,3 +226,33 @@ void uninit_location(void)
|
||||
}
|
||||
driver->location_data = NULL;
|
||||
}
|
||||
|
||||
bool location_driver_ctl(enum rarch_location_ctl_state state, void *data)
|
||||
{
|
||||
static bool location_driver_active = false;
|
||||
static bool location_driver_data_own = false;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case RARCH_LOCATION_CTL_SET_OWN_DRIVER:
|
||||
location_driver_data_own = true;
|
||||
break;
|
||||
case RARCH_LOCATION_CTL_UNSET_OWN_DRIVER:
|
||||
location_driver_data_own = false;
|
||||
break;
|
||||
case RARCH_LOCATION_CTL_OWNS_DRIVER:
|
||||
return location_driver_data_own;
|
||||
case RARCH_LOCATION_CTL_SET_ACTIVE:
|
||||
location_driver_active = true;
|
||||
break;
|
||||
case RARCH_LOCATION_CTL_UNSET_ACTIVE:
|
||||
location_driver_active = false;
|
||||
break;
|
||||
case RARCH_LOCATION_CTL_IS_ACTIVE:
|
||||
return location_driver_active;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -25,6 +25,17 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum rarch_location_ctl_state
|
||||
{
|
||||
RARCH_LOCATION_CTL_NONE = 0,
|
||||
RARCH_LOCATION_CTL_SET_OWN_DRIVER,
|
||||
RARCH_LOCATION_CTL_UNSET_OWN_DRIVER,
|
||||
RARCH_LOCATION_CTL_OWNS_DRIVER,
|
||||
RARCH_LOCATION_CTL_SET_ACTIVE,
|
||||
RARCH_LOCATION_CTL_UNSET_ACTIVE,
|
||||
RARCH_LOCATION_CTL_IS_ACTIVE
|
||||
};
|
||||
|
||||
typedef struct location_driver
|
||||
{
|
||||
void *(*init)(void);
|
||||
@ -126,6 +137,8 @@ void init_location(void);
|
||||
|
||||
void uninit_location(void);
|
||||
|
||||
bool location_driver_ctl(enum rarch_location_ctl_state state, void *data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user