From 7c4329f31d1ff713dc0789969e98f9f5c3dcf74d Mon Sep 17 00:00:00 2001 From: neville Date: Mon, 6 May 2019 14:11:46 +0200 Subject: [PATCH] (OSX PPC) Buildfixes --- .../RetroArch_PPC.xcodeproj/project.pbxproj | 2 +- ui/drivers/cocoa/ui_cocoa_application.m | 4 + ui/drivers/cocoa/ui_cocoa_msg_window.m | 12 ++ ui/drivers/ui_cocoa.m | 111 +++++++++++------- 4 files changed, 87 insertions(+), 42 deletions(-) diff --git a/pkg/apple/RetroArch_PPC.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_PPC.xcodeproj/project.pbxproj index d9353f870a..d6dfcbade1 100644 --- a/pkg/apple/RetroArch_PPC.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_PPC.xcodeproj/project.pbxproj @@ -23,7 +23,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 7A868DD21AC85A8500B0EDDB /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = OSX/en.lproj/MainMenu.xib; sourceTree = SOURCE_ROOT; }; + 7A868DD21AC85A8500B0EDDB /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = OSX/en.lproj/MainMenu_PPC.xib; sourceTree = SOURCE_ROOT; }; 7A868DD41AC85A8500B0EDDB /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = OSX/en.lproj/Settings.xib; sourceTree = SOURCE_ROOT; }; 7ACC4C4F1AC864B800D67175 /* griffin_objc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = griffin_objc.m; path = ../../griffin/griffin_objc.m; sourceTree = SOURCE_ROOT; }; 7AEFCD861921295E00FB5B6A /* griffin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = griffin.c; path = ../../griffin/griffin.c; sourceTree = SOURCE_ROOT; }; diff --git a/ui/drivers/cocoa/ui_cocoa_application.m b/ui/drivers/cocoa/ui_cocoa_application.m index 14c67ad927..8e53ce1950 100644 --- a/ui/drivers/cocoa/ui_cocoa_application.m +++ b/ui/drivers/cocoa/ui_cocoa_application.m @@ -23,6 +23,10 @@ #include "cocoa_common.h" #include "../../ui_companion_driver.h" +#ifndef NSEventMaskAny +#define NSEventMaskAny NSAnyEventMask +#endif + static void* ui_application_cocoa_initialize(void) { return NULL; diff --git a/ui/drivers/cocoa/ui_cocoa_msg_window.m b/ui/drivers/cocoa/ui_cocoa_msg_window.m index 4cfa5c1a4b..9757dc695f 100644 --- a/ui/drivers/cocoa/ui_cocoa_msg_window.m +++ b/ui/drivers/cocoa/ui_cocoa_msg_window.m @@ -29,6 +29,18 @@ extern id apple_platform; #include "../../ui_companion_driver.h" +#ifndef NSAlertStyleCritical +#define NSAlertStyleCritical NSCriticalAlertStyle +#endif + +#ifndef NSAlertStyleWarning +#define NSAlertStyleWarning NSWarningAlertStyle +#endif + +#ifndef NSAlertStyleInformational +#define NSAlertStyleInformational NSInformationalAlertStyle +#endif + static enum ui_msg_window_response ui_msg_window_cocoa_dialog(ui_msg_window_state *state, enum ui_msg_window_type type) { #if defined(HAVE_COCOA_METAL) diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 78f5d81d5d..1498dcf1d4 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -105,6 +105,67 @@ static void app_terminate(void) @implementation RApplication #endif +#ifndef NSEventModifierFlagCapsLock +#define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask +#endif + +#ifndef NSEventModifierFlagShift +#define NSEventModifierFlagShift NSShiftKeyMask +#endif + +#ifndef NSEventModifierFlagControl +#define NSEventModifierFlagControl NSControlKeyMask +#endif + +#ifndef NSEventModifierFlagOption +#define NSEventModifierFlagOption NSAlternateKeyMask +#endif + +#ifndef NSEventModifierFlagCommand +#define NSEventModifierFlagCommand NSCommandKeyMask +#endif + +#ifndef NSEventModifierFlagNumericPad +#define NSEventModifierFlagNumericPad NSNumericPadKeyMask +#endif + +#ifndef NSEventTypeKeyDown +#define NSEventTypeKeyDown NSKeyDown +#endif + +#ifndef NSEventTypeKeyUp +#define NSEventTypeKeyUp NSKeyUp +#endif + +#ifndef NSEventTypeLeftMouseDragged +#define NSEventTypeLeftMouseDragged NSLeftMouseDragged +#endif + +#ifndef NSEventTypeRightMouseDragged +#define NSEventTypeRightMouseDragged NSRightMouseDragged +#endif + +#ifndef NSEventTypeOtherMouseDragged +#define NSEventTypeOtherMouseDragged NSOtherMouseDragged +#endif + +#ifndef NSEventTypeMouseMoved +#define NSEventTypeMouseMoved NSMouseMoved +#endif + +#ifndef NSEventTypeLeftMouseUp +#define NSEventTypeLeftMouseUp NSLeftMouseUp +#endif + +#ifndef NSEventTypeRightMouseUp +#define NSEventTypeRightMouseUp NSRightMouseUp +#endif + +#ifndef NSEventTypeOtherMouseUp +#define NSEventTypeOtherMouseUp NSOtherMouseUp +#endif + + - (void)sendEvent:(NSEvent *)event { [super sendEvent:event]; @@ -113,17 +174,12 @@ static void app_terminate(void) switch ((int32_t)event_type) { -#if defined(HAVE_COCOA_METAL) case NSEventTypeKeyDown: case NSEventTypeKeyUp: -#elif defined(HAVE_COCOA) - case NSKeyDown: - case NSKeyUp: -#endif { - NSString* ch = event.characters; + NSString* ch = event.characters; uint32_t character = 0; - uint32_t mod = 0; + uint32_t mod = 0; if (ch && ch.length != 0) { @@ -168,23 +224,19 @@ static void app_terminate(void) 0, event.modifierFlags, RETRO_DEVICE_KEYBOARD); } break; -#if defined(HAVE_COCOA_METAL) case NSEventTypeMouseMoved: case NSEventTypeLeftMouseDragged: case NSEventTypeRightMouseDragged: - case NSEventTypeOtherMouseDragged: -#elif defined(HAVE_COCOA) - case NSMouseMoved: - case NSLeftMouseDragged: - case NSRightMouseDragged: - case NSOtherMouseDragged: -#endif + case NSEventTypeOtherMouseDragged: { NSPoint pos; NSPoint mouse_pos; apple = (cocoa_input_data_t*)input_driver_get_data(); if (!apple) return; + + pos.x = 0; + pos.y = 0; /* Relative */ apple->mouse_rel_x = (int16_t)event.deltaX; @@ -214,29 +266,6 @@ static void app_terminate(void) #endif /* TODO/FIXME - properly implement. */ break; -#if defined(HAVE_COCOA_METAL) - case NSEventTypeLeftMouseDown: - case NSEventTypeRightMouseDown: - case NSEventTypeOtherMouseDown: -#elif defined(HAVE_COCOA) - case NSLeftMouseDown: - case NSRightMouseDown: - case NSOtherMouseDown: -#endif - { -#if defined(HAVE_COCOA_METAL) - NSPoint pos = [apple_platform.renderView convertPoint:[event locationInWindow] fromView:nil]; -#elif defined(HAVE_COCOA) - NSPoint pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil]; -#endif - apple = (cocoa_input_data_t*)input_driver_get_data(); - if (!apple || pos.y < 0) - return; - apple->mouse_buttons |= 1 << event.buttonNumber; - - apple->touch_count = 1; - } - break; case NSEventTypeLeftMouseUp: case NSEventTypeRightMouseUp: case NSEventTypeOtherMouseUp: @@ -499,11 +528,11 @@ static char** waiting_argv; - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames { - if (filenames.count == 1 && filenames[0]) + if ((filenames.count == 1) && [filenames objectAtIndex:0]) { struct retro_system_info *system = runloop_get_libretro_system_info(); - NSString *__core = filenames[0]; - const char *core_name = system ? system->library_name : NULL; + NSString *__core = [filenames objectAtIndex:0]; + const char *core_name = system->library_name; if (core_name) {