Add location/null.c - get rid of HAVE_LOCATION ifdefs

This commit is contained in:
twinaphex 2014-08-14 02:15:48 +02:00
parent 12c0311f04
commit 027bd68bb3
15 changed files with 79 additions and 64 deletions

View File

@ -44,6 +44,7 @@ OBJ = frontend/frontend.o \
audio/dsp_filter.o \
audio/sinc.o \
audio/cc_resampler.o \
location/null.o \
performance.o

View File

@ -49,6 +49,7 @@ OBJ = frontend/frontend.o \
audio/dsp_filter.o \
audio/sinc.o \
audio/cc_resampler.o \
location/null.o \
performance.o
JOBJ := conf/config_file.o \

View File

@ -54,7 +54,7 @@ else
GLES_LIB := -lGLESv2
endif
LOCAL_CFLAGS += -Wall -pthread -Wno-unused-function -fno-stack-protector -funroll-loops -DNDEBUG -DRARCH_MOBILE -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_DYLIB -DHAVE_GLSL -DHAVE_MENU -DHAVE_RGUI -DHAVE_ZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREADS -D__LIBRETRO__ -DHAVE_RSOUND -DHAVE_NETPLAY -DHAVE_CAMERA -DRARCH_INTERNAL -DHAVE_LOCATION -DHAVE_CC_RESAMPLER -DHAVE_FILTERS_BUILTIN
LOCAL_CFLAGS += -Wall -pthread -Wno-unused-function -fno-stack-protector -funroll-loops -DNDEBUG -DRARCH_MOBILE -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_DYLIB -DHAVE_GLSL -DHAVE_MENU -DHAVE_RGUI -DHAVE_ZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREADS -D__LIBRETRO__ -DHAVE_RSOUND -DHAVE_NETPLAY -DHAVE_CAMERA -DRARCH_INTERNAL -DHAVE_CC_RESAMPLER -DHAVE_FILTERS_BUILTIN
LOCAL_CFLAGS += -O2

View File

@ -96,6 +96,7 @@ enum
LOCATION_ANDROID,
LOCATION_APPLE,
LOCATION_NULL,
OSK_PS3,
OSK_NULL,
@ -230,6 +231,8 @@ enum
#define LOCATION_DEFAULT_DRIVER LOCATION_ANDROID
#elif defined(IOS) || defined(OSX)
#define LOCATION_DEFAULT_DRIVER LOCATION_APPLE
#else
#define LOCATION_DEFAULT_DRIVER LOCATION_NULL
#endif
#if defined(__CELLOS_LV2__)

View File

@ -401,7 +401,6 @@ void uninit_camera(void)
}
#endif
#ifdef HAVE_LOCATION
static const location_driver_t *location_drivers[] = {
#ifdef ANDROID
&location_android,
@ -409,6 +408,7 @@ static const location_driver_t *location_drivers[] = {
#if defined(IOS) || defined(OSX)
&location_apple,
#endif
&location_null,
NULL,
};
@ -527,7 +527,6 @@ void uninit_location(void)
}
driver.location_data = NULL;
}
#endif
#ifdef HAVE_MENU
static const menu_ctx_driver_t *menu_ctx_drivers[] = {
@ -777,9 +776,7 @@ void init_drivers_pre(void)
#ifdef HAVE_CAMERA
find_camera_driver();
#endif
#ifdef HAVE_LOCATION
find_location_driver();
#endif
#ifdef HAVE_OSK
find_osk_driver();
#endif
@ -941,9 +938,7 @@ void init_drivers(void)
#ifdef HAVE_CAMERA
driver.camera_data_own = false;
#endif
#ifdef HAVE_LOCATION
driver.location_data_own = false;
#endif
#ifdef HAVE_OSK
driver.osk_data_own = false;
#endif
@ -970,11 +965,9 @@ void init_drivers(void)
init_camera();
#endif
#ifdef HAVE_LOCATION
// Only initialize location driver if we're ever going to use it.
if (g_extern.location_active)
init_location();
#endif
#ifdef HAVE_OSK
init_osk();
@ -1073,13 +1066,11 @@ void uninit_drivers(void)
}
#endif
#ifdef HAVE_LOCATION
if (!driver.location_data_own)
{
uninit_location();
driver.location_data = NULL;
}
#endif
#ifdef HAVE_OSK
if (!driver.osk_data_own)

View File

