mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-24 12:15:08 +00:00
(Apple) Implement HAVE_LOCATION for OSX/iOS
This commit is contained in:
parent
1659adbfe9
commit
5f33a6b373
@ -301,6 +301,7 @@
|
||||
OTHER_CFLAGS = (
|
||||
"-DHAVE_RARCH_MAIN_WRAP",
|
||||
"-DHAVE_GRIFFIN",
|
||||
"-DHAVE_LOCATION",
|
||||
"-DHAVE_RGUI",
|
||||
"-DHAVE_MENU",
|
||||
"-DOSX",
|
||||
@ -356,6 +357,7 @@
|
||||
"-DNDEBUG",
|
||||
"-DHAVE_RARCH_MAIN_WRAP",
|
||||
"-DHAVE_GRIFFIN",
|
||||
"-DHAVE_LOCATION",
|
||||
"-DHAVE_RGUI",
|
||||
"-DHAVE_MENU",
|
||||
"-DOSX",
|
||||
|
@ -357,6 +357,7 @@
|
||||
OTHER_CFLAGS = (
|
||||
"-DHAVE_CAMERA",
|
||||
"-DHAVE_GRIFFIN",
|
||||
"-DHAVE_LOCATION",
|
||||
"-DHAVE_RGUI",
|
||||
"-DHAVE_MENU",
|
||||
"-DIOS",
|
||||
@ -408,6 +409,7 @@
|
||||
"-DNDEBUG",
|
||||
"-DHAVE_CAMERA",
|
||||
"-DHAVE_GRIFFIN",
|
||||
"-DHAVE_LOCATION",
|
||||
"-DHAVE_RGUI",
|
||||
"-DHAVE_MENU",
|
||||
"-DIOS",
|
||||
@ -453,6 +455,7 @@
|
||||
"-DHAVE_RARCH_MAIN_WRAP",
|
||||
"-DHAVE_CAMERA",
|
||||
"-DHAVE_GRIFFIN",
|
||||
"-DHAVE_LOCATION",
|
||||
"-DHAVE_RGUI",
|
||||
"-DHAVE_MENU",
|
||||
"-DIOS",
|
||||
@ -498,6 +501,7 @@
|
||||
"-DHAVE_RARCH_MAIN_WRAP",
|
||||
"-DHAVE_CAMERA",
|
||||
"-DHAVE_GRIFFIN",
|
||||
"-DHAVE_LOCATION",
|
||||
"-DHAVE_RGUI",
|
||||
"-DHAVE_MENU",
|
||||
"-DIOS",
|
||||
|
@ -314,7 +314,7 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)onLocationInit
|
||||
- (void)onLocationInit:(int)interval_update_ms interval_update_distance:(int)interval_distance
|
||||
{
|
||||
// Create the location manager if this object does not
|
||||
// already have one.
|
||||
@ -343,17 +343,16 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||
/* TODO - free location manager? */
|
||||
}
|
||||
|
||||
- (float)onLocationGetLatitude
|
||||
- (double)onLocationGetLatitude
|
||||
{
|
||||
return (float)currentLatitude;
|
||||
return currentLatitude;
|
||||
}
|
||||
|
||||
- (float)onLocationGetLongitude
|
||||
- (double)onLocationGetLongitude
|
||||
{
|
||||
return (float)currentLongitude;
|
||||
return currentLongitude;
|
||||
}
|
||||
|
||||
|
||||
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
|
||||
{
|
||||
currentLatitude = newLocation.coordinate.latitude;
|
||||
@ -605,10 +604,6 @@ void apple_bind_game_view_fbo(void)
|
||||
});
|
||||
}
|
||||
|
||||
// References:
|
||||
// http://allmybrain.com/2011/12/08/rendering-to-a-texture-with-ios-5-texture-cache-api/
|
||||
// https://developer.apple.com/library/iOS/samplecode/GLCameraRipple/
|
||||
|
||||
typedef struct ios_camera
|
||||
{
|
||||
void *empty;
|
||||
@ -688,3 +683,72 @@ const camera_driver_t camera_ios = {
|
||||
"ios",
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LOCATION
|
||||
typedef struct apple_location
|
||||
{
|
||||
void *empty;
|
||||
} applelocation_t;
|
||||
|
||||
static void *apple_location_init(int interval_update_ms, int interval_distance)
|
||||
{
|
||||
applelocation_t *applelocation = (applelocation_t*)calloc(1, sizeof(applelocation_t));
|
||||
if (!applelocation)
|
||||
return NULL;
|
||||
|
||||
[[RAGameView get] onLocationInit:interval_update_ms interval_update_distance:interval_distance];
|
||||
|
||||
return applelocation;
|
||||
}
|
||||
|
||||
static void apple_location_free(void *data)
|
||||
{
|
||||
applelocation_t *applelocation = (applelocation_t*)data;
|
||||
|
||||
[[RAGameView get] onLocationFree];
|
||||
|
||||
if (applelocation)
|
||||
free(applelocation);
|
||||
applelocation = NULL;
|
||||
}
|
||||
|
||||
static bool apple_location_start(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
[[RAGameView get] onLocationStart];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void apple_location_stop(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
[[RAGameView get] onLocationStop];
|
||||
}
|
||||
|
||||
static double apple_location_get_latitude(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
return [[RAGameView get] onLocationGetLatitude];
|
||||
}
|
||||
|
||||
static double apple_location_get_longitude(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
return [[RAGameView get] onLocationGetLongitude];
|
||||
}
|
||||
|
||||
const location_driver_t location_apple = {
|
||||
apple_location_init,
|
||||
apple_location_free,
|
||||
apple_location_start,
|
||||
apple_location_stop,
|
||||
apple_location_get_longitude,
|
||||
apple_location_get_latitude,
|
||||
"apple",
|
||||
};
|
||||
#endif
|
4
driver.c
4
driver.c
@ -706,7 +706,7 @@ void global_uninit_drivers(void)
|
||||
#ifdef HAVE_LOCATION
|
||||
if (driver.location && driver.location_data)
|
||||
{
|
||||
driver.location->free(driver.camera_data);
|
||||
driver.location->free(driver.location_data);
|
||||
driver.location_data = NULL;
|
||||
}
|
||||
#endif
|
||||
@ -750,7 +750,7 @@ void init_camera(void)
|
||||
void init_location(void)
|
||||
{
|
||||
// Resource leaks will follow if location interface is initialized twice.
|
||||
if (driver.camera_data)
|
||||
if (driver.location_data)
|
||||
return;
|
||||
|
||||
find_location_driver();
|
||||
|
Loading…
x
Reference in New Issue
Block a user