mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-14 22:47:44 +00:00
(Apple) Style nits
This commit is contained in:
parent
590376836a
commit
3296b9575c
@ -126,10 +126,15 @@ static char** waiting_argv;
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
NSArray *paths;
|
||||
NSComboBox* cb;
|
||||
const core_info_list_t* cores;
|
||||
int i;
|
||||
|
||||
apple_platform = self;
|
||||
_loaded = true;
|
||||
|
||||
NSArray* paths = (NSArray*)NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
||||
paths = (NSArray*)NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
||||
self.configDirectory = [[paths objectAtIndex:0] stringByAppendingPathComponent:BOXSTRING("RetroArch")];
|
||||
self.globalConfigFile = [NSString stringWithFormat:BOXSTRING("%@/retroarch.cfg"), self.configDirectory];
|
||||
self.coreDirectory = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:BOXSTRING("Contents/Resources/modules")];
|
||||
@ -150,13 +155,13 @@ static char** waiting_argv;
|
||||
self.settingsWindow = [[[NSWindowController alloc] initWithWindowNibName:BOXSTRING("Settings")] autorelease];
|
||||
|
||||
// Create core select list
|
||||
NSComboBox* cb = (NSComboBox*)[[self.coreSelectSheet contentView] viewWithTag:1];
|
||||
cb = (NSComboBox*)[[self.coreSelectSheet contentView] viewWithTag:1];
|
||||
|
||||
core_info_set_core_path(self.coreDirectory.UTF8String);
|
||||
core_info_set_config_path(self.configDirectory.UTF8String);
|
||||
const core_info_list_t* cores = (const core_info_list_t*)core_info_list_get();
|
||||
cores = (const core_info_list_t*)core_info_list_get();
|
||||
|
||||
for (int i = 0; cores && i < cores->count; i ++)
|
||||
for (i = 0; cores && i < cores->count; i ++)
|
||||
{
|
||||
NSString* desc = (NSString*)BOXSTRING(cores->list[i].display_name);
|
||||
#if defined(MAC_OS_X_VERSION_10_6)
|
||||
@ -266,6 +271,8 @@ static char** waiting_argv;
|
||||
|
||||
- (IBAction)coreWasChosen:(id)sender
|
||||
{
|
||||
NSComboBox* cb;
|
||||
|
||||
[[NSApplication sharedApplication] stopModal];
|
||||
[[NSApplication sharedApplication] endSheet:self.coreSelectSheet returnCode:0];
|
||||
[self.coreSelectSheet orderOut:self];
|
||||
@ -273,7 +280,7 @@ static char** waiting_argv;
|
||||
if (_isTerminating)
|
||||
return;
|
||||
|
||||
NSComboBox* cb = (NSComboBox*)[[self.coreSelectSheet contentView] viewWithTag:1];
|
||||
cb = (NSComboBox*)[[self.coreSelectSheet contentView] viewWithTag:1];
|
||||
#if defined(MAC_OS_X_VERSION_10_6)
|
||||
/* FIXME - Rewrite this so that this is no longer an associated object - requires ObjC 2.0 runtime */
|
||||
self.core = objc_getAssociatedObject(cb.objectValueOfSelectedItem, associated_core_key);
|
||||
@ -330,13 +337,16 @@ static char** waiting_argv;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
for (int i = 0; i != argc; i ++)
|
||||
int i;
|
||||
for (i = 0; i < argc; i ++)
|
||||
{
|
||||
if (strcmp(argv[i], "--") == 0)
|
||||
{
|
||||
waiting_argc = argc - i;
|
||||
waiting_argv = argv + i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NSApplicationMain(argc, (const char **) argv);
|
||||
}
|
||||
|
@ -162,9 +162,10 @@ static bool g_is_syncing = true;
|
||||
// < iOS Pause menu and lifecycle
|
||||
- (id)init
|
||||
{
|
||||
UINib *xib;
|
||||
self = [super init];
|
||||
|
||||
UINib *xib = [UINib nibWithNibName:BOXSTRING("PauseIndicatorView") bundle:nil];
|
||||
xib = (UINib*)[UINib nibWithNibName:BOXSTRING("PauseIndicatorView") bundle:nil];
|
||||
g_pause_indicator_view = [[xib instantiateWithOwner:[RetroArch_iOS get] options:nil] lastObject];
|
||||
|
||||
g_view = [GLKView new];
|
||||
@ -193,14 +194,15 @@ static bool g_is_syncing = true;
|
||||
|
||||
- (void)viewWillLayoutSubviews
|
||||
{
|
||||
float tenpctw, tenpcth, width, height;
|
||||
UIInterfaceOrientation orientation = self.interfaceOrientation;
|
||||
CGRect screenSize = [[UIScreen mainScreen] bounds];
|
||||
|
||||
const float width = ((int)orientation < 3) ? CGRectGetWidth(screenSize) : CGRectGetHeight(screenSize);
|
||||
const float height = ((int)orientation < 3) ? CGRectGetHeight(screenSize) : CGRectGetWidth(screenSize);
|
||||
width = ((int)orientation < 3) ? CGRectGetWidth(screenSize) : CGRectGetHeight(screenSize);
|
||||
height = ((int)orientation < 3) ? CGRectGetHeight(screenSize) : CGRectGetWidth(screenSize);
|
||||
|
||||
float tenpctw = width / 10.0f;
|
||||
float tenpcth = height / 10.0f;
|
||||
tenpctw = width / 10.0f;
|
||||
tenpcth = height / 10.0f;
|
||||
|
||||
g_pause_indicator_view.frame = CGRectMake(tenpctw * 4.0f, 0.0f, tenpctw * 2.0f, tenpcth);
|
||||
[g_pause_indicator_view viewWithTag:1].frame = CGRectMake(0, 0, tenpctw * 2.0f, tenpcth);
|
||||
@ -297,6 +299,10 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||
{
|
||||
CVReturn ret;
|
||||
int width, height;
|
||||
NSError *error;
|
||||
AVCaptureVideoDataOutput * dataOutput;
|
||||
AVCaptureDeviceInput *input;
|
||||
AVCaptureDevice *videoDevice;
|
||||
|
||||
//FIXME - dehardcode this
|
||||
width = 640;
|
||||
@ -320,14 +326,13 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||
[_session setSessionPreset:_sessionPreset];
|
||||
|
||||
//-- Creata a video device and input from that Device. Add the input to the capture session.
|
||||
AVCaptureDevice *videoDevice = (AVCaptureDevice*)[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
if(videoDevice == nil)
|
||||
videoDevice = (AVCaptureDevice*)[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
if (videoDevice == nil)
|
||||
assert(0);
|
||||
|
||||
//-- Add the device to the session.
|
||||
NSError *error;
|
||||
AVCaptureDeviceInput *input = (AVCaptureDeviceInput*)[AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
|
||||
if(error)
|
||||
input = (AVCaptureDeviceInput*)[AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
|
||||
if (error)
|
||||
{
|
||||
RARCH_ERR("video device input %s\n", error.localizedDescription.UTF8String);
|
||||
assert(0);
|
||||
@ -336,7 +341,7 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||
[_session addInput:input];
|
||||
|
||||
//-- Create the output for the capture session.
|
||||
AVCaptureVideoDataOutput * dataOutput = (AVCaptureVideoDataOutput*)[[AVCaptureVideoDataOutput alloc] init];
|
||||
dataOutput = (AVCaptureVideoDataOutput*)[[AVCaptureVideoDataOutput alloc] init];
|
||||
[dataOutput setAlwaysDiscardsLateVideoFrames:NO]; // Probably want to set this to NO when recording
|
||||
|
||||
[dataOutput setVideoSettings:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey]];
|
||||
@ -390,8 +395,9 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||
|
||||
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
|
||||
{
|
||||
CLLocation *location;
|
||||
locationChanged = true;
|
||||
CLLocation *location = (CLLocation*)[locations objectAtIndex:([locations count] - 1)];
|
||||
location = (CLLocation*)[locations objectAtIndex:([locations count] - 1)];
|
||||
currentLatitude = [location coordinate].latitude;
|
||||
currentLongitude = [location coordinate].longitude;
|
||||
currentHorizontalAccuracy = location.horizontalAccuracy;
|
||||
@ -432,16 +438,17 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||
|
||||
static RAScreen* get_chosen_screen(void)
|
||||
{
|
||||
NSArray *screens;
|
||||
#if defined(OSX) && !defined(MAC_OS_X_VERSION_10_6)
|
||||
#else
|
||||
if (g_settings.video.monitor_index >= RAScreen.screens.count)
|
||||
{
|
||||
RARCH_WARN("video_monitor_index is greater than the number of connected monitors; using main screen instead.\n");
|
||||
return [RAScreen mainScreen];
|
||||
return RAScreen.mainScreen;
|
||||
}
|
||||
#endif
|
||||
|
||||
NSArray *screens = (NSArray*)[RAScreen screens];
|
||||
screens = (NSArray*)RAScreen.screens;
|
||||
return (RAScreen*)[screens objectAtIndex:g_settings.video.monitor_index];
|
||||
}
|
||||
|
||||
@ -550,9 +557,10 @@ bool apple_gfx_ctx_set_video_mode(void *data, unsigned width, unsigned height, b
|
||||
|
||||
void apple_gfx_ctx_get_video_size(void *data, unsigned* width, unsigned* height)
|
||||
{
|
||||
(void)data;
|
||||
RAScreen* screen = (RAScreen*)get_chosen_screen();
|
||||
RAScreen *screen;
|
||||
CGRect size;
|
||||
(void)data;
|
||||
screen = (RAScreen*)get_chosen_screen();
|
||||
|
||||
if (g_initialized)
|
||||
{
|
||||
@ -566,19 +574,21 @@ void apple_gfx_ctx_get_video_size(void *data, unsigned* width, unsigned* height)
|
||||
else
|
||||
size = screen.bounds;
|
||||
|
||||
|
||||
*width = CGRectGetWidth(size) * screen.scale;
|
||||
*height = CGRectGetHeight(size) * screen.scale;
|
||||
}
|
||||
|
||||
void apple_gfx_ctx_update_window_title(void *data)
|
||||
{
|
||||
(void)data;
|
||||
static char buf[128], buf_fps[128];
|
||||
bool fps_draw = g_settings.fps_show;
|
||||
bool got_text = gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps));
|
||||
bool fps_draw, got_text;
|
||||
|
||||
(void)data;
|
||||
(void)got_text;
|
||||
|
||||
fps_draw = g_settings.fps_show;
|
||||
got_text = gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps));
|
||||
static const char* const text = buf; // < Can't access buf directly in the block
|
||||
(void)got_text;
|
||||
(void)text;
|
||||
#ifdef OSX
|
||||
if (got_text)
|
||||
@ -596,8 +606,9 @@ bool apple_gfx_ctx_has_focus(void *data)
|
||||
|
||||
void apple_gfx_ctx_swap_buffers(void *data)
|
||||
{
|
||||
bool swap;
|
||||
(void)data;
|
||||
bool swap = --g_fast_forward_skips < 0;
|
||||
swap = --g_fast_forward_skips < 0;
|
||||
|
||||
if (!swap)
|
||||
return;
|
||||
@ -632,13 +643,15 @@ typedef struct ios_camera
|
||||
|
||||
static void *ios_camera_init(const char *device, uint64_t caps, unsigned width, unsigned height)
|
||||
{
|
||||
ioscamera_t *ioscamera;
|
||||
|
||||
if ((caps & (1ULL << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE)) == 0)
|
||||
{
|
||||
RARCH_ERR("ioscamera returns OpenGL texture.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ioscamera_t *ioscamera = (ioscamera_t*)calloc(1, sizeof(ioscamera_t));
|
||||
ioscamera = (ioscamera_t*)calloc(1, sizeof(ioscamera_t));
|
||||
if (!ioscamera)
|
||||
return NULL;
|
||||
|
||||
|
@ -33,7 +33,7 @@ NSString* apple_core;
|
||||
|
||||
void apple_rarch_exited(void)
|
||||
{
|
||||
NSString* used_core = (NSString*)apple_core;
|
||||
NSString *used_core = (NSString*)apple_core;
|
||||
apple_core = 0;
|
||||
|
||||
if (apple_is_running)
|
||||
|
@ -47,11 +47,12 @@ void apple_display_alert(const char *message, const char *title)
|
||||
// Fetch a value from a config file, returning defaultValue if the value is not present
|
||||
NSString* objc_get_value_from_config(config_file_t* config, NSString* name, NSString* defaultValue)
|
||||
{
|
||||
NSString *result;
|
||||
char* data = 0;
|
||||
if (config)
|
||||
config_get_string(config, name.UTF8String, &data);
|
||||
|
||||
NSString* result = data ? BOXSTRING(data) : defaultValue;
|
||||
result = data ? BOXSTRING(data) : defaultValue;
|
||||
free(data);
|
||||
return result;
|
||||
}
|
||||
|
@ -114,12 +114,13 @@ void ios_set_logging_state(const char *log_path, bool on)
|
||||
// Input helpers: This is kept here because it needs objective-c
|
||||
static void handle_touch_event(NSArray* touches)
|
||||
{
|
||||
int i;
|
||||
unsigned long numTouches = touches.count;
|
||||
const float scale = [[UIScreen mainScreen] scale];
|
||||
|
||||
g_current_input_data.touch_count = 0;
|
||||
|
||||
for(int i = 0; i != numTouches && g_current_input_data.touch_count < MAX_TOUCHES; i ++)
|
||||
for(i = 0; i != numTouches && g_current_input_data.touch_count < MAX_TOUCHES; i ++)
|
||||
{
|
||||
UITouch* touch = [touches objectAtIndex:i];
|
||||
|
||||
@ -157,6 +158,7 @@ static void handle_touch_event(NSArray* touches)
|
||||
// Keyboard handler for iOS 7
|
||||
- (id)_keyCommandForEvent:(UIEvent*)event
|
||||
{
|
||||
int i;
|
||||
// This gets called twice with the same timestamp for each keypress, that's fine for polling
|
||||
// but is bad for business with events.
|
||||
static double last_time_stamp;
|
||||
@ -170,13 +172,13 @@ static void handle_touch_event(NSArray* touches)
|
||||
{
|
||||
NSString* ch = (NSString*)event._privateInput;
|
||||
|
||||
if (!ch || [ch length] == 0)
|
||||
if (!ch || ch.length == 0)
|
||||
apple_input_keyboard_event(event._isKeyDown, (uint32_t)event._keyCode, 0, (uint32_t)event._modifierFlags);
|
||||
else
|
||||
{
|
||||
apple_input_keyboard_event(event._isKeyDown, (uint32_t)event._keyCode, [ch characterAtIndex:0], (uint32_t)event._modifierFlags);
|
||||
|
||||
for (unsigned i = 1; i != [ch length]; i ++)
|
||||
for (i = 1; i < ch.length; i++)
|
||||
apple_input_keyboard_event(event._isKeyDown, 0, [ch characterAtIndex:i], (uint32_t)event._modifierFlags);
|
||||
}
|
||||
}
|
||||
@ -217,6 +219,10 @@ static void handle_touch_event(NSArray* touches)
|
||||
|
||||
- (void)applicationDidFinishLaunching:(UIApplication *)application
|
||||
{
|
||||
const rarch_setting_t* frontend_settings;
|
||||
const core_info_list_t* core_list;
|
||||
const char *path;
|
||||
|
||||
apple_platform = self;
|
||||
[self setDelegate:self];
|
||||
|
||||
@ -235,8 +241,9 @@ static void handle_touch_event(NSArray* touches)
|
||||
self.coreDirectory = [NSBundle.mainBundle.bundlePath stringByAppendingPathComponent:@"modules"];
|
||||
self.logPath = [self.systemDirectory stringByAppendingPathComponent:@"stdout.log"];
|
||||
|
||||
const char *path = [self.documentsDirectory UTF8String];
|
||||
path = (const char*)self.documentsDirectory.UTF8String;
|
||||
path_mkdir(path);
|
||||
|
||||
if (access(path, 0755) != 0)
|
||||
{
|
||||
char msg[256];
|
||||
@ -245,8 +252,9 @@ static void handle_touch_event(NSArray* touches)
|
||||
}
|
||||
else
|
||||
{
|
||||
path = [self.systemDirectory UTF8String];
|
||||
path = self.systemDirectory.UTF8String;
|
||||
path_mkdir(path);
|
||||
|
||||
if (access(path, 0755) != 0)
|
||||
{
|
||||
char msg[256];
|
||||
@ -258,10 +266,10 @@ static void handle_touch_event(NSArray* touches)
|
||||
}
|
||||
|
||||
// Warn if there are no cores present
|
||||
core_info_set_core_path([self.coreDirectory UTF8String]);
|
||||
core_info_set_config_path([self.configDirectory UTF8String]);
|
||||
core_info_set_core_path(self.coreDirectory.UTF8String);
|
||||
core_info_set_config_path(self.configDirectory.UTF8String);
|
||||
|
||||
const core_info_list_t* core_list = (const core_info_list_t*)core_info_list_get();
|
||||
core_list = (const core_info_list_t*)core_info_list_get();
|
||||
|
||||
if (!core_list || core_list->count == 0)
|
||||
apple_display_alert("No libretro cores were found. You will not be able to run any content.", "Warning");
|
||||
@ -269,9 +277,9 @@ static void handle_touch_event(NSArray* touches)
|
||||
apple_gamecontroller_init();
|
||||
|
||||
// Load system config
|
||||
const rarch_setting_t* frontend_settings = (const rarch_setting_t*)apple_get_frontend_settings();
|
||||
frontend_settings = (const rarch_setting_t*)apple_get_frontend_settings();
|
||||
setting_data_reset(frontend_settings);
|
||||
setting_data_load_config_path(frontend_settings, [self.systemConfigPath UTF8String]);
|
||||
setting_data_load_config_path(frontend_settings, self.systemConfigPath.UTF8String);
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application
|
||||
|
Loading…
x
Reference in New Issue
Block a user