@ -423,10 +423,8 @@ typedef struct driver
const camera_driver_t *camera;
void *camera_data;
#endif
#ifdef HAVE_LOCATION
const location_driver_t *location;
void *location_data;
#endif
void *audio_data;
void *video_data;
void *input_data;
@ -457,9 +455,7 @@ typedef struct driver
#ifdef HAVE_CAMERA
bool camera_data_own;
#endif
#ifdef HAVE_LOCATION
bool location_data_own;
#endif
#ifdef HAVE_OSK
bool osk_data_own;
#endif
@ -531,12 +527,10 @@ void find_prev_camera_driver(void);
void find_next_camera_driver(void);
#endif
#ifdef HAVE_LOCATION
void init_location(void);
void uninit_location(void);
void find_prev_location_driver(void);
void find_next_location_driver(void);
#endif
void driver_set_monitor_refresh_rate(float hz);
bool driver_monitor_fps_statistics(double *refresh_rate, double *deviation, unsigned *sample_points);
@ -571,12 +565,10 @@ void driver_camera_poll(void);
#endif
// Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE
#ifdef HAVE_LOCATION
bool driver_location_start(void);
void driver_location_stop(void);
bool driver_location_get_position(double *lat, double *lon, double *horiz_accuracy, double *vert_accuracy);
void driver_location_set_interval(unsigned interval_msecs, unsigned interval_distance);
#endif
#ifdef HAVE_MENU
const void *menu_ctx_find_driver(const char *ident); // Finds driver with ident. Does not initialize.
@ -646,6 +638,7 @@ extern const camera_driver_t camera_rwebcam;
extern const camera_driver_t camera_ios;
extern const location_driver_t location_apple;
extern const location_driver_t location_android;
extern const location_driver_t location_null;
extern const input_osk_driver_t input_ps3_osk;
extern const menu_ctx_driver_t menu_ctx_rmenu;

View File

