mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
(qb) Add COCOA
This commit is contained in:
parent
3637dc7af7
commit
2f169a42b1
8
Makefile
8
Makefile
@ -42,8 +42,9 @@ ifeq ($(DEBUG), 1)
|
||||
OPTIMIZE_FLAG = -O0
|
||||
endif
|
||||
|
||||
CFLAGS += -Wall $(OPTIMIZE_FLAG) $(INCLUDE_DIRS) $(DEBUG_FLAG) -I.
|
||||
CFLAGS += -Wall $(OPTIMIZE_FLAG) $(INCLUDE_DIRS) $(DEBUG_FLAG) -I.
|
||||
CXXFLAGS := $(CFLAGS) -std=c++0x -D__STDC_CONSTANT_MACROS
|
||||
OBJCFLAGS := $(CFLAGS) -D__STDC_CONSTANT_MACROS
|
||||
|
||||
ifeq ($(CXX_BUILD), 1)
|
||||
LINK = $(CXX)
|
||||
@ -102,6 +103,11 @@ $(OBJDIR)/%.o: %.cpp
|
||||
@$(if $(Q), $(shell echo echo CXX $<),)
|
||||
$(Q)$(CXX) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $<
|
||||
|
||||
$(OBJDIR)/%.o: %.m
|
||||
@mkdir -p $(dir $@)
|
||||
@$(if $(Q), $(shell echo echo CXX $<),)
|
||||
$(Q)$(CXX) $(OBJCFLAGS) $(DEFINES) -MMD -c -o $@ $<
|
||||
|
||||
.FORCE:
|
||||
|
||||
$(OBJDIR)/git_version.o: git_version.c .FORCE
|
||||
|
@ -754,6 +754,15 @@ ifeq ($(HAVE_COMPRESSION), 1)
|
||||
DEFINES += -DHAVE_COMPRESSION
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_COCOA),1)
|
||||
OBJ += apple/common/apple_cocoa_common.o \
|
||||
apple/OSX/platform.o \
|
||||
apple/OSX/settings.o \
|
||||
input/drivers/cocoa_input.o \
|
||||
input/drivers_keyboard/keyboard_event_apple.o \
|
||||
gfx/drivers_context/apple_cocoa_gl.o
|
||||
endif
|
||||
|
||||
|
||||
# Joyconfig binary
|
||||
JOYCONFIG_OBJ += tools/retroarch-joyconfig-griffin.o
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#import "../common/RetroArch_Apple.h"
|
||||
#import <objc/runtime.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
#include "../../settings.h"
|
||||
#include "../../input/drivers/cocoa_input.h"
|
||||
|
@ -30,7 +30,7 @@
|
||||
- (void)unloadingCore;
|
||||
@end
|
||||
|
||||
#ifdef IOS
|
||||
#if defined(HAVE_COCOATOUCH)
|
||||
#include <UIKit/UIKit.h>
|
||||
|
||||
#include <CoreLocation/CoreLocation.h>
|
||||
@ -183,7 +183,7 @@ extern apple_frontend_settings_t apple_frontend_settings;
|
||||
|
||||
void get_ios_version(int *major, int *minor);
|
||||
|
||||
#elif defined(OSX)
|
||||
#elif defined(HAVE_COCOA)
|
||||
#include <AppKit/AppKit.h>
|
||||
#ifdef HAVE_LOCATION
|
||||
#include <CoreLocation/CoreLocation.h>
|
||||
|
@ -99,7 +99,7 @@ void CFSearchPathForDirectoriesInDomains(unsigned flags,
|
||||
|
||||
void apple_display_alert(const char *message, const char *title)
|
||||
{
|
||||
#ifdef IOS
|
||||
#if defined(HAVE_COCOATOUCH)
|
||||
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:BOXSTRING(title)
|
||||
message:BOXSTRING(message)
|
||||
delegate:nil
|
||||
@ -159,7 +159,7 @@ void apple_display_alert(const char *message, const char *title)
|
||||
return YES;
|
||||
}
|
||||
|
||||
#ifdef IOS
|
||||
#if defined(HAVE_COCOATOUCH)
|
||||
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
|
||||
{
|
||||
NSString* text = (NSString*)[[textField text] stringByReplacingCharactersInRange:range withString:string];
|
||||
@ -186,7 +186,7 @@ void apple_display_alert(const char *message, const char *title)
|
||||
|
||||
static RAGameView* g_instance;
|
||||
|
||||
#ifdef OSX
|
||||
#if defined(HAVE_COCOA)
|
||||
void *nsview_get_ptr(void)
|
||||
{
|
||||
return g_instance;
|
||||
@ -210,9 +210,9 @@ void *glkitview_init(void);
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
#if defined(OSX)
|
||||
#if defined(HAVE_COCOA)
|
||||
[self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||
#elif defined(IOS)
|
||||
#elif defined(HAVE_COCOATOUCH)
|
||||
self.view = (__bridge GLKView*)glkitview_init();
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showPauseIndicator) name:UIApplicationWillEnterForegroundNotification object:nil];
|
||||
@ -221,7 +221,7 @@ void *glkitview_init(void);
|
||||
return self;
|
||||
}
|
||||
|
||||
#ifdef OSX
|
||||
#if defined(HAVE_COCOA)
|
||||
- (void)setFrame:(NSRect)frameRect
|
||||
{
|
||||
[super setFrame:frameRect];
|
||||
@ -244,7 +244,7 @@ void *glkitview_init(void);
|
||||
{
|
||||
}
|
||||
|
||||
#elif defined(IOS)
|
||||
#elif defined(HAVE_COCOATOUCH)
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
/* Pause Menus. */
|
||||
|
@ -17,12 +17,12 @@
|
||||
//#define HAVE_NSOPENGL
|
||||
|
||||
#include <CoreGraphics/CGGeometry.h>
|
||||
#if defined(OSX)
|
||||
#if defined(HAVE_COCOA)
|
||||
#include <OpenGL/CGLTypes.h>
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#include <AppKit/NSScreen.h>
|
||||
#include <AppKit/NSOpenGL.h>
|
||||
#elif defined(IOS)
|
||||
#elif defined(HAVE_COCOATOUCH)
|
||||
#include <GLKit/GLKit.h>
|
||||
#endif
|
||||
#import "../../apple/common/RetroArch_Apple.h"
|
||||
@ -31,7 +31,7 @@
|
||||
#include "../../configuration.h"
|
||||
#include "../../runloop.h"
|
||||
|
||||
#ifdef IOS
|
||||
#if defined(HAVE_COCOATOUCH)
|
||||
#define GLContextClass EAGLContext
|
||||
#define GLFrameworkID CFSTR("com.apple.opengles")
|
||||
#define RAScreen UIScreen
|
||||
@ -59,7 +59,7 @@
|
||||
#define RAScreen NSScreen
|
||||
#endif
|
||||
|
||||
#if defined(IOS)
|
||||
#if defined(HAVE_COCOATOUCH)
|
||||
#define ALMOST_INVISIBLE (.021f)
|
||||
static GLKView *g_view;
|
||||
static UIView *g_pause_indicator_view;
|
||||
@ -72,7 +72,7 @@ static int g_fast_forward_skips;
|
||||
static bool g_is_syncing = true;
|
||||
static bool g_use_hw_ctx;
|
||||
|
||||
#ifdef OSX
|
||||
#if defined(HAVE_COCOA)
|
||||
static bool g_has_went_fullscreen;
|
||||
static NSOpenGLPixelFormat* g_format;
|
||||
#endif
|
||||
@ -83,7 +83,7 @@ static unsigned g_major = 0;
|
||||
/* forward declaration */
|
||||
void *nsview_get_ptr(void);
|
||||
|
||||
#ifdef IOS
|
||||
#if defined(HAVE_COCOATOUCH)
|
||||
static void glkitview_init_xibs(void)
|
||||
{
|
||||
/* iOS Pause menu and lifecycle. */
|
||||
@ -94,7 +94,7 @@ static void glkitview_init_xibs(void)
|
||||
|
||||
void *glkitview_init(void)
|
||||
{
|
||||
#ifdef IOS
|
||||
#if defined(HAVE_COCOATOUCH)
|
||||
glkitview_init_xibs();
|
||||
|
||||
g_view = [GLKView new];
|
||||
@ -108,7 +108,7 @@ void *glkitview_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef IOS
|
||||
#if defined(HAVE_COCOATOUCH)
|
||||
void cocoagl_bind_game_view_fbo(void)
|
||||
{
|
||||
if (g_context)
|
||||
@ -118,7 +118,7 @@ void cocoagl_bind_game_view_fbo(void)
|
||||
|
||||
static RAScreen* get_chosen_screen(void)
|
||||
{
|
||||
#if defined(OSX) && !defined(MAC_OS_X_VERSION_10_6)
|
||||
#if defined(HAVE_COCOA) && !defined(MAC_OS_X_VERSION_10_6)
|
||||
return [RAScreen mainScreen];
|
||||
#else
|
||||
settings_t *settings = config_get_ptr();
|
||||
@ -135,7 +135,7 @@ static RAScreen* get_chosen_screen(void)
|
||||
|
||||
void cocoagl_gfx_ctx_update(void)
|
||||
{
|
||||
#ifdef OSX
|
||||
#if defined(HAVE_COCOA)
|
||||
#if MAC_OS_X_VERSION_10_7 && !defined(HAVE_NSOPENGL)
|
||||
CGLUpdateContext(g_context.CGLContextObj);
|
||||
#else
|
||||
@ -148,7 +148,7 @@ static bool cocoagl_gfx_ctx_init(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
#ifdef OSX
|
||||
#if defined(HAVE_COCOA)
|
||||
RAGameView *g_view = (RAGameView*)nsview_get_ptr();
|
||||
NSOpenGLPixelFormatAttribute attributes [] = {
|
||||
NSOpenGLPFAColorSize, 24,
|
||||
@ -198,9 +198,9 @@ static void cocoagl_gfx_ctx_destroy(void *data)
|
||||
|
||||
[GLContextClass clearCurrentContext];
|
||||
|
||||
#if defined(IOS)
|
||||
#if defined(HAVE_COCOATOUCH)
|
||||
g_view.context = nil;
|
||||
#elif defined(OSX)
|
||||
#elif defined(HAVE_COCOA)
|
||||
[g_context clearDrawable];
|
||||
if (g_context)
|
||||
[g_context release];
|
||||
@ -219,10 +219,10 @@ static void cocoagl_gfx_ctx_destroy(void *data)
|
||||
static bool cocoagl_gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
{
|
||||
(void)data;
|
||||
#if defined(IOS)
|
||||
#if defined(HAVE_COCOATOUCH)
|
||||
if (api != GFX_CTX_OPENGL_ES_API)
|
||||
return false;
|
||||
#elif defined(OSX)
|
||||
#elif defined(HAVE_COCOA)
|
||||
if (api != GFX_CTX_OPENGL_API)
|
||||
return false;
|
||||
#endif
|
||||
@ -236,11 +236,11 @@ static bool cocoagl_gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned
|
||||
static void cocoagl_gfx_ctx_swap_interval(void *data, unsigned interval)
|
||||
{
|
||||
(void)data;
|
||||
#ifdef IOS // < No way to disable Vsync on iOS?
|
||||
#if defined(HAVE_COCOATOUCH) // < No way to disable Vsync on iOS?
|
||||
// Just skip presents so fast forward still works.
|
||||
g_is_syncing = interval ? true : false;
|
||||
g_fast_forward_skips = interval ? 0 : 3;
|
||||
#elif defined(OSX)
|
||||
#elif defined(HAVE_COCOA)
|
||||
GLint value = interval ? 1 : 0;
|
||||
#ifdef HAVE_NSOPENGL
|
||||
[g_context setValues:&value forParameter:NSOpenGLCPSwapInterval];
|
||||
@ -253,7 +253,7 @@ static void cocoagl_gfx_ctx_swap_interval(void *data, unsigned interval)
|
||||
|
||||
static bool cocoagl_gfx_ctx_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen)
|
||||
{
|
||||
#ifdef OSX
|
||||
#if defined(HAVE_COCOA)
|
||||
RAGameView *g_view = (RAGameView*)nsview_get_ptr();
|
||||
/* TODO: Screen mode support. */
|
||||
|
||||
@ -315,7 +315,7 @@ static void cocoagl_gfx_ctx_get_video_size(void *data, unsigned* width, unsigned
|
||||
CGRect size = screen.bounds;
|
||||
float screenscale = cocoagl_gfx_ctx_get_native_scale();
|
||||
|
||||
#if defined(OSX)
|
||||
#if defined(HAVE_COCOA)
|
||||
RAGameView *g_view = (RAGameView*)nsview_get_ptr();
|
||||
CGRect cgrect = NSRectToCGRect([g_view frame]);
|
||||
size = CGRectMake(0, 0, CGRectGetWidth(cgrect), CGRectGetHeight(cgrect));
|
||||
@ -336,7 +336,7 @@ static void cocoagl_gfx_ctx_update_window_title(void *data)
|
||||
|
||||
(void)got_text;
|
||||
|
||||
#ifdef OSX
|
||||
#if defined(HAVE_COCOA)
|
||||
RAGameView *g_view = (RAGameView*)nsview_get_ptr();
|
||||
static const char* const text = buf; /* < Can't access buffer directly in the block */
|
||||
if (got_text)
|
||||
@ -349,7 +349,7 @@ static void cocoagl_gfx_ctx_update_window_title(void *data)
|
||||
static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types type,
|
||||
float *value)
|
||||
{
|
||||
#ifdef OSX
|
||||
#if defined(HAVE_COCOA)
|
||||
RAScreen *screen = [RAScreen mainScreen];
|
||||
NSDictionary *description = [screen deviceDescription];
|
||||
NSSize display_pixel_size = [[description objectForKey:NSDeviceSize] sizeValue];
|
||||
@ -360,7 +360,7 @@ static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types ty
|
||||
float display_height = display_pixel_size.height;
|
||||
float physical_width = display_physical_size.width;
|
||||
float physical_height = display_physical_size.height;
|
||||
#elif defined(IOS)
|
||||
#elif defined(HAVE_COCOATOUCH)
|
||||
float scale = cocoagl_gfx_ctx_get_native_scale();
|
||||
CGRect screen_rect = [[UIScreen mainScreen] bounds];
|
||||
|
||||
@ -396,7 +396,7 @@ static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types ty
|
||||
static bool cocoagl_gfx_ctx_has_focus(void *data)
|
||||
{
|
||||
(void)data;
|
||||
#ifdef IOS
|
||||
#if defined(HAVE_COCOATOUCH)
|
||||
return ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive);
|
||||
#else
|
||||
return [NSApp isActive];
|
||||
@ -415,7 +415,7 @@ static bool cocoagl_gfx_ctx_has_windowed(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
#ifdef IOS
|
||||
#if defined(HAVE_COCOATOUCH)
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
@ -427,14 +427,14 @@ static void cocoagl_gfx_ctx_swap_buffers(void *data)
|
||||
if (!(--g_fast_forward_skips < 0))
|
||||
return;
|
||||
|
||||
#if defined(OSX)
|
||||
#if defined(HAVE_COCOA)
|
||||
#ifdef HAVE_NSOPENGL
|
||||
[g_context flushBuffer];
|
||||
#else
|
||||
if (g_context.CGLContextObj)
|
||||
CGLFlushDrawable(g_context.CGLContextObj);
|
||||
#endif
|
||||
#elif defined(IOS)
|
||||
#elif defined(HAVE_COCOATOUCH)
|
||||
if (g_view)
|
||||
[g_view display];
|
||||
#endif
|
||||
|
@ -202,6 +202,8 @@ check_lib COREAUDIO "-framework AudioUnit" AudioUnitInitialize
|
||||
|
||||
check_lib CORETEXT "-framework CoreText" CTFontCreateWithName
|
||||
|
||||
check_lib COCOA "-framework AppKit" NSApplicationMain
|
||||
|
||||
check_pkgconf SDL sdl 1.2.10
|
||||
check_pkgconf SDL2 sdl2 2.0.0
|
||||
|
||||
@ -369,6 +371,6 @@ add_define_make OS "$OS"
|
||||
|
||||
# Creates config.mk and config.h.
|
||||
add_define_make GLOBAL_CONFIG_DIR "$GLOBAL_CONFIG_DIR"
|
||||
VARS="RGUI LAKKA GLUI XMB ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO CORETEXT PULSE SDL SDL2 D3D9 DINPUT LIBUSB XINPUT DSOUND XAUDIO OPENGL EXYNOS DISPMANX SUNXI OMAP GLES GLES3 VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG LIBXML2 ZLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE FREETYPE XKBCOMMON XVIDEO X11 XEXT XF86VM XINERAMA WAYLAND MALI_FBDEV VIVANTE_FBDEV NETWORKING NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL STRCASESTR MMAP PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 BSV_MOVIE VIDEOCORE NEON FLOATHARD FLOATSOFTFP UDEV V4L2 AV_CHANNEL_LAYOUT 7ZIP PARPORT"
|
||||
VARS="RGUI LAKKA GLUI XMB ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO CORETEXT PULSE SDL SDL2 D3D9 DINPUT LIBUSB XINPUT DSOUND XAUDIO OPENGL EXYNOS DISPMANX SUNXI OMAP GLES GLES3 VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG LIBXML2 ZLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE FREETYPE XKBCOMMON XVIDEO X11 XEXT XF86VM XINERAMA WAYLAND MALI_FBDEV VIVANTE_FBDEV NETWORKING NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL STRCASESTR MMAP PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 BSV_MOVIE VIDEOCORE NEON FLOATHARD FLOATSOFTFP UDEV V4L2 AV_CHANNEL_LAYOUT 7ZIP PARPORT COCOA"
|
||||
create_config_make config.mk $VARS
|
||||
create_config_header config.h $VARS
|
||||
|
Loading…
x
Reference in New Issue
Block a user