RetroArch/ui/drivers/ui_cocoa.m

655 lines
19 KiB
Mathematica
Raw Normal View History

2015-04-20 12:43:07 +02:00
/* RetroArch - A frontend for libretro.
2017-01-22 13:40:32 +01:00
* Copyright (C) 2013-2014 - Jason Fetters
* Copyright (C) 2011-2017 - Daniel De Matteis
2015-04-20 12:43:07 +02:00
*
* 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 <objc/objc-runtime.h>
2015-04-20 12:43:07 +02:00
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <boolean.h>
2015-04-20 12:43:07 +02:00
#include <file/file_path.h>
2016-01-20 04:11:25 +01:00
#include <string/stdstring.h>
2016-05-16 17:29:02 +02:00
#include <queues/task_queue.h>
2017-06-28 04:41:38 +02:00
#include <retro_timers.h>
#include "cocoa/cocoa_defines.h"
#include "cocoa/cocoa_common.h"
2019-11-30 12:43:38 +07:00
#include "cocoa/apple_platform.h"
2015-04-20 12:43:07 +02:00
#include "../ui_companion_driver.h"
2015-04-20 17:27:07 +02:00
#include "../../input/drivers/cocoa_input.h"
2015-11-29 16:30:38 +01:00
#include "../../input/drivers_keyboard/keyboard_event_apple.h"
2015-04-20 17:27:07 +02:00
#include "../../frontend/frontend.h"
2016-09-05 18:33:22 +02:00
#include "../../configuration.h"
2016-09-23 03:42:50 +02:00
#include "../../paths.h"
2016-09-06 06:11:44 +02:00
#include "../../core.h"
2016-01-20 00:38:48 +01:00
#include "../../retroarch.h"
2019-01-20 03:26:35 +01:00
#include "../../tasks/task_content.h"
2016-02-10 07:20:54 +01:00
#include "../../tasks/tasks_internal.h"
2020-03-07 06:50:43 +01:00
#include "../../verbosity.h"
2021-01-16 22:22:16 +01:00
/* TODO/FIXME - static global variables */
static int waiting_argc;
static char **waiting_argv;
#if defined(HAVE_COCOA_METAL)
@interface RAWindow : NSWindow
@end
@implementation RAWindow
#elif defined(HAVE_COCOA)
@interface RApplication : NSApplication
@end
@implementation RApplication
#endif
2021-01-16 22:22:16 +01:00
#ifdef HAVE_COCOA_METAL
#define CONVERT_POINT() [apple_platform.renderView convertPoint:[event locationInWindow] fromView:nil]
#else
#define CONVERT_POINT() [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil]
#endif
2019-05-06 14:11:46 +02:00
- (void)sendEvent:(NSEvent *)event {
NSEventType event_type = event.type;
2016-01-13 13:08:51 +01:00
2020-09-14 23:14:26 +02:00
[super sendEvent:event];
switch ((int32_t)event_type)
{
case NSEventTypeKeyDown:
case NSEventTypeKeyUp:
{
2020-09-14 20:09:30 +02:00
uint32_t i;
NSString* ch = event.characters;
uint32_t mod = 0;
const char *inputTextUTF8 = ch.UTF8String;
uint32_t character = inputTextUTF8[0];
NSEventModifierFlags mods = event.modifierFlags;
2020-09-14 20:32:04 +02:00
uint16_t keycode = event.keyCode;
2020-09-14 20:09:30 +02:00
if (mods & NSEventModifierFlagCapsLock)
2016-01-13 13:08:51 +01:00
mod |= RETROKMOD_CAPSLOCK;
2020-09-14 20:09:30 +02:00
if (mods & NSEventModifierFlagShift)
2016-01-13 13:08:51 +01:00
mod |= RETROKMOD_SHIFT;
2020-09-14 20:09:30 +02:00
if (mods & NSEventModifierFlagControl)
2016-01-13 13:08:51 +01:00
mod |= RETROKMOD_CTRL;
2020-09-14 20:09:30 +02:00
if (mods & NSEventModifierFlagOption)
2016-01-13 13:08:51 +01:00
mod |= RETROKMOD_ALT;
2020-09-14 20:09:30 +02:00
if (mods & NSEventModifierFlagCommand)
2016-01-13 13:08:51 +01:00
mod |= RETROKMOD_META;
2020-09-14 20:09:30 +02:00
if (mods & NSEventModifierFlagNumericPad)
2016-01-13 13:08:51 +01:00
mod |= RETROKMOD_NUMLOCK;
for (i = 1; i < ch.length; i++)
apple_input_keyboard_event(event_type == NSEventTypeKeyDown,
2020-09-14 20:09:30 +02:00
0, inputTextUTF8[i], mod, RETRO_DEVICE_KEYBOARD);
2016-01-13 13:08:51 +01:00
apple_input_keyboard_event(event_type == NSEventTypeKeyDown,
2020-09-14 20:32:04 +02:00
keycode, character, mod, RETRO_DEVICE_KEYBOARD);
}
break;
#if defined(HAVE_COCOA_METAL)
case NSEventTypeFlagsChanged:
#elif defined(HAVE_COCOA)
case NSFlagsChanged:
#endif
2016-01-13 13:08:51 +01:00
{
2020-09-14 20:32:04 +02:00
static NSEventModifierFlags old_flags = 0;
NSEventModifierFlags new_flags = event.modifierFlags;
bool down = (new_flags & old_flags) == old_flags;
uint16_t keycode = event.keyCode;
2017-01-16 22:34:36 +01:00
2020-09-14 20:32:04 +02:00
old_flags = new_flags;
2020-09-14 20:32:04 +02:00
apple_input_keyboard_event(down, keycode,
2020-09-14 20:23:49 +02:00
0, new_flags, RETRO_DEVICE_KEYBOARD);
2016-01-13 13:08:51 +01:00
}
break;
case NSEventTypeMouseMoved:
case NSEventTypeLeftMouseDragged:
case NSEventTypeRightMouseDragged:
2020-02-13 22:39:29 +01:00
case NSEventTypeOtherMouseDragged:
2015-11-29 18:06:09 +01:00
{
2020-09-14 23:14:26 +02:00
CGFloat delta_x = event.deltaX;
CGFloat delta_y = event.deltaY;
2021-01-17 05:02:07 +01:00
NSPoint pos = CONVERT_POINT();
2020-09-14 23:14:26 +02:00
cocoa_input_data_t
*apple = (cocoa_input_data_t*)
input_driver_get_data();
if (!apple)
2020-06-04 14:41:28 +02:00
return;
/* Relative */
2020-09-14 20:27:44 +02:00
apple->mouse_rel_x += (int16_t)delta_x;
apple->mouse_rel_y += (int16_t)delta_y;
/* Absolute */
2020-09-14 20:14:23 +02:00
apple->touches[0].screen_x = (int16_t)pos.x;
apple->touches[0].screen_y = (int16_t)pos.y;
apple->window_pos_x = (int16_t)pos.x;
apple->window_pos_y = (int16_t)pos.y;
2015-11-29 18:06:09 +01:00
}
break;
#if defined(HAVE_COCOA_METAL)
case NSEventTypeScrollWheel:
#elif defined(HAVE_COCOA)
case NSScrollWheel:
#endif
2016-01-13 13:08:51 +01:00
/* TODO/FIXME - properly implement. */
break;
2019-09-20 18:22:14 +02:00
case NSEventTypeLeftMouseDown:
case NSEventTypeRightMouseDown:
case NSEventTypeOtherMouseDown:
{
2020-09-14 20:47:07 +02:00
NSInteger number = event.buttonNumber;
2021-01-17 05:02:07 +01:00
NSPoint pos = CONVERT_POINT();
2020-09-14 23:14:26 +02:00
cocoa_input_data_t
*apple = (cocoa_input_data_t*)
input_driver_get_data();
2019-09-20 18:22:14 +02:00
if (!apple || pos.y < 0)
return;
2020-09-14 20:14:23 +02:00
apple->mouse_buttons |= (1 << number);
apple->touch_count = 1;
2019-09-20 18:22:14 +02:00
}
break;
case NSEventTypeLeftMouseUp:
case NSEventTypeRightMouseUp:
case NSEventTypeOtherMouseUp:
2017-01-16 22:34:36 +01:00
{
2020-09-14 20:47:07 +02:00
NSInteger number = event.buttonNumber;
2021-01-17 05:02:07 +01:00
NSPoint pos = CONVERT_POINT();
2021-01-16 22:22:16 +01:00
cocoa_input_data_t
2020-09-14 23:14:26 +02:00
*apple = (cocoa_input_data_t*)
input_driver_get_data();
2017-01-16 22:34:36 +01:00
if (!apple || pos.y < 0)
return;
2020-09-14 20:14:23 +02:00
apple->mouse_buttons &= ~(1 << number);
apple->touch_count = 0;
2017-01-16 22:34:36 +01:00
}
break;
default:
break;
}
}
@end
@implementation RetroArch_OSX
@synthesize window = _window;
#ifdef HAVE_COCOA_METAL
2019-02-07 06:37:41 +01:00
#else
#define NS_WINDOW_COLLECTION_BEHAVIOR_FULLSCREEN_PRIMARY (1 << 17)
- (void)dealloc
{
[_window release];
[super dealloc];
}
#endif
2016-01-17 18:58:50 +01:00
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
unsigned i;
apple_platform = self;
2020-09-15 21:00:22 +02:00
[self.window setAcceptsMouseMovedEvents: YES];
#if MAC_OS_X_VERSION_10_7
self.window.collectionBehavior = NS_WINDOW_COLLECTION_BEHAVIOR_FULLSCREEN_PRIMARY;
#endif
#ifdef HAVE_COCOA_METAL
_listener = [WindowListener new];
[self.window setNextResponder:_listener];
self.window.delegate = _listener;
#else
[[CocoaView get] setFrame: [[self.window contentView] bounds]];
#endif
[[self.window contentView] setAutoresizesSubviews:YES];
#ifndef HAVE_COCOA_METAL
[[self.window contentView] addSubview:[CocoaView get]];
[self.window makeFirstResponder:[CocoaView get]];
#endif
2020-09-15 21:00:22 +02:00
for (i = 0; i < waiting_argc; i++)
{
if (string_is_equal(waiting_argv[i], "-NSDocumentRevisionsDebugMode"))
{
waiting_argv[i] = NULL;
waiting_argv[i+1] = NULL;
waiting_argc -= 2;
}
}
2015-04-20 21:31:25 +02:00
if (rarch_main(waiting_argc, waiting_argv, NULL))
2020-09-15 20:45:42 +02:00
[[NSApplication sharedApplication] terminate:nil];
waiting_argc = 0;
#ifdef HAVE_COCOA_METAL
[self.window makeMainWindow];
[self.window makeKeyWindow];
#endif
[self performSelectorOnMainThread:@selector(rarch_main) withObject:nil waitUntilDone:NO];
}
#pragma mark - ApplePlatform
#ifdef HAVE_COCOA_METAL
2020-09-15 21:00:22 +02:00
- (void)setViewType:(apple_view_type_t)vt
{
2020-02-19 20:57:02 +01:00
if (vt == _vt)
return;
_vt = vt;
if (_renderView != nil)
{
2020-09-14 21:50:51 +02:00
_renderView.wantsLayer = NO;
_renderView.layer = nil;
[_renderView removeFromSuperview];
self.window.contentView = nil;
2020-09-14 21:50:51 +02:00
_renderView = nil;
}
2020-09-14 21:50:51 +02:00
switch (vt)
{
case APPLE_VIEW_TYPE_VULKAN:
2020-09-14 21:50:51 +02:00
case APPLE_VIEW_TYPE_METAL:
{
MetalView *v = [MetalView new];
v.paused = YES;
v.enableSetNeedsDisplay = NO;
_renderView = v;
}
break;
case APPLE_VIEW_TYPE_OPENGL:
_renderView = [CocoaView get];
break;
2020-09-14 21:50:51 +02:00
case APPLE_VIEW_TYPE_NONE:
2021-01-16 22:36:03 +01:00
default:
return;
}
_renderView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
[_renderView setFrame: [[self.window contentView] bounds]];
self.window.contentView = _renderView;
self.window.contentView.nextResponder = _listener;
}
2020-09-15 21:00:22 +02:00
- (apple_view_type_t)viewType { return _vt; }
- (id)renderView { return _renderView; }
- (bool)hasFocus { return [NSApp isActive]; }
2020-09-15 21:03:27 +02:00
- (void)setVideoMode:(gfx_ctx_mode_t)mode
{
BOOL is_fullscreen = (self.window.styleMask
& NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen;
if (mode.fullscreen && !is_fullscreen)
{
[self.window toggleFullScreen:self];
return;
}
2020-09-15 21:03:27 +02:00
if (!mode.fullscreen && is_fullscreen)
[self.window toggleFullScreen:self];
2020-09-15 21:03:27 +02:00
/* HACK(sgc): ensure MTKView posts a drawable resize event */
if (mode.width > 0)
[self.window setContentSize:NSMakeSize(mode.width-1, mode.height)];
[self.window setContentSize:NSMakeSize(mode.width, mode.height)];
}
2020-09-15 21:00:22 +02:00
- (void)setCursorVisible:(bool)v
{
if (v)
[NSCursor unhide];
else
[NSCursor hide];
}
- (bool)setDisableDisplaySleep:(bool)disable
{
if (disable && _sleepActivity == nil)
_sleepActivity = [NSProcessInfo.processInfo beginActivityWithOptions:NSActivityIdleDisplaySleepDisabled reason:@"disable screen saver"];
else if (!disable && _sleepActivity != nil)
{
[NSProcessInfo.processInfo endActivity:_sleepActivity];
_sleepActivity = nil;
}
return YES;
}
#endif
- (void) rarch_main
{
for (;;)
{
2016-09-30 08:17:18 +02:00
int ret;
#ifdef HAVE_QT
const ui_application_t *application = &ui_application_qt;
#else
2019-07-11 04:28:49 +02:00
const ui_application_t *application = &ui_application_cocoa;
#endif
if (application)
application->process_events();
ret = runloop_iterate();
2017-05-14 20:43:39 +02:00
task_queue_check();
while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.002, FALSE)
== kCFRunLoopRunHandledSource);
2016-09-30 08:17:18 +02:00
if (ret == -1)
{
#ifdef HAVE_QT
ui_application_qt.quit();
#endif
2016-09-30 08:17:18 +02:00
break;
}
}
2018-04-30 14:33:05 -04:00
main_exit(NULL);
}
2020-09-15 21:00:22 +02:00
- (void)applicationDidBecomeActive:(NSNotification *)notification { }
- (void)applicationWillResignActive:(NSNotification *)notification { }
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication { return YES; }
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
NSApplicationTerminateReply reply = NSTerminateNow;
if (rarch_ctl(RARCH_CTL_IS_INITED, NULL))
reply = NSTerminateCancel;
command_event(CMD_EVENT_QUIT, NULL);
return reply;
}
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
{
2020-09-15 21:03:27 +02:00
if ((filenames.count == 1) && [filenames objectAtIndex:0])
{
struct retro_system_info *system = runloop_get_libretro_system_info();
2020-09-15 21:03:27 +02:00
NSString *__core = [filenames objectAtIndex:0];
2019-05-06 14:11:46 +02:00
const char *core_name = system->library_name;
2018-04-30 14:33:05 -04:00
if (core_name)
{
content_ctx_info_t content_info = {0};
task_push_load_content_with_current_core_from_companion_ui(
__core.UTF8String,
&content_info,
CORE_TYPE_PLAIN,
NULL, NULL);
}
else
2016-09-29 09:58:57 +02:00
path_set(RARCH_PATH_CONTENT, __core.UTF8String);
[sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess];
}
else
{
2020-09-15 21:03:27 +02:00
const ui_msg_window_t *msg_window =
ui_companion_driver_get_msg_window_ptr();
2016-06-08 07:19:19 +02:00
if (msg_window)
{
2016-06-08 07:24:26 +02:00
ui_msg_window_state msg_window_state;
msg_window_state.text = strdup("Cannot open multiple files");
msg_window_state.title = strdup(msg_hash_to_str(MSG_PROGRAM));
2016-06-08 07:19:19 +02:00
msg_window->information(&msg_window_state);
2016-06-08 07:24:26 +02:00
free(msg_window_state.text);
free(msg_window_state.title);
2016-06-08 07:19:19 +02:00
}
[sender replyToOpenOrPrint:NSApplicationDelegateReplyFailure];
}
}
static void open_core_handler(ui_browser_window_state_t *state, bool result)
{
2020-02-19 20:57:02 +01:00
rarch_system_info_t *info = runloop_get_system_info();
settings_t *settings = config_get_ptr();
2020-09-15 21:03:27 +02:00
bool set_supports_no_game_enable =
settings->bools.set_supports_no_game_enable;
2020-09-15 21:00:22 +02:00
if (!state || string_is_empty(state->result))
2020-02-19 20:57:02 +01:00
return;
if (!result)
return;
2018-04-30 14:33:05 -04:00
2020-02-19 20:57:02 +01:00
path_set(RARCH_PATH_CORE, state->result);
ui_companion_event_command(CMD_EVENT_LOAD_CORE);
2018-04-30 14:33:05 -04:00
if (info
2020-02-19 20:57:02 +01:00
&& info->load_no_content
&& set_supports_no_game_enable)
{
content_ctx_info_t content_info = {0};
path_clear(RARCH_PATH_CONTENT);
task_push_load_content_with_current_core_from_companion_ui(
NULL,
&content_info,
CORE_TYPE_PLAIN,
NULL, NULL);
}
}
2020-02-19 20:57:02 +01:00
static void open_document_handler(
ui_browser_window_state_t *state, bool result)
{
2020-02-19 20:57:02 +01:00
struct retro_system_info *system = runloop_get_libretro_system_info();
const char *core_name = system ? system->library_name : NULL;
2018-04-30 14:33:05 -04:00
2020-09-15 21:00:22 +02:00
if (!state || string_is_empty(state->result))
2020-02-19 20:57:02 +01:00
return;
if (!result)
return;
2018-04-30 14:33:05 -04:00
2020-02-19 20:57:02 +01:00
path_set(RARCH_PATH_CONTENT, state->result);
2018-04-30 14:33:05 -04:00
2020-02-19 20:57:02 +01:00
if (core_name)
{
content_ctx_info_t content_info = {0};
task_push_load_content_with_current_core_from_companion_ui(
NULL,
&content_info,
CORE_TYPE_PLAIN,
NULL, NULL);
}
2016-01-17 18:42:52 +01:00
}
2020-09-15 21:03:27 +02:00
- (IBAction)openCore:(id)sender
{
const ui_browser_window_t *browser =
ui_companion_driver_get_browser_window_ptr();
2018-04-30 14:33:05 -04:00
2020-09-15 21:03:27 +02:00
if (browser)
{
ui_browser_window_state_t browser_state;
bool result = false;
settings_t *settings = config_get_ptr();
const char *path_dir_libretro = settings->paths.directory_libretro;
browser_state.filters = strdup("dylib");
browser_state.filters_title = strdup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_SETTINGS));
browser_state.title = strdup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_LIST));
browser_state.startdir = strdup(path_dir_libretro);
result = browser->open(&browser_state);
open_core_handler(&browser_state, result);
free(browser_state.filters);
free(browser_state.filters_title);
free(browser_state.title);
free(browser_state.startdir);
}
2016-01-17 18:43:24 +01:00
}
2016-01-17 18:42:52 +01:00
- (void)openDocument:(id)sender
{
2020-09-15 21:03:27 +02:00
const ui_browser_window_t *browser =
ui_companion_driver_get_browser_window_ptr();
2018-04-30 14:33:05 -04:00
2020-09-15 21:03:27 +02:00
if (browser)
{
ui_browser_window_state_t
browser_state = {{0}};
bool result = false;
settings_t *settings = config_get_ptr();
const char *path_dir_menu_content = settings->paths.directory_menu_content;
NSString *startdir = BOXSTRING(path_dir_menu_content);
2018-04-30 14:33:05 -04:00
2020-09-15 21:03:27 +02:00
if (!startdir.length)
startdir = BOXSTRING("/");
2018-04-30 14:33:05 -04:00
2020-09-15 21:03:27 +02:00
browser_state.title = strdup(msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_LOAD_CONTENT_LIST));
browser_state.startdir = strdup([startdir UTF8String]);
2018-04-30 14:33:05 -04:00
2020-09-15 21:03:27 +02:00
result = browser->open(&browser_state);
open_document_handler(&browser_state, result);
2018-04-30 14:33:05 -04:00
2020-09-15 21:03:27 +02:00
free(browser_state.startdir);
free(browser_state.title);
}
}
2020-09-15 21:00:22 +02:00
- (void)unloadingCore { }
- (IBAction)showPreferences:(id)sender { }
- (IBAction)showCoresDirectory:(id)sender
{
2020-02-19 20:57:02 +01:00
settings_t *settings = config_get_ptr();
const char *path_dir_libretro = settings->paths.directory_libretro;
[[NSWorkspace sharedWorkspace] openFile:BOXSTRING(path_dir_libretro)];
}
- (IBAction)basicEvent:(id)sender
{
2020-09-15 21:00:22 +02:00
enum event_command cmd = CMD_EVENT_NONE;
unsigned sender_tag = (unsigned)[sender tag];
2018-04-30 14:33:05 -04:00
switch (sender_tag)
{
case 1:
2016-05-09 20:51:53 +02:00
cmd = CMD_EVENT_RESET;
break;
case 2:
2016-05-09 20:51:53 +02:00
cmd = CMD_EVENT_LOAD_STATE;
break;
case 3:
2016-05-09 20:51:53 +02:00
cmd = CMD_EVENT_SAVE_STATE;
break;
case 4:
2016-05-09 20:51:53 +02:00
cmd = CMD_EVENT_DISK_EJECT_TOGGLE;
break;
case 5:
2016-05-09 20:51:53 +02:00
cmd = CMD_EVENT_DISK_PREV;
break;
case 6:
2016-05-09 20:51:53 +02:00
cmd = CMD_EVENT_DISK_NEXT;
break;
case 7:
2016-05-09 20:51:53 +02:00
cmd = CMD_EVENT_GRAB_MOUSE_TOGGLE;
break;
case 8:
2016-05-09 20:51:53 +02:00
cmd = CMD_EVENT_MENU_TOGGLE;
break;
case 9:
2016-05-09 20:51:53 +02:00
cmd = CMD_EVENT_PAUSE_TOGGLE;
break;
case 20:
2016-05-09 20:51:53 +02:00
cmd = CMD_EVENT_FULLSCREEN_TOGGLE;
break;
default:
break;
}
2018-04-30 14:33:05 -04:00
if (sender_tag >= 10 && sender_tag <= 19)
{
unsigned idx = (sender_tag - (10-1));
2017-05-15 05:06:23 +02:00
rarch_ctl(RARCH_CTL_SET_WINDOWED_SCALE, &idx);
2016-05-09 20:51:53 +02:00
cmd = CMD_EVENT_RESIZE_WINDOWED_SCALE;
}
ui_companion_event_command(cmd);
}
- (void)alertDidEnd:(NSAlert *)alert returnCode:(int32_t)returnCode contextInfo:(void *)contextInfo
{
[[NSApplication sharedApplication] stopModal];
}
@end
int main(int argc, char *argv[])
{
2016-01-17 16:26:04 +01:00
if (argc == 2)
{
if (argv[1] != '\0')
if (!strncmp(argv[1], "-psn", 4))
argc = 1;
}
2018-04-30 14:33:05 -04:00
2015-07-25 15:45:22 +02:00
waiting_argc = argc;
waiting_argv = argv;
2016-01-17 15:55:30 +01:00
return NSApplicationMain(argc, (const char **) argv);
}
2015-04-20 12:43:07 +02:00
static void ui_companion_cocoa_deinit(void *data)
{
2020-09-15 20:45:42 +02:00
[[NSApplication sharedApplication] terminate:nil];
2015-04-20 12:43:07 +02:00
}
2020-09-15 20:45:42 +02:00
static void *ui_companion_cocoa_init(void) { return (void*)-1; }
2020-02-13 22:39:29 +01:00
static void ui_companion_cocoa_notify_content_loaded(void *data) { }
static void ui_companion_cocoa_toggle(void *data, bool force) { }
2020-09-15 20:45:42 +02:00
static void ui_companion_cocoa_event_command(void *data, enum event_command cmd) { }
static void ui_companion_cocoa_notify_list_pushed(void *data,
2020-02-13 22:39:29 +01:00
file_list_t *list, file_list_t *menu_list) { }
static void *ui_companion_cocoa_get_main_window(void *data)
{
return (BRIDGE void *)((RetroArch_OSX*)[[NSApplication sharedApplication] delegate]).window;
}
2018-04-30 14:33:05 -04:00
ui_companion_driver_t ui_companion_cocoa = {
2015-04-20 12:43:07 +02:00
ui_companion_cocoa_init,
ui_companion_cocoa_deinit,
ui_companion_cocoa_toggle,
ui_companion_cocoa_event_command,
ui_companion_cocoa_notify_content_loaded,
ui_companion_cocoa_notify_list_pushed,
NULL, /* notify_refresh */
NULL, /* msg_queue_push */
NULL, /* render_messagebox */
ui_companion_cocoa_get_main_window,
NULL, /* log_msg */
NULL, /* is_active */
&ui_browser_window_cocoa,
&ui_msg_window_cocoa,
2016-06-04 07:56:28 +02:00
&ui_window_cocoa,
2016-06-07 16:51:25 +02:00
&ui_application_cocoa,
2015-04-20 12:43:07 +02:00
"cocoa",
};