@ -382,9 +382,7 @@ void uninit_libretro_sym(void)
#ifdef HAVE_CAMERA
g_extern.camera_active = false;
#endif
#ifdef HAVE_LOCATION
g_extern.location_active = false;
#endif
// Performance counters no longer valid.
retro_perf_clear();
@ -834,7 +832,6 @@ bool rarch_environment_cb(unsigned cmd, void *data)
break;
}
#endif
#ifdef HAVE_LOCATION
case RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE:
{
RARCH_LOG("Environ GET_LOCATION_INTERFACE.\n");
@ -847,7 +844,6 @@ bool rarch_environment_cb(unsigned cmd, void *data)
g_extern.location_active = true;
break;
}
#endif
case RETRO_ENVIRONMENT_GET_LOG_INTERFACE:
{

View File

@ -315,9 +315,7 @@ static void menu_common_entries_init(menu_handle_t *menu, unsigned menu_type)
#ifdef HAVE_CAMERA
file_list_push(menu->selection_buf, "", "camera_allow", MENU_SETTINGS_PRIVACY_CAMERA_ALLOW, 0);
#endif
#ifdef HAVE_LOCATION
file_list_push(menu->selection_buf, "", "location_allow", MENU_SETTINGS_PRIVACY_LOCATION_ALLOW, 0);
#endif
break;
case MENU_SETTINGS_DISK_OPTIONS:
file_list_clear(menu->selection_buf);
@ -413,9 +411,7 @@ static void menu_common_entries_init(menu_handle_t *menu, unsigned menu_type)
#ifdef HAVE_CAMERA
file_list_push(menu->selection_buf, "Camera Driver", "", MENU_SETTINGS_DRIVER_CAMERA, 0);
#endif
#ifdef HAVE_LOCATION
file_list_push(menu->selection_buf, "Location Driver", "", MENU_SETTINGS_DRIVER_LOCATION, 0);
#endif
#ifdef HAVE_MENU
file_list_push(menu->selection_buf, "Menu Driver", "", MENU_SETTINGS_DRIVER_MENU, 0);
#endif
@ -3803,14 +3799,12 @@ static int menu_common_setting_set(unsigned id, unsigned action, rarch_setting_t
find_next_camera_driver();
break;
#endif
#ifdef HAVE_LOCATION
case MENU_SETTINGS_DRIVER_LOCATION:
if (action == MENU_ACTION_LEFT)
find_prev_location_driver();
else if (action == MENU_ACTION_RIGHT)
find_next_location_driver();
break;
#endif
#ifdef HAVE_MENU
case MENU_SETTINGS_DRIVER_MENU:
if (action == MENU_ACTION_LEFT)
@ -4257,11 +4251,9 @@ static void menu_common_setting_set_label(char *type_str, size_t type_str_size,
strlcpy(type_str, g_settings.camera.driver, type_str_size);
break;
#endif
#ifdef HAVE_LOCATION
case MENU_SETTINGS_DRIVER_LOCATION:
strlcpy(type_str, g_settings.location.driver, type_str_size);
break;
#endif
#ifdef HAVE_MENU
case MENU_SETTINGS_DRIVER_MENU:
strlcpy(type_str, g_settings.menu.driver, type_str_size);
@ -4676,11 +4668,9 @@ static void menu_common_setting_set_label(char *type_str, size_t type_str_size,
snprintf(type_str, type_str_size, g_settings.camera.allow ? "ON" : "OFF");
break;
#endif
#ifdef HAVE_LOCATION
case MENU_SETTINGS_PRIVACY_LOCATION_ALLOW:
snprintf(type_str, type_str_size, g_settings.location.allow ? "ON" : "OFF");
break;
#endif
#ifdef HAVE_OSK
case MENU_SETTINGS_ONSCREEN_KEYBOARD_ENABLE:
snprintf(type_str, type_str_size, g_settings.osk.enable ? "ON" : "OFF");

View File

@ -257,7 +257,6 @@ struct settings
} camera;
#endif
#ifdef HAVE_LOCATION
struct
{
char driver[32];
@ -265,7 +264,6 @@ struct settings
int update_interval_ms;
int update_interval_distance;
} location;
#endif
#ifdef HAVE_OSK
struct
@ -406,9 +404,7 @@ struct global
#ifdef HAVE_CAMERA
bool camera_active;
#endif
#ifdef HAVE_LOCATION
bool location_active;
#endif
#ifdef HAVE_OSK
bool osk_active;
#endif
@ -757,9 +753,7 @@ void config_set_defaults(void);
#ifdef HAVE_CAMERA
const char *config_get_default_camera(void);
#endif
#ifdef HAVE_LOCATION
const char *config_get_default_location(void);
#endif
#ifdef HAVE_OSK
const char *config_get_default_osk(void);
#endif

View File

@ -383,13 +383,11 @@ CAMERA
/*============================================================
LOCATION
============================================================ */
#ifdef HAVE_LOCATION
#if defined(ANDROID)
#include "../location/android.c"
#endif
#endif
#include "../location/null.c"
/*============================================================
RSOUND

62
location/null.c Normal file
View File

@ -0,0 +1,62 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2014 - 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 "../driver.h"
typedef struct null_location
{
} nulllocation_t;
static void *null_location_init(void)
{
return NULL;
}
static void null_location_free(void *data)
{
(void)data;
}
static bool null_location_start(void *data)
{
(void)data;
return true;
}
static void null_location_stop(void *data)
{
(void)data;
}
static bool null_location_get_position(void *data, double *latitude, double *longitude, double *horiz_accuracy,
double *vert_accuracy)
{
return true;
}
static void null_location_set_interval(void *data, unsigned interval_ms, unsigned interval_distance)
{
}
const location_driver_t location_null = {
null_location_init,
null_location_free,
null_location_start,
null_location_stop,
null_location_get_position,
null_location_set_interval,
"null",
};

View File

@ -319,6 +319,8 @@
</ClCompile>
<ClCompile Include="..\..\retroarch.c">
</ClCompile>
<ClCompile Include="..\..\location\null.c">
</ClCompile>
<ClCompile Include="..\..\rewind.c">
</ClCompile>
<ClCompile Include="..\..\screenshot.c">

View File

@ -22,6 +22,7 @@
<ClCompile Include="..\..\netplay.c" />
<ClCompile Include="..\..\patch.c" />
<ClCompile Include="..\..\retroarch.c" />
<ClCompile Include="..\..\location\null.c" />
<ClCompile Include="..\..\rewind.c" />
<ClCompile Include="..\..\screenshot.c" />
<ClCompile Include="..\..\settings.c" />
@ -321,4 +322,4 @@
<UniqueIdentifier>{4a5338d9-92ad-4d07-bb1a-97bd6eb475e4}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
</Project>

View File

@ -212,19 +212,18 @@ const char *config_get_default_camera(void)
return "video4linux2";
case CAMERA_RWEBCAM:
return "rwebcam";
case CAMERA_NULL:
return "null";
case CAMERA_ANDROID:
return "android";
case CAMERA_IOS:
return "ios";
case CAMERA_NULL:
return "null";
default:
return NULL;
}
}
#endif
#ifdef HAVE_LOCATION
const char *config_get_default_location(void)
{
switch (LOCATION_DEFAULT_DRIVER)
@ -233,11 +232,12 @@ const char *config_get_default_location(void)
return "android";
case LOCATION_APPLE:
return "apple";
case LOCATION_NULL:
return "null";
default:
return NULL;
}
}
#endif
void config_set_defaults(void)
{
@ -256,12 +256,10 @@ void config_set_defaults(void)
strlcpy(g_settings.camera.driver, def_camera, sizeof(g_settings.camera.driver));
#endif
#ifdef HAVE_LOCATION
const char *def_location = config_get_default_location();
if (def_location)
strlcpy(g_settings.location.driver, def_location, sizeof(g_settings.location.driver));
#endif
#ifdef HAVE_OSK
const char *def_osk = config_get_default_osk();
@ -374,9 +372,7 @@ void config_set_defaults(void)
g_settings.menu_show_start_screen = menu_show_start_screen;
#endif
#ifdef HAVE_LOCATION
g_settings.location.allow = false;
#endif
#ifdef HAVE_CAMERA
g_settings.camera.allow = false;
@ -984,10 +980,7 @@ bool config_load_file(const char *path, bool set_defaults)
CONFIG_GET_BOOL(camera.allow, "camera_allow");
#endif
#ifdef HAVE_LOCATION
CONFIG_GET_BOOL(location.allow, "location_allow");
#endif
CONFIG_GET_STRING(video.driver, "video_driver");
CONFIG_GET_STRING(menu.driver, "menu_driver");
CONFIG_GET_STRING(video.gl_context, "video_gl_context");
@ -1406,9 +1399,7 @@ bool config_save_file(const char *path)
config_set_bool(conf, "audio_enable", g_settings.audio.enable);
config_set_int(conf, "audio_out_rate", g_settings.audio.out_rate);
#ifdef HAVE_LOCATION
config_set_bool(conf, "location_allow", g_settings.location.allow);
#endif
config_set_float(conf, "video_font_size", g_settings.video.font_size);
config_set_bool(conf, "video_font_enable", g_settings.video.font_enable);

View File

@ -1001,10 +1001,8 @@ static void general_read_handler(const void *data)
else if (!strcmp(setting->name, "camera_allow"))
*setting->value.boolean = g_settings.camera.allow;
#endif
#ifdef HAVE_LOCATION
else if (!strcmp(setting->name, "location_allow"))
*setting->value.boolean = g_settings.location.allow;
#endif
else if (!strcmp(setting->name, "video_shared_context"))
*setting->value.boolean = g_settings.video.shared_context;
#ifdef HAVE_NETPLAY
@ -1334,10 +1332,8 @@ static void general_write_handler(const void *data)
else if (!strcmp(setting->name, "camera_allow"))
g_settings.camera.allow = *setting->value.boolean;
#endif
#ifdef HAVE_LOCATION
else if (!strcmp(setting->name, "location_allow"))
g_settings.location.allow = *setting->value.boolean;
#endif
else if (!strcmp(setting->name, "video_shared_context"))
g_settings.video.shared_context = *setting->value.boolean;
#ifdef HAVE_NETPLAY
@ -1460,9 +1456,7 @@ rarch_setting_t* setting_data_get_list(void)
#ifdef HAVE_CAMERA
CONFIG_STRING(g_settings.camera.device, "camera_device", "Camera Driver", config_get_default_camera(), GROUP_NAME, SUBGROUP_NAME, NULL, NULL)
#endif
#ifdef HAVE_LOCATION
CONFIG_STRING(g_settings.location.driver, "location_driver", "Location Driver", config_get_default_location(), GROUP_NAME, SUBGROUP_NAME, NULL, NULL)
#endif
CONFIG_STRING(g_settings.input.joypad_driver, "input_joypad_driver", "Joypad Driver", "", GROUP_NAME, SUBGROUP_NAME, NULL, NULL)
CONFIG_STRING(g_settings.input.keyboard_layout, "input_keyboard_layout", "Keyboard Layout", "", GROUP_NAME, SUBGROUP_NAME, NULL, NULL)
@ -1764,9 +1758,7 @@ rarch_setting_t* setting_data_get_list(void)
#ifdef HAVE_CAMERA
CONFIG_BOOL(g_settings.camera.allow, "camera_allow", "Allow Camera", false, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
#endif
#ifdef HAVE_LOCATION
CONFIG_BOOL(g_settings.location.allow, "location_allow", "Allow Location", false, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
#endif
END_SUB_GROUP()
END_GROUP()
}