diff --git a/apple/RetroArch_OSX.xcodeproj/project.pbxproj b/apple/RetroArch_OSX.xcodeproj/project.pbxproj index c4f9871129..fe5d65ddc4 100644 --- a/apple/RetroArch_OSX.xcodeproj/project.pbxproj +++ b/apple/RetroArch_OSX.xcodeproj/project.pbxproj @@ -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", diff --git a/apple/RetroArch_iOS.xcodeproj/project.pbxproj b/apple/RetroArch_iOS.xcodeproj/project.pbxproj index dafa5e7895..ffbf978263 100644 --- a/apple/RetroArch_iOS.xcodeproj/project.pbxproj +++ b/apple/RetroArch_iOS.xcodeproj/project.pbxproj @@ -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", diff --git a/apple/common/RAGameView.m b/apple/common/RAGameView.m index a14ecb7c9e..dd8fe0506e 100644 --- a/apple/common/RAGameView.m +++ b/apple/common/RAGameView.m @@ -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 \ No newline at end of file diff --git a/driver.c b/driver.c index c432d18619..7bed8088ac 100644 --- a/driver.c +++ b/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();