RetroArch/ui/drivers/cocoa/cocoa_common.h
yoshisuga bc02f8319e
[iOS] New iOS 13 project to support Swift; Custom keyboard and touch mouse support (#13435)
* Support for Swift, added emulator keyboard

* fixed toggle key handling using magic number hack for now

* fixed keyboard transparency slider for now with suboptimal fix; add gesture recognizer to hide/show keyboard

* Support CocoaView extensions in Swift; move keyboard delegate impl and setup to swift extension

* moved keyboard view model creation out of EmulatorKeyboard

* implement key pressed delegate in swift extension

* added input method for directly sending RETROK_* codes to support a touchscreen keyboard; assign keyboard model delegates; updated keyboard layout (added F1-F12 keys); change shift, control and alt keys to be modifiers

* enable focus mode when custom keyboard is shown; enable/disable overlay when custom keyboard is toggled

* Specify -DHAVE_OPENGLES2 instead of -DHAVE_OPENGLES3 since glsym_es3.h does not compile in iOS 14.5
Fix tvOS build using compiler flags

* Create new project for iOS 13 deploy target; add check for deploy target to conditionally compile for new iOS 13 specific feature (custom keyboard)

* force disable core info caching for iOS, use opengl es2 for debug

* Add flag for iOS custom keyboard - 3-finger swipe up to show, 3-finger swipe down to hide

* use OpenGLES2 instead; using ES3 results in compile time errors on iOS 14.5

* code cleanup

* Updated references to -DDONT_WANT_ARM_ASM_OPTIMIZATIONS flag

* Add JIT support for non-jailbroken devices

* iOS: Add support for touch mouse handler

* Added a HAVE_IOS_TOUCHMOUSE preprocessor macro so that it builds under the iOS11_Metal xcode project

* Changed click-and-drag behavior to double tap hold and drag

* Visual improvements to the emulator keyboard: updated colors, improved key-press effect
2022-02-22 08:21:34 +01:00

130 lines
3.3 KiB
Objective-C

/* RetroArch - A frontend for libretro.
* Copyright (C) 2013-2014 - Jason Fetters
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* 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/>.
*/
#ifndef __COCOA_COMMON_SHARED_H
#define __COCOA_COMMON_SHARED_H
#include <Foundation/Foundation.h>
#if defined(HAVE_COCOATOUCH)
#include <UIKit/UIKit.h>
#if TARGET_OS_TV
#import <GameController/GameController.h>
#endif
#else
#include <AppKit/AppKit.h>
#endif
#include "../../../retroarch.h"
#if defined(HAVE_COCOATOUCH)
#define RAScreen UIScreen
#ifndef UIUserInterfaceIdiomTV
#define UIUserInterfaceIdiomTV 2
#endif
#ifndef UIUserInterfaceIdiomCarPlay
#define UIUserInterfaceIdiomCarPlay 3
#endif
#if TARGET_OS_IOS
@class EmulatorKeyboardController;
@interface CocoaView : UIViewController
#elif TARGET_OS_TV
@interface CocoaView : GCEventViewController
#endif
#if TARGET_OS_IOS && defined(HAVE_IOS_CUSTOMKEYBOARD)
@property(nonatomic,strong) EmulatorKeyboardController *keyboardController;
@property(nonatomic,assign) unsigned int keyboardModifierState;
#endif
+ (CocoaView*)get;
@end
void get_ios_version(int *major, int *minor);
#else
#define RAScreen NSScreen
@interface CocoaView : NSView
+ (CocoaView*)get;
#if !defined(HAVE_COCOA) && !defined(HAVE_COCOA_METAL)
- (void)display;
#endif
@end
#endif
typedef struct
{
char orientations[32];
unsigned orientation_flags;
char bluetooth_mode[64];
} apple_frontend_settings_t;
extern apple_frontend_settings_t apple_frontend_settings;
#define BOXSTRING(x) [NSString stringWithUTF8String:x]
#define BOXINT(x) [NSNumber numberWithInt:x]
#define BOXUINT(x) [NSNumber numberWithUnsignedInt:x]
#define BOXFLOAT(x) [NSNumber numberWithDouble:x]
#if defined(__clang__)
/* ARC is only available for Clang */
#if __has_feature(objc_arc)
#define RELEASE(x) x = nil
#define BRIDGE __bridge
#define UNSAFE_UNRETAINED __unsafe_unretained
#else
#define RELEASE(x) [x release]; \
x = nil
#define BRIDGE
#define UNSAFE_UNRETAINED
#endif
#else
/* On compilers other than Clang (e.g. GCC), assume ARC
is going to be unavailable */
#define RELEASE(x) [x release]; \
x = nil
#define BRIDGE
#define UNSAFE_UNRETAINED
#endif
void *nsview_get_ptr(void);
void nsview_set_ptr(CocoaView *ptr);
bool cocoa_has_focus(void *data);
void cocoa_show_mouse(void *data, bool state);
void *cocoa_screen_get_chosen(void);
#ifdef HAVE_COCOATOUCH
float cocoa_screen_get_native_scale(void);
#else
float cocoa_screen_get_backing_scale_factor(void);
void cocoa_update_title(void *data);
#endif
bool cocoa_get_metrics(
void *data, enum display_metric_types type,
float *value);
#endif