(UI) Cleanups; style nits
This commit is contained in:
parent
d12a747e06
commit
7dfaae58f9
|
@ -300,9 +300,9 @@ void *glkitview_init(void);
|
|||
[super viewDidLoad];
|
||||
#if TARGET_OS_IOS
|
||||
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(showNativeMenu)];
|
||||
swipe.numberOfTouchesRequired = 4;
|
||||
swipe.delegate = self;
|
||||
swipe.direction = UISwipeGestureRecognizerDirectionDown;
|
||||
swipe.numberOfTouchesRequired = 4;
|
||||
swipe.delegate = self;
|
||||
swipe.direction = UISwipeGestureRecognizerDirectionDown;
|
||||
[self.view addGestureRecognizer:swipe];
|
||||
#ifdef HAVE_IOS_TOUCHMOUSE
|
||||
[self setupMouseSupport];
|
||||
|
@ -310,14 +310,14 @@ void *glkitview_init(void);
|
|||
#ifdef HAVE_IOS_CUSTOMKEYBOARD
|
||||
[self setupEmulatorKeyboard];
|
||||
UISwipeGestureRecognizer *showKeyboardSwipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(toggleCustomKeyboardUsingSwipe:)];
|
||||
showKeyboardSwipe.numberOfTouchesRequired = 3;
|
||||
showKeyboardSwipe.direction = UISwipeGestureRecognizerDirectionUp;
|
||||
showKeyboardSwipe.delegate = self;
|
||||
showKeyboardSwipe.numberOfTouchesRequired = 3;
|
||||
showKeyboardSwipe.direction = UISwipeGestureRecognizerDirectionUp;
|
||||
showKeyboardSwipe.delegate = self;
|
||||
[self.view addGestureRecognizer:showKeyboardSwipe];
|
||||
UISwipeGestureRecognizer *hideKeyboardSwipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(toggleCustomKeyboardUsingSwipe:)];
|
||||
hideKeyboardSwipe.numberOfTouchesRequired = 3;
|
||||
hideKeyboardSwipe.direction = UISwipeGestureRecognizerDirectionDown;
|
||||
hideKeyboardSwipe.delegate = self;
|
||||
hideKeyboardSwipe.numberOfTouchesRequired = 3;
|
||||
hideKeyboardSwipe.direction = UISwipeGestureRecognizerDirectionDown;
|
||||
hideKeyboardSwipe.delegate = self;
|
||||
[self.view addGestureRecognizer:hideKeyboardSwipe];
|
||||
#endif
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
|
||||
|
@ -366,13 +366,14 @@ void *glkitview_init(void);
|
|||
|
||||
-(void)handleMouseMoveWithX:(CGFloat)x y:(CGFloat)y
|
||||
{
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*) input_state_get_ptr()->current_data;
|
||||
if (!apple)
|
||||
return;
|
||||
apple->mouse_rel_x = (int16_t)x;
|
||||
apple->mouse_rel_y = (int16_t)y;
|
||||
// use location position to track pointer
|
||||
if (@available(iOS 13.4, *)) {
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*) input_state_get_ptr()->current_data;
|
||||
if (!apple)
|
||||
return;
|
||||
apple->mouse_rel_x = (int16_t)x;
|
||||
apple->mouse_rel_y = (int16_t)y;
|
||||
/* use location position to track pointer */
|
||||
if (@available(iOS 13.4, *))
|
||||
{
|
||||
apple->window_pos_x = 0;
|
||||
apple->window_pos_y = 0;
|
||||
}
|
||||
|
@ -478,7 +479,7 @@ float cocoa_screen_get_backing_scale_factor(void) { return 1.0f; }
|
|||
#endif
|
||||
#else
|
||||
static float get_from_selector(
|
||||
Class obj_class, id obj_id, SEL selector, CGFloat *ret)
|
||||
Class obj_class, id obj_id, SEL selector, CGFloat *ret)
|
||||
{
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:
|
||||
[obj_class instanceMethodSignatureForSelector:selector]];
|
||||
|
@ -499,15 +500,14 @@ float cocoa_screen_get_native_scale(void)
|
|||
|
||||
if (ret != 0.0f)
|
||||
return ret;
|
||||
screen = (BRIDGE RAScreen*)cocoa_screen_get_chosen();
|
||||
if (!screen)
|
||||
if (!(screen = (BRIDGE RAScreen*)cocoa_screen_get_chosen()))
|
||||
return 0.0f;
|
||||
|
||||
selector = NSSelectorFromString(BOXSTRING("nativeScale"));
|
||||
|
||||
if ([screen respondsToSelector:selector])
|
||||
ret = (float)get_from_selector(
|
||||
[screen class], screen, selector, &ret);
|
||||
[screen class], screen, selector, &ret);
|
||||
else
|
||||
{
|
||||
ret = 1.0f;
|
||||
|
|
|
@ -114,9 +114,7 @@ static void ui_window_cocoa_set_droppable(void *data, bool droppable)
|
|||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
[[cocoa_view window] unregisterDraggedTypes];
|
||||
}
|
||||
}
|
||||
|
||||
static bool ui_window_cocoa_focused(void *data)
|
||||
|
@ -407,22 +405,22 @@ static ui_application_t ui_application_cocoa = {
|
|||
NSUInteger mods = event.modifierFlags;
|
||||
uint16_t keycode = event.keyCode;
|
||||
|
||||
if (mods & NSEventModifierFlagCapsLock)
|
||||
mod |= RETROKMOD_CAPSLOCK;
|
||||
if (mods & NSEventModifierFlagShift)
|
||||
mod |= RETROKMOD_SHIFT;
|
||||
if (mods & NSEventModifierFlagControl)
|
||||
mod |= RETROKMOD_CTRL;
|
||||
if (mods & NSEventModifierFlagOption)
|
||||
mod |= RETROKMOD_ALT;
|
||||
if (mods & NSEventModifierFlagCommand)
|
||||
mod |= RETROKMOD_META;
|
||||
if (mods & NSEventModifierFlagNumericPad)
|
||||
mod |= RETROKMOD_NUMLOCK;
|
||||
if (mods & NSEventModifierFlagCapsLock)
|
||||
mod |= RETROKMOD_CAPSLOCK;
|
||||
if (mods & NSEventModifierFlagShift)
|
||||
mod |= RETROKMOD_SHIFT;
|
||||
if (mods & NSEventModifierFlagControl)
|
||||
mod |= RETROKMOD_CTRL;
|
||||
if (mods & NSEventModifierFlagOption)
|
||||
mod |= RETROKMOD_ALT;
|
||||
if (mods & NSEventModifierFlagCommand)
|
||||
mod |= RETROKMOD_META;
|
||||
if (mods & NSEventModifierFlagNumericPad)
|
||||
mod |= RETROKMOD_NUMLOCK;
|
||||
|
||||
for (i = 1; i < ch.length; i++)
|
||||
apple_input_keyboard_event(event_type == NSEventTypeKeyDown,
|
||||
0, inputTextUTF8[i], mod, RETRO_DEVICE_KEYBOARD);
|
||||
for (i = 1; i < ch.length; i++)
|
||||
apple_input_keyboard_event(event_type == NSEventTypeKeyDown,
|
||||
0, inputTextUTF8[i], mod, RETRO_DEVICE_KEYBOARD);
|
||||
|
||||
apple_input_keyboard_event(event_type == NSEventTypeKeyDown,
|
||||
keycode, character, mod, RETRO_DEVICE_KEYBOARD);
|
||||
|
@ -558,7 +556,7 @@ static ui_application_t ui_application_cocoa = {
|
|||
{
|
||||
waiting_argv[i] = NULL;
|
||||
waiting_argv[i+1] = NULL;
|
||||
waiting_argc -= 2;
|
||||
waiting_argc -= 2;
|
||||
}
|
||||
}
|
||||
if (rarch_main(waiting_argc, waiting_argv, NULL))
|
||||
|
@ -582,41 +580,40 @@ static ui_application_t ui_application_cocoa = {
|
|||
if (vt == _vt)
|
||||
return;
|
||||
|
||||
_vt = vt;
|
||||
if (_renderView != nil)
|
||||
_vt = vt;
|
||||
|
||||
if (_renderView)
|
||||
{
|
||||
_renderView.wantsLayer = NO;
|
||||
_renderView.layer = nil;
|
||||
_renderView.wantsLayer = NO;
|
||||
_renderView.layer = nil;
|
||||
[_renderView removeFromSuperview];
|
||||
self.window.contentView = nil;
|
||||
_renderView = nil;
|
||||
self.window.contentView = nil;
|
||||
_renderView = nil;
|
||||
}
|
||||
|
||||
switch (vt)
|
||||
{
|
||||
case APPLE_VIEW_TYPE_VULKAN:
|
||||
case APPLE_VIEW_TYPE_METAL:
|
||||
case APPLE_VIEW_TYPE_METAL:
|
||||
{
|
||||
MetalView *v = [MetalView new];
|
||||
v.paused = YES;
|
||||
MetalView *v = [MetalView new];
|
||||
v.paused = YES;
|
||||
v.enableSetNeedsDisplay = NO;
|
||||
_renderView = v;
|
||||
_renderView = v;
|
||||
}
|
||||
break;
|
||||
|
||||
case APPLE_VIEW_TYPE_OPENGL:
|
||||
_renderView = [CocoaView get];
|
||||
case APPLE_VIEW_TYPE_OPENGL:
|
||||
_renderView = [CocoaView get];
|
||||
break;
|
||||
|
||||
case APPLE_VIEW_TYPE_NONE:
|
||||
default:
|
||||
case APPLE_VIEW_TYPE_NONE:
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
_renderView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
||||
[_renderView setFrame: [[self.window contentView] bounds]];
|
||||
|
||||
self.window.contentView = _renderView;
|
||||
self.window.contentView = _renderView;
|
||||
self.window.contentView.nextResponder = _listener;
|
||||
}
|
||||
|
||||
|
@ -628,14 +625,19 @@ static ui_application_t ui_application_cocoa = {
|
|||
{
|
||||
BOOL is_fullscreen = (self.window.styleMask
|
||||
& NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen;
|
||||
if (mode.fullscreen && !is_fullscreen)
|
||||
if (mode.fullscreen)
|
||||
{
|
||||
[self.window toggleFullScreen:self];
|
||||
return;
|
||||
if (!is_fullscreen)
|
||||
{
|
||||
[self.window toggleFullScreen:self];
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_fullscreen)
|
||||
[self.window toggleFullScreen:self];
|
||||
}
|
||||
|
||||
if (!mode.fullscreen && is_fullscreen)
|
||||
[self.window toggleFullScreen:self];
|
||||
|
||||
/* HACK(sgc): ensure MTKView posts a drawable resize event */
|
||||
if (mode.width > 0)
|
||||
|
@ -653,12 +655,18 @@ static ui_application_t ui_application_cocoa = {
|
|||
|
||||
- (bool)setDisableDisplaySleep:(bool)disable
|
||||
{
|
||||
if (disable && _sleepActivity == nil)
|
||||
_sleepActivity = [NSProcessInfo.processInfo beginActivityWithOptions:NSActivityIdleDisplaySleepDisabled reason:@"disable screen saver"];
|
||||
else if (!disable && _sleepActivity != nil)
|
||||
if (disable)
|
||||
{
|
||||
[NSProcessInfo.processInfo endActivity:_sleepActivity];
|
||||
_sleepActivity = nil;
|
||||
if (_sleepActivity == nil)
|
||||
_sleepActivity = [NSProcessInfo.processInfo beginActivityWithOptions:NSActivityIdleDisplaySleepDisabled reason:@"disable screen saver"];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_sleepActivity)
|
||||
{
|
||||
[NSProcessInfo.processInfo endActivity:_sleepActivity];
|
||||
_sleepActivity = nil;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
@ -765,7 +773,7 @@ static void open_core_handler(ui_browser_window_state_t *state, bool result)
|
|||
path_set(RARCH_PATH_CORE, state->result);
|
||||
ui_companion_event_command(CMD_EVENT_LOAD_CORE);
|
||||
|
||||
if (info
|
||||
if ( info
|
||||
&& info->load_no_content
|
||||
&& set_supports_no_game_enable)
|
||||
{
|
||||
|
@ -937,7 +945,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
if (argc == 2)
|
||||
{
|
||||
if (argv[1] != NULL)
|
||||
if (argv[1])
|
||||
if (!strncmp(argv[1], "-psn", 4))
|
||||
argc = 1;
|
||||
}
|
||||
|
@ -962,8 +970,7 @@ static void ui_companion_cocoa_event_command(void *data, enum event_command cmd)
|
|||
[performer performSelectorOnMainThread:@selector(perform) withObject:nil waitUntilDone:NO];
|
||||
RELEASE(performer);
|
||||
}
|
||||
static void ui_companion_cocoa_notify_list_pushed(void *data,
|
||||
file_list_t *list, file_list_t *menu_list) { }
|
||||
static void ui_companion_cocoa_notify_list_pushed(void *data, file_list_t *a, file_list_t *b) { }
|
||||
|
||||
static void *ui_companion_cocoa_get_main_window(void *data)
|
||||
{
|
||||
|
|
|
@ -165,14 +165,14 @@ static void handle_touch_event(NSArray* touches)
|
|||
* defined in any standard iOS header */
|
||||
enum
|
||||
{
|
||||
NSAlphaShiftKeyMask = 1 << 16,
|
||||
NSShiftKeyMask = 1 << 17,
|
||||
NSControlKeyMask = 1 << 18,
|
||||
NSAlternateKeyMask = 1 << 19,
|
||||
NSCommandKeyMask = 1 << 20,
|
||||
NSNumericPadKeyMask = 1 << 21,
|
||||
NSHelpKeyMask = 1 << 22,
|
||||
NSFunctionKeyMask = 1 << 23,
|
||||
NSAlphaShiftKeyMask = 1 << 16,
|
||||
NSShiftKeyMask = 1 << 17,
|
||||
NSControlKeyMask = 1 << 18,
|
||||
NSAlternateKeyMask = 1 << 19,
|
||||
NSCommandKeyMask = 1 << 20,
|
||||
NSNumericPadKeyMask = 1 << 21,
|
||||
NSHelpKeyMask = 1 << 22,
|
||||
NSFunctionKeyMask = 1 << 23,
|
||||
NSDeviceIndependentModifierFlagsMask = 0xffff0000U
|
||||
};
|
||||
|
||||
|
@ -187,9 +187,9 @@ enum
|
|||
if (last_time_stamp == event.timestamp)
|
||||
return [super handleKeyUIEvent:event];
|
||||
|
||||
last_time_stamp = event.timestamp;
|
||||
last_time_stamp = event.timestamp;
|
||||
|
||||
/* If the _hidEvent is null, [event _keyCode] will crash.
|
||||
/* If the _hidEvent is NULL, [event _keyCode] will crash.
|
||||
* (This happens with the on screen keyboard). */
|
||||
if (event._hidEvent)
|
||||
{
|
||||
|
@ -357,14 +357,14 @@ enum
|
|||
switch (vt)
|
||||
{
|
||||
#ifdef HAVE_COCOA_METAL
|
||||
case APPLE_VIEW_TYPE_VULKAN:
|
||||
case APPLE_VIEW_TYPE_VULKAN:
|
||||
case APPLE_VIEW_TYPE_METAL:
|
||||
{
|
||||
MetalView *v = [MetalView new];
|
||||
v.paused = YES;
|
||||
v.paused = YES;
|
||||
v.enableSetNeedsDisplay = NO;
|
||||
#if TARGET_OS_IOS
|
||||
v.multipleTouchEnabled = YES;
|
||||
v.multipleTouchEnabled = YES;
|
||||
#endif
|
||||
_renderView = v;
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ enum
|
|||
break;
|
||||
|
||||
case APPLE_VIEW_TYPE_NONE:
|
||||
default:
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ enum
|
|||
{
|
||||
#ifdef HAVE_COCOA_METAL
|
||||
MetalView *metalView = (MetalView*) _renderView;
|
||||
CGFloat scale = [[UIScreen mainScreen] scale];
|
||||
CGFloat scale = [[UIScreen mainScreen] scale];
|
||||
[metalView setDrawableSize:CGSizeMake(
|
||||
_renderView.bounds.size.width * scale,
|
||||
_renderView.bounds.size.height * scale
|
||||
|
@ -411,11 +411,10 @@ enum
|
|||
if (_documentsDirectory == nil)
|
||||
{
|
||||
#if TARGET_OS_IOS
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
#elif TARGET_OS_TV
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||
#endif
|
||||
|
||||
_documentsDirectory = paths.firstObject;
|
||||
}
|
||||
return _documentsDirectory;
|
||||
|
@ -481,8 +480,7 @@ enum
|
|||
if ([url startAccessingSecurityScopedResource]) {
|
||||
if (![[url path] containsString: self.documentsDirectory])
|
||||
if (![manager fileExistsAtPath:destination])
|
||||
if (![manager copyItemAtPath:[url path] toPath:destination error:&error])
|
||||
printf("%s\n", [[error description] UTF8String]);
|
||||
[manager copyItemAtPath:[url path] toPath:destination error:&error];
|
||||
[url stopAccessingSecurityScopedResource];
|
||||
}
|
||||
return true;
|
||||
|
@ -561,8 +559,6 @@ int main(int argc, char *argv[])
|
|||
static void apple_rarch_exited(void)
|
||||
{
|
||||
RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform;
|
||||
|
||||
if (!ap)
|
||||
return;
|
||||
[ap showPauseMenu:ap];
|
||||
if (ap)
|
||||
[ap showPauseMenu:ap];
|
||||
}
|
||||
|
|
|
@ -158,15 +158,15 @@ static enum ui_msg_window_response ui_msg_window_win32_response(
|
|||
switch (response)
|
||||
{
|
||||
case IDOK:
|
||||
return UI_MSG_RESPONSE_OK;
|
||||
return UI_MSG_RESPONSE_OK;
|
||||
case IDCANCEL:
|
||||
return UI_MSG_RESPONSE_CANCEL;
|
||||
return UI_MSG_RESPONSE_CANCEL;
|
||||
case IDYES:
|
||||
return UI_MSG_RESPONSE_YES;
|
||||
return UI_MSG_RESPONSE_YES;
|
||||
case IDNO:
|
||||
return UI_MSG_RESPONSE_NO;
|
||||
return UI_MSG_RESPONSE_NO;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (state->buttons)
|
||||
|
|
Loading…
Reference in New Issue