Merge pull request #10981 from yoshisuga/yoshisuga/ios-metal

iOS/tvOS Metal Renderer
This commit is contained in:
Autechre 2020-07-21 20:41:07 +02:00 committed by GitHub
commit 6c7143d02d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 2053 additions and 266 deletions

View File

@ -408,10 +408,10 @@ static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_AUDIOIO;
static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_OSS;
#elif defined(HAVE_JACK)
static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_JACK;
#elif defined(HAVE_COREAUDIO) && !defined(HAVE_COCOA_METAL)
static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_COREAUDIO;
#elif defined(HAVE_COREAUDIO3)
static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_COREAUDIO3;
#elif defined(HAVE_COREAUDIO)
static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_COREAUDIO;
#elif defined(HAVE_XAUDIO)
static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_XAUDIO;
#elif defined(HAVE_DSOUND)

View File

@ -9,6 +9,7 @@
#import "Context.h"
#import "Filter.h"
#import <QuartzCore/QuartzCore.h>
#import "metal_common.h"
@interface BufferNode : NSObject
@property (nonatomic, readonly) id<MTLBuffer> src;
@ -174,6 +175,8 @@
{
#if TARGET_OS_OSX
return _layer.displaySyncEnabled;
#else
return NO;
#endif
}
@ -759,15 +762,9 @@ static const NSUInteger kConstantAlignment = 4;
- (bool)allocRange:(BufferRange *)range length:(NSUInteger)length
{
MTLResourceOptions opts;
opts = PLATFORM_METAL_RESOURCE_STORAGE_MODE;
memset(range, 0, sizeof(*range));
#if TARGET_OS_OSX
opts = MTLResourceStorageModeManaged;
#else
opts = MTLResourceStorageModeShared;
#endif
if (!_head)
{
_head = [[BufferNode alloc] initWithBuffer:[_device newBufferWithLength:_blockLen options:opts]];

View File

@ -5,7 +5,7 @@
#import "Context.h"
#import "MenuDisplay.h"
#import "ShaderTypes.h"
#import "menu_driver.h"
#include "../../../menu/menu_driver.h"
#import <Metal/Metal.h>
/* TODO(sgc): this dependency is incorrect */
#import "../metal_common.h"

View File

@ -23,9 +23,14 @@
- (NSString *)debugDescription
{
#if defined(HAVE_COCOATOUCH)
NSString *sizeDesc = [NSString stringWithFormat:@"width: %f, height: %f",_size.width,_size.height];
#else
NSString *sizeDesc = NSStringFromSize(_size);
#endif
return [NSString stringWithFormat:@"( format = %@, frame = %@ )",
NSStringFromRPixelFormat(_format),
NSStringFromSize(_size)];
sizeDesc];
}
@end

View File

@ -28,6 +28,12 @@
#include "../../config.h"
#endif
#ifdef HAVE_COCOATOUCH
#define PLATFORM_METAL_RESOURCE_STORAGE_MODE MTLResourceStorageModeShared
#else
#define PLATFORM_METAL_RESOURCE_STORAGE_MODE MTLResourceStorageModeManaged
#endif
RETRO_BEGIN_DECLS
extern MTLPixelFormat glslang_format_to_metal(glslang_format fmt);

View File

@ -25,7 +25,7 @@
#import <gfx/video_frame.h>
#import "metal_common.h"
#import "Context.h"
#include "metal/Context.h"
#include "../../ui/drivers/cocoa/cocoa_common.h"
@ -53,9 +53,11 @@
@implementation MetalView
#if !defined(HAVE_COCOATOUCH)
- (void)keyDown:(NSEvent*)theEvent
{
}
#endif
/* Stop the annoying sound when pressing a key. */
- (BOOL)acceptsFirstResponder
@ -500,7 +502,13 @@
- (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size
{
NSLog(@"mtkView drawableSizeWillChange to: %f x %f",size.width,size.height);
#ifdef HAVE_COCOATOUCH
CGFloat scale = [[UIScreen mainScreen] scale];
[self setViewportWidth:(unsigned int)view.bounds.size.width*scale height:(unsigned int)view.bounds.size.height*scale forceFull:NO allowRotate:YES];
#else
[self setViewportWidth:(unsigned int)size.width height:(unsigned int)size.height forceFull:NO allowRotate:YES];
#endif
}
- (void)drawInMTKView:(MTKView *)view
@ -693,7 +701,11 @@ typedef struct MTLALIGN(16)
switch (i)
{
case RARCH_WRAP_BORDER:
#if defined(HAVE_COCOATOUCH)
sd.sAddressMode = MTLSamplerAddressModeClampToZero;
#else
sd.sAddressMode = MTLSamplerAddressModeClampToBorderColor;
#endif
break;
case RARCH_WRAP_EDGE:
@ -1023,7 +1035,9 @@ typedef struct MTLALIGN(16)
if (buffer_sem->stage_mask & SLANG_STAGE_FRAGMENT_MASK)
[rce setFragmentBuffer:buffer offset:0 atIndex:buffer_sem->binding];
#if !defined(HAVE_COCOATOUCH)
[buffer didModifyRange:NSMakeRange(0, buffer.length)];
#endif
}
}
@ -1356,7 +1370,7 @@ typedef struct MTLALIGN(16)
if (size == 0)
continue;
id<MTLBuffer> buf = [_context.device newBufferWithLength:size options:MTLResourceStorageModeManaged];
id<MTLBuffer> buf = [_context.device newBufferWithLength:size options:PLATFORM_METAL_RESOURCE_STORAGE_MODE];
STRUCT_ASSIGN(_engine.pass[i].buffers[j], buf);
}
} @finally
@ -1472,7 +1486,7 @@ typedef struct MTLALIGN(16)
NSUInteger needed = sizeof(SpriteVertex) * count * 4;
if (!_vert || _vert.length < needed)
{
_vert = [_context.device newBufferWithLength:needed options:MTLResourceStorageModeManaged];
_vert = [_context.device newBufferWithLength:needed options:PLATFORM_METAL_RESOURCE_STORAGE_MODE];
}
for (NSUInteger i = 0; i < count; i++)
@ -1490,11 +1504,13 @@ typedef struct MTLALIGN(16)
- (void)drawWithEncoder:(id<MTLRenderCommandEncoder>)rce
{
#if !defined(HAVE_COCOATOUCH)
if (_vertDirty)
{
[_vert didModifyRange:NSMakeRange(0, _vert.length)];
_vertDirty = NO;
}
#endif
NSUInteger count = _images.count;
for (NSUInteger i = 0; i < count; ++i)

View File

@ -23,7 +23,7 @@
#else
#include <ApplicationServices/ApplicationServices.h>
#endif
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
#include <OpenGL/CGLTypes.h>
#include <OpenGL/OpenGL.h>
#include <AppKit/NSScreen.h>
@ -103,7 +103,7 @@ void *nsview_get_ptr(void)
video_driver_display_type_set(RARCH_DISPLAY_OSX);
video_driver_display_set(0);
video_driver_display_userdata_set((uintptr_t)g_instance);
#elif defined(HAVE_COCOA_METAL)
#elif defined(HAVE_COCOA_METAL) && !defined(HAVE_COCOATOUCH)
video_driver_display_type_set(RARCH_DISPLAY_OSX);
video_driver_display_set(0);
video_driver_display_userdata_set((uintptr_t)g_instance);
@ -116,7 +116,7 @@ void nsview_set_ptr(CocoaView *p)
g_instance = p;
}
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
static NSOpenGLPixelFormat* g_format;
void *glcontext_get_ptr(void)
@ -240,7 +240,7 @@ float get_backing_scale_factor(void)
return backing_scale_def;
backing_scale_def = 1.0f;
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
screen = (BRIDGE RAScreen*)get_chosen_screen();
if (screen)
@ -269,7 +269,7 @@ void cocoagl_gfx_ctx_update(void)
{
case GFX_CTX_OPENGL_API:
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_OPENGL_CORE)
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
#if MAC_OS_X_VERSION_10_7
CGLUpdateContext(g_hw_ctx.CGLContextObj);
CGLUpdateContext(g_context.CGLContextObj);
@ -299,7 +299,7 @@ static void cocoagl_gfx_ctx_destroy(void *data)
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_OPENGL_CORE)
[GLContextClass clearCurrentContext];
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
[g_context clearDrawable];
RELEASE(g_context);
RELEASE(g_format);
@ -340,7 +340,7 @@ static void cocoagl_gfx_ctx_show_mouse(void *data, bool state)
{
(void)data;
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
if (state)
[NSCursor unhide];
else
@ -369,7 +369,7 @@ float cocoagl_gfx_ctx_get_native_scale(void)
return ret;
}
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
static void cocoagl_gfx_ctx_update_title(void *data)
{
const ui_window_t *window = ui_companion_driver_get_window_ptr();
@ -392,7 +392,7 @@ static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types ty
float *value)
{
RAScreen *screen = (BRIDGE RAScreen*)get_chosen_screen();
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
NSDictionary *description = [screen deviceDescription];
NSSize display_pixel_size = [[description objectForKey:NSDeviceSize] sizeValue];
CGSize display_physical_size = CGDisplayScreenSize(
@ -482,7 +482,7 @@ static void cocoagl_gfx_ctx_input_driver(void *data,
static void cocoagl_gfx_ctx_get_video_size(void *data, unsigned* width, unsigned* height)
{
float screenscale = cocoagl_gfx_ctx_get_native_scale();
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
CGRect size, cgrect;
GLsizei backingPixelWidth, backingPixelHeight;
#if defined(HAVE_COCOA_METAL)
@ -630,7 +630,7 @@ static void cocoagl_gfx_ctx_swap_buffers(void *data)
if (!(--g_fast_forward_skips < 0))
return;
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
[g_context flushBuffer];
[g_hw_ctx flushBuffer];
#elif defined(HAVE_COCOATOUCH)
@ -699,12 +699,12 @@ static void *cocoagl_gfx_ctx_get_context_data(void *data)
static bool cocoagl_gfx_ctx_set_video_mode(void *data,
unsigned width, unsigned height, bool fullscreen)
{
#if defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && defined(HAVE_COCOA_METAL)
NSView *g_view = apple_platform.renderView;
#elif defined(HAVE_COCOA)
CocoaView *g_view = (CocoaView*)nsview_get_ptr();
#endif
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data;
cocoa_ctx->width = width;
cocoa_ctx->height = height;
@ -715,7 +715,7 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data,
case GFX_CTX_OPENGL_API:
case GFX_CTX_OPENGL_ES_API:
{
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
if ([g_view respondsToSelector: @selector(setWantsBestResolutionOpenGLSurface:)])
[g_view setWantsBestResolutionOpenGLSurface:YES];
@ -791,7 +791,7 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data,
break;
}
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
static bool has_went_fullscreen = false;
/* TODO: Screen mode support. */
@ -839,6 +839,10 @@ static void *cocoagl_gfx_ctx_init(void *video_driver)
{
#if defined(HAVE_COCOATOUCH)
case GFX_CTX_OPENGL_ES_API:
#if defined(HAVE_COCOA_METAL)
// the metal build supports both the OpenGL and Metal video drivers
[apple_platform setViewType:APPLE_VIEW_TYPE_OPENGL_ES];
#endif
// setViewType is not (yet?) defined for iOS
// [apple_platform setViewType:APPLE_VIEW_TYPE_OPENGL_ES];
break;
@ -921,7 +925,7 @@ const gfx_ctx_driver_t gfx_ctx_cocoagl = {
NULL, /* get_video_output_next */
cocoagl_gfx_ctx_get_metrics,
NULL, /* translate_aspect */
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
cocoagl_gfx_ctx_update_title,
#else
NULL, /* update_title */

View File

@ -79,19 +79,20 @@
{
_buffer = [_context.device newBufferWithBytes:_atlas->buffer
length:(NSUInteger)(_stride * _atlas->height)
options:MTLResourceStorageModeManaged];
options:PLATFORM_METAL_RESOURCE_STORAGE_MODE];
/* Even though newBufferWithBytes will copy the initial contents
* from our atlas, it doesn't seem to invalidate the buffer when
* doing so, causing corrupted text rendering if we hit this code
* path. To work around it we manually invalidate the buffer.
*/
// Even though newBufferWithBytes will copy the initial contents
// from our atlas, it doesn't seem to invalidate the buffer when
// doing so, causing corrupted text rendering if we hit this code
// path. To work around it we manually invalidate the buffer.
#if !defined(HAVE_COCOATOUCH)
[_buffer didModifyRange:NSMakeRange(0, _buffer.length)];
#endif
}
else
{
_buffer = [_context.device newBufferWithLength:(NSUInteger)(_stride * _atlas->height)
options:MTLResourceStorageModeManaged];
options:PLATFORM_METAL_RESOURCE_STORAGE_MODE];
void *dst = _buffer.contents;
void *src = _atlas->buffer;
for (unsigned i = 0; i < _atlas->height; i++)
@ -100,7 +101,9 @@
dst += _stride;
src += _atlas->width;
}
[_buffer didModifyRange:NSMakeRange(0, _buffer.length)];
#if !defined(HAVE_COCOATOUCH)
[_buffer didModifyRange:NSMakeRange(0, _buffer.length)];
#endif
}
MTLTextureDescriptor *td = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatR8Unorm
@ -112,7 +115,7 @@
_capacity = 12000;
_vert = [_context.device newBufferWithLength:sizeof(SpriteVertex) *
_capacity options:MTLResourceStorageModeManaged];
_capacity options:PLATFORM_METAL_RESOURCE_STORAGE_MODE];
if (![self _initializeState])
{
return nil;
@ -182,7 +185,9 @@
NSUInteger offset = glyph->atlas_offset_y;
NSUInteger len = glyph->height * _stride;
#if !defined(HAVE_COCOATOUCH)
[_buffer didModifyRange:NSMakeRange(offset, len)];
#endif
_atlas->dirty = false;
}
@ -325,7 +330,9 @@ static INLINE void write_quad6(SpriteVertex *pv,
- (void)_flush
{
NSUInteger start = _offset * sizeof(SpriteVertex);
#if !defined(HAVE_COCOATOUCH)
[_vert didModifyRange:NSMakeRange(start, sizeof(SpriteVertex) * _vertices)];
#endif
id<MTLRenderCommandEncoder> rce = _context.rce;
[rce pushDebugGroup:@"render fonts"];

View File

@ -304,7 +304,7 @@ float gfx_display_get_dpi_scale_internal(unsigned width, unsigned height)
* unfortunate, and needs to be fixed at the gfx context driver
* level. Until this is done, all we can do is fallback to using
* the old legacy 'magic number' scaling on Mac platforms. */
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
if (true)
{
scale = (diagonal_pixels / 6.5f) / 212.0f;

View File

@ -33,15 +33,10 @@
#include "../gfx/drivers_context/cocoa_gl_ctx.m"
#if defined(HAVE_COCOATOUCH)
#if TARGET_OS_IOS
#include "../ui/drivers/cocoa/cocoatouch_menu.m"
#endif
#include "../ui/drivers/ui_cocoatouch.m"
#else
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
#include "../ui/drivers/cocoa/ui_cocoa_window.m"
#include "../ui/drivers/cocoa/ui_cocoa_browser_window.m"
#include "../ui/drivers/cocoa/ui_cocoa_application.m"

View File

@ -339,10 +339,10 @@ static int16_t apple_gamecontroller_joypad_button(
if (port >= DEFAULT_MAX_PADS)
return 0;
/* Check hat. */
else if (GET_HAT_DIR(i))
else if (GET_HAT_DIR(joykey))
return 0;
else if (i < 32)
return ((mfi_buttons[port] & (1 << i)) != 0);
else if (joykey < 32)
return ((mfi_buttons[port] & (1 << joykey)) != 0);
return 0;
}
@ -407,7 +407,7 @@ static int16_t apple_gamecontroller_joypad_state(
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(apple_gamecontroller_joypad_axis(pad, joyaxis))
((float)abs(apple_gamecontroller_joypad_axis(port, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -694,7 +694,6 @@
"-DHAVE_SHADERPIPELINE",
"-D_LZMA_UINT32_IS_ULONG",
"-DHAVE_MFI",
"-DHAVE_BTSTACK",
"-DHAVE_KEYMAPPER",
);
PRODUCT_BUNDLE_IDENTIFIER = com.libretro.dist.ios.RetroArch;
@ -798,7 +797,6 @@
"-DHAVE_SHADERPIPELINE",
"-D_LZMA_UINT32_IS_ULONG",
"-DHAVE_MFI",
"-DHAVE_BTSTACK",
"-DHAVE_KEYMAPPER",
);
PRODUCT_BUNDLE_IDENTIFIER = com.libretro.dist.ios.RetroArch;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:/Users/yoshi/Code/personal/RetroArch-yoshi/pkg/apple/RetroArch_iOS11_Metal.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>6D7FAF49-495D-480E-B0C9-8C39AC77CE3C</string>
<key>IDESourceControlProjectName</key>
<string>RetroArch_iOS</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>6B9F0B13E5864452B91F13C09B7ED9EB989E82AD</key>
<string>https://github.com/libretro/retroarch-joypad-autoconfig.git</string>
<key>76200F0D6584D865E96F58DE862E738E88B23A3C</key>
<string>https://github.com/libretro/libretro-super.git</string>
<key>A267D9543F572B4C32EC6E1B876E3B9BFE4DE8F6</key>
<string>https://github.com/libretro/retroarch-assets.git</string>
<key>C3AEE01BDA902108663DB5DB9CD7916436919463</key>
<string>https://github.com/libretro/libretro-database.git</string>
<key>C7C12374C7051F8843B3EFA1ACCAF2907102CCF7</key>
<string>https://github.com/libretro/RetroArch.git</string>
<key>EF363D58F01B3FB341FA6C851870E60E4F080E97</key>
<string>https://github.com/libretro/common-overlays.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>apple/iOS/RetroArch_iOS.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>6B9F0B13E5864452B91F13C09B7ED9EB989E82AD</key>
<string>../../../..media/autoconfig</string>
<key>76200F0D6584D865E96F58DE862E738E88B23A3C</key>
<string>../../../../..</string>
<key>A267D9543F572B4C32EC6E1B876E3B9BFE4DE8F6</key>
<string>../../../..media/assets</string>
<key>C3AEE01BDA902108663DB5DB9CD7916436919463</key>
<string>../../../..media/libretrodb</string>
<key>C7C12374C7051F8843B3EFA1ACCAF2907102CCF7</key>
<string>../../../..</string>
<key>EF363D58F01B3FB341FA6C851870E60E4F080E97</key>
<string>../../../..media/overlays</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/libretro/RetroArch.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>C7C12374C7051F8843B3EFA1ACCAF2907102CCF7</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>76200F0D6584D865E96F58DE862E738E88B23A3C</string>
<key>IDESourceControlWCCName</key>
<string></string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>A267D9543F572B4C32EC6E1B876E3B9BFE4DE8F6</string>
<key>IDESourceControlWCCName</key>
<string>assets</string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>6B9F0B13E5864452B91F13C09B7ED9EB989E82AD</string>
<key>IDESourceControlWCCName</key>
<string>autoconfig</string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>C3AEE01BDA902108663DB5DB9CD7916436919463</string>
<key>IDESourceControlWCCName</key>
<string>libretrodb</string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>EF363D58F01B3FB341FA6C851870E60E4F080E97</string>
<key>IDESourceControlWCCName</key>
<string>overlays</string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>C7C12374C7051F8843B3EFA1ACCAF2907102CCF7</string>
<key>IDESourceControlWCCName</key>
<string>retroarch</string>
</dict>
</array>
</dict>
</plist>

View File

@ -0,0 +1,30 @@
{
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "C7C12374C7051F8843B3EFA1ACCAF2907102CCF7",
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
"76200F0D6584D865E96F58DE862E738E88B23A3C" : 9223372036854775807,
"C7C12374C7051F8843B3EFA1ACCAF2907102CCF7" : 9223372036854775807
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "8BA6E269-73BB-4AAE-8F4A-967CCF8ACA14",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"76200F0D6584D865E96F58DE862E738E88B23A3C" : "",
"C7C12374C7051F8843B3EFA1ACCAF2907102CCF7" : "retroarch\/"
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "RetroArch_iOS10",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "pkg\/apple\/RetroArch_iOS10.xcodeproj",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/libretro\/libretro-super.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "76200F0D6584D865E96F58DE862E738E88B23A3C"
},
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/libretro\/RetroArch.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "C7C12374C7051F8843B3EFA1ACCAF2907102CCF7"
}
]
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "926C77D621FD1E6500103EDE"
BuildableName = "RetroArchTV.app"
BlueprintName = "RetroArchTV"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "926C77D621FD1E6500103EDE"
BuildableName = "RetroArchTV.app"
BlueprintName = "RetroArchTV"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "926C77D621FD1E6500103EDE"
BuildableName = "RetroArchTV.app"
BlueprintName = "RetroArchTV"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "926C77D621FD1E6500103EDE"
BuildableName = "RetroArchTV.app"
BlueprintName = "RetroArchTV"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "926C77D621FD1E6500103EDE"
BuildableName = "RetroArchTV.app"
BlueprintName = "RetroArchTV"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "926C77D621FD1E6500103EDE"
BuildableName = "RetroArchTV.app"
BlueprintName = "RetroArchTV"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "926C77D621FD1E6500103EDE"
BuildableName = "RetroArchTV.app"
BlueprintName = "RetroArchTV"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "926C77D621FD1E6500103EDE"
BuildableName = "RetroArchTV.app"
BlueprintName = "RetroArchTV"
ReferencedContainer = "container:RetroArch_iOS11_Metal.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -1005,11 +1005,8 @@ static const ui_companion_driver_t *ui_companion_drivers[] = {
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
&ui_companion_win32,
#endif
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
&ui_companion_cocoa,
#endif
#ifdef HAVE_COCOATOUCH
&ui_companion_cocoatouch,
#endif
&ui_companion_null,
NULL
@ -33002,7 +32999,6 @@ bool video_driver_translate_coord_viewport(
int norm_vp_height = (int)vp->height;
int norm_full_vp_width = (int)vp->full_width;
int norm_full_vp_height = (int)vp->full_height;
if (norm_vp_width <= 0 ||
norm_vp_height <= 0 ||
norm_full_vp_width <= 0 ||
@ -33040,7 +33036,6 @@ bool video_driver_translate_coord_viewport(
*res_y = scaled_y;
*res_screen_x = scaled_screen_x;
*res_screen_y = scaled_screen_y;
return true;
}

View File

@ -1,10 +1,14 @@
#ifndef COCOA_APPLE_PLATFORM_H
#define COCOA_APPLE_PLATFORM_H
#if defined(HAVE_COCOA_METAL)
#if defined(HAVE_COCOA_METAL) || defined(HAVE_COCOATOUCH)
#ifdef HAVE_COCOA_METAL
#import <Metal/Metal.h>
#import <MetalKit/MetalKit.h>
#endif
#if !defined(HAVE_COCOATOUCH)
@interface WindowListener : NSResponder<NSWindowDelegate>
@end
@ -22,6 +26,7 @@
}
@end
#endif
@protocol ApplePlatform
@ -48,6 +53,31 @@
extern id<ApplePlatform> apple_platform;
id<ApplePlatform> apple_platform;
#if defined(HAVE_COCOATOUCH)
@interface RetroArch_iOS : UINavigationController<ApplePlatform, UIApplicationDelegate,
UINavigationControllerDelegate> {
UIView *_renderView;
apple_view_type_t _vt;
}
@property (nonatomic) UIWindow* window;
@property (nonatomic) NSString* documentsDirectory;
@property (nonatomic) RAMenuBase* mainmenu;
@property (nonatomic) int menu_count;
+ (RetroArch_iOS*)get;
- (void)showGameView;
- (void)toggleUI;
- (void)supportOtherAudioSessions;
- (void)refreshSystemConfig;
- (void)mainMenuPushPop: (bool)pushp;
- (void)mainMenuRefresh;
@end
#else
@interface RetroArch_OSX : NSObject<ApplePlatform, NSApplicationDelegate> {
NSWindow *_window;
apple_view_type_t _vt;
@ -55,6 +85,8 @@ id<ApplePlatform> apple_platform;
id _sleepActivity;
WindowListener *_listener;
}
#endif
#elif defined(HAVE_COCOA)
id apple_platform;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
@ -67,7 +99,7 @@ id apple_platform;
}
#endif
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
@property(nonatomic, retain) NSWindow IBOutlet *window;
@end

View File

@ -57,6 +57,7 @@ typedef enum apple_view_type {
#import <GameController/GameController.h>
#endif
/*********************************************/
/* RAMenuBase */
/* A menu class that displays RAMenuItemBase */
@ -81,25 +82,6 @@ typedef enum apple_view_type {
+ (CocoaView*)get;
@end
@interface RetroArch_iOS : UINavigationController<UIApplicationDelegate,
UINavigationControllerDelegate>
@property (nonatomic) UIWindow* window;
@property (nonatomic) NSString* documentsDirectory;
@property (nonatomic) RAMenuBase* mainmenu;
@property (nonatomic) int menu_count;
+ (RetroArch_iOS*)get;
- (void)showGameView;
- (void)toggleUI;
- (void)supportOtherAudioSessions;
- (void)refreshSystemConfig;
- (void)mainMenuPushPop: (bool)pushp;
- (void)mainMenuRefresh;
@end
void get_ios_version(int *major, int *minor);
#endif
@ -112,7 +94,7 @@ typedef struct
} apple_frontend_settings_t;
extern apple_frontend_settings_t apple_frontend_settings;
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
#include <AppKit/AppKit.h>
@interface CocoaView : NSView

View File

@ -29,6 +29,7 @@
#ifdef HAVE_COCOATOUCH
#import "GCDWebUploader.h"
#import "WebServer.h"
#include "apple_platform.h"
#endif
@ -46,13 +47,13 @@ void *glkitview_init(void);
@implementation CocoaView
#if defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && defined(HAVE_COCOA_METAL)
- (BOOL)layer:(CALayer *)layer shouldInheritContentsScale:(CGFloat)newScale fromWindow:(NSWindow *)window {
return YES;
}
#endif
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
- (void)scrollWheel:(NSEvent *)theEvent {
cocoa_input_data_t *apple = (cocoa_input_data_t*)input_driver_get_data();
(void)apple;
@ -74,7 +75,7 @@ void *glkitview_init(void);
{
self = [super init];
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
[self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
#endif
@ -83,10 +84,14 @@ void *glkitview_init(void);
cocoa_view.data = (CocoaView*)self;
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSColorPboardType, NSFilenamesPboardType, nil]];
#elif defined(HAVE_COCOA_METAL)
#elif !defined(HAVE_COCOATOUCH) && defined(HAVE_COCOA_METAL)
[self registerForDraggedTypes:@[NSColorPboardType, NSFilenamesPboardType]];
#elif defined(HAVE_COCOATOUCH)
#if defined(HAVE_COCOA_METAL)
self.view = [UIView new];
#else
self.view = (BRIDGE GLKView*)glkitview_init();
#endif
#if TARGET_OS_IOS
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(showNativeMenu)];
swipe.numberOfTouchesRequired = 4;
@ -108,7 +113,7 @@ void *glkitview_init(void);
return self;
}
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if TARGET_OS_OSX
- (void)setFrame:(NSRect)frameRect
{
[super setFrame:frameRect];
@ -169,7 +174,7 @@ void *glkitview_init(void);
#elif TARGET_OS_IOS
-(void) showNativeMenu {
dispatch_async(dispatch_get_main_queue(), ^{
[[RetroArch_iOS get] toggleUI];
command_event(CMD_EVENT_MENU_TOGGLE, NULL);
});
}

View File

@ -26,6 +26,7 @@
#include <retro_timers.h>
#include "cocoa/cocoa_common.h"
#include "cocoa/apple_platform.h"
#include "../ui_companion_driver.h"
#include "../../configuration.h"
#include "../../frontend/frontend.h"
@ -39,7 +40,7 @@
#import <AVFoundation/AVFoundation.h>
#ifdef HAVE_COCOA_METAL
#if defined(HAVE_COCOA_METAL) || defined(HAVE_COCOATOUCH)
id<ApplePlatform> apple_platform;
#else
static id apple_platform;
@ -124,11 +125,10 @@ static void handle_touch_event(NSArray* touches)
CGPoint coord;
UITouch *touch = [touches objectAtIndex:i];
if (touch.view != [CocoaView get].view)
continue;
// if (touch.view != [CocoaView get].view)
// continue;
coord = [touch locationInView:[touch view]];
if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled)
{
apple->touches[apple->touch_count ].screen_x = coord.x * scale;
@ -138,7 +138,7 @@ static void handle_touch_event(NSArray* touches)
}
#ifndef HAVE_APPLE_STORE
// iO7 Keyboard support
// iOS7 Keyboard support
@interface UIEvent(iOS7Keyboard)
@property(readonly, nonatomic) long long _keyCode;
@property(readonly, nonatomic) _Bool _isKeyDown;
@ -317,6 +317,86 @@ enum
@implementation RetroArch_iOS
#pragma mark - ApplePlatform
-(id)renderView {
return _renderView;
}
-(bool)hasFocus {
return YES;
}
- (void)setViewType:(apple_view_type_t)vt {
if (vt == _vt)
return;
RARCH_LOG("[Cocoa]: change view type: %d ? %d\n", _vt, vt);
_vt = vt;
if (_renderView != nil)
{
[_renderView removeFromSuperview];
_renderView = nil;
}
switch (vt) {
#ifdef HAVE_COCOA_METAL
case APPLE_VIEW_TYPE_VULKAN:
case APPLE_VIEW_TYPE_METAL:
{
MetalView *v = [MetalView new];
v.paused = YES;
v.enableSetNeedsDisplay = NO;
#if TARGET_OS_IOS
v.multipleTouchEnabled = YES;
#endif
_renderView = v;
}
break;
#endif
case APPLE_VIEW_TYPE_OPENGL_ES:
{
_renderView = (BRIDGE GLKView*)glkitview_init();
break;
}
case APPLE_VIEW_TYPE_NONE:
default:
return;
}
_renderView.translatesAutoresizingMaskIntoConstraints = NO;
UIView *rootView = [CocoaView get].view;
[rootView addSubview:_renderView];
[[_renderView.topAnchor constraintEqualToAnchor:rootView.topAnchor] setActive:YES];
[[_renderView.bottomAnchor constraintEqualToAnchor:rootView.bottomAnchor] setActive:YES];
[[_renderView.leadingAnchor constraintEqualToAnchor:rootView.leadingAnchor] setActive:YES];
[[_renderView.trailingAnchor constraintEqualToAnchor:rootView.trailingAnchor] setActive:YES];
}
- (apple_view_type_t)viewType {
return _vt;
}
- (void)setVideoMode:(gfx_ctx_mode_t)mode {
#ifdef HAVE_COCOA_METAL
MetalView *metalView = (MetalView*) _renderView;
CGFloat scale = [[UIScreen mainScreen] scale];
[metalView setDrawableSize:CGSizeMake(
_renderView.bounds.size.width * scale,
_renderView.bounds.size.height * scale
)
];
#endif
}
- (void)setCursorVisible:(bool)v {
// no-op for iOS
}
- (bool)setDisableDisplaySleep:(bool)disable {
// no-op for iOS
return NO;
}
+ (RetroArch_iOS*)get
{
return (RetroArch_iOS*)[[UIApplication sharedApplication] delegate];
@ -349,12 +429,6 @@ enum
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window makeKeyAndVisible];
#if TARGET_OS_IOS
self.mainmenu = [RAMainMenu new];
self.mainmenu.last_menu = self.mainmenu;
[self pushViewController:self.mainmenu animated:NO];
#endif
NSError *error;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error];
if (error) {
@ -477,50 +551,10 @@ enum
#endif
}
- (void)mainMenuRefresh
{
#if TARGET_OS_IOS
[self.mainmenu reloadData];
#endif
}
- (void)mainMenuPushPop: (bool)pushp
{
#if TARGET_OS_IOS
if (pushp)
{
self.menu_count++;
RAMenuBase* next_menu = [RAMainMenu new];
next_menu.last_menu = self.mainmenu;
self.mainmenu = next_menu;
[self pushViewController:self.mainmenu animated:YES];
}
else
{
if (self.menu_count == 0)
[self.mainmenu reloadData];
else
{
self.menu_count--;
[self popViewControllerAnimated:YES];
self.mainmenu = self.mainmenu.last_menu;
}
}
#endif
}
- (void)supportOtherAudioSessions
{
}
- (void)mainMenuRenderMessageBox:(NSString *)msg
{
#if TARGET_OS_IOS
[self.mainmenu renderMessageBox:msg];
#endif
}
@end
int main(int argc, char *argv[])
@ -538,132 +572,3 @@ static void apple_rarch_exited(void)
return;
[ap showPauseMenu:ap];
}
typedef struct ui_companion_cocoatouch
{
void *empty;
} ui_companion_cocoatouch_t;
static void ui_companion_cocoatouch_notify_content_loaded(void *data)
{
RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform;
(void)data;
if (ap)
[ap showGameView];
}
static void ui_companion_cocoatouch_toggle(void *data, bool force)
{
RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform;
(void)data;
if (ap)
[ap toggleUI];
}
static void ui_companion_cocoatouch_deinit(void *data)
{
ui_companion_cocoatouch_t *handle = (ui_companion_cocoatouch_t*)data;
apple_rarch_exited();
if (handle)
free(handle);
}
static void *ui_companion_cocoatouch_init(void)
{
ui_companion_cocoatouch_t *handle = (ui_companion_cocoatouch_t*)
calloc(1, sizeof(*handle));
if (!handle)
return NULL;
rarch_enable_ui();
return handle;
}
static void ui_companion_cocoatouch_notify_list_pushed(void *data,
file_list_t *list, file_list_t *menu_list)
{
static size_t old_size = 0;
RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform;
bool pushp = false;
size_t new_size = file_list_get_size(menu_list);
/* FIXME workaround for the double call */
if (old_size == 0)
{
old_size = new_size;
return;
}
if (old_size == new_size)
pushp = false;
else if (old_size < new_size)
pushp = true;
else if (old_size > new_size)
printf("notify_list_pushed: old size should not be larger\n" );
old_size = new_size;
if (ap)
[ap mainMenuPushPop: pushp];
}
static void ui_companion_cocoatouch_notify_refresh(void *data)
{
RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform;
if (ap)
[ap mainMenuRefresh];
}
static void ui_companion_cocoatouch_render_messagebox(const char *msg)
{
static char msg_old[PATH_MAX_LENGTH];
RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform;
if (ap && !string_is_equal(msg, msg_old))
{
[ap mainMenuRenderMessageBox: [NSString stringWithUTF8String:msg]];
strlcpy(msg_old, msg, sizeof(msg_old));
}
}
static void ui_companion_cocoatouch_msg_queue_push(void *data, const char *msg,
unsigned priority, unsigned duration, bool flush)
{
RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform;
if (ap && msg)
{
#if TARGET_OS_IOS
[ap.mainmenu msgQueuePush: [NSString stringWithUTF8String:msg]];
#endif
}
}
ui_companion_driver_t ui_companion_cocoatouch = {
ui_companion_cocoatouch_init,
ui_companion_cocoatouch_deinit,
ui_companion_cocoatouch_toggle,
ui_companion_cocoatouch_event_command,
ui_companion_cocoatouch_notify_content_loaded,
ui_companion_cocoatouch_notify_list_pushed,
ui_companion_cocoatouch_notify_refresh,
ui_companion_cocoatouch_msg_queue_push,
ui_companion_cocoatouch_render_messagebox,
NULL, /* get_main_window */
NULL, /* log_msg */
NULL, /* is_active */
NULL, /* ui_browser_window_null */
NULL, /* ui_msg_window_null */
NULL, /* ui_window_null */
NULL, /* ui_application_null */
"cocoatouch",
};