diff options
author | Thierry Crozat | 2019-08-04 16:30:41 +0100 |
---|---|---|
committer | Thierry Crozat | 2019-08-04 19:03:34 +0100 |
commit | 160070347f1ae2b3b15390a8f9e9273fcb0d4419 (patch) | |
tree | 4a813deff3d8e18e35c026afecd3530efda4b45d /backends | |
parent | c505a7b4bb14c532a2f343fd27032bd97ad716b7 (diff) | |
download | scummvm-rg350-160070347f1ae2b3b15390a8f9e9273fcb0d4419.tar.gz scummvm-rg350-160070347f1ae2b3b15390a8f9e9273fcb0d4419.tar.bz2 scummvm-rg350-160070347f1ae2b3b15390a8f9e9273fcb0d4419.zip |
IOS7: Move non-video related functions to a separate file
Diffstat (limited to 'backends')
-rw-r--r-- | backends/platform/ios7/ios7_osys_misc.mm | 79 | ||||
-rw-r--r-- | backends/platform/ios7/ios7_osys_video.mm | 52 | ||||
-rw-r--r-- | backends/platform/ios7/module.mk | 1 |
3 files changed, 80 insertions, 52 deletions
diff --git a/backends/platform/ios7/ios7_osys_misc.mm b/backends/platform/ios7/ios7_osys_misc.mm new file mode 100644 index 0000000000..8641094c47 --- /dev/null +++ b/backends/platform/ios7/ios7_osys_misc.mm @@ -0,0 +1,79 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program 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 Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include "backends/platform/ios7/ios7_osys_main.h" + +#include <UIKit/UIKit.h> +#include "common/translation.h" + +bool OSystem_iOS7::hasTextInClipboard() { + return [[UIPasteboard generalPasteboard] containsPasteboardTypes:UIPasteboardTypeListString]; +} + +Common::String OSystem_iOS7::getTextFromClipboard() { + if (!hasTextInClipboard()) + return Common::String(); + + UIPasteboard *pb = [UIPasteboard generalPasteboard]; + NSString *str = pb.string; + if (str == nil) + return Common::String(); + + // If translations are supported, use the current TranslationManager charset and otherwise + // use ASCII. If the string cannot be represented using the requested encoding we get a null + // pointer below, which is fine as ScummVM would not know what to do with the string anyway. +#ifdef USE_TRANSLATION + NSString* encStr = [NSString stringWithCString:TransMan.getCurrentCharset().c_str() encoding:NSASCIIStringEncoding]; + NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)encStr)); +#else + NSStringEncoding encoding = NSISOLatin1StringEncoding; +#endif + return Common::String([str cStringUsingEncoding:encoding]); +} + +bool OSystem_iOS7::setTextInClipboard(const Common::String &text) { +#ifdef USE_TRANSLATION + NSString* encStr = [NSString stringWithCString:TransMan.getCurrentCharset().c_str() encoding:NSASCIIStringEncoding]; + NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)encStr)); +#else + NSStringEncoding encoding = NSISOLatin1StringEncoding; +#endif + UIPasteboard *pb = [UIPasteboard generalPasteboard]; + [pb setString:[NSString stringWithCString:text.c_str() encoding:encoding]]; + return true; +} + +bool OSystem_iOS7::openUrl(const Common::String &url) { + UIApplication *application = [UIApplication sharedApplication]; + NSURL *nsurl = [NSURL URLWithString:[NSString stringWithCString:url.c_str() encoding:NSISOLatin1StringEncoding]]; + // The way to oipen a URL has changed in iOS 10. Check if the iOS 10 method is recognized + // and otherwise use the old method. + if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) { + [application openURL:nsurl options:@{} completionHandler:nil]; + return true; + } else { + return [application openURL:nsurl]; + } +} diff --git a/backends/platform/ios7/ios7_osys_video.mm b/backends/platform/ios7/ios7_osys_video.mm index f0a7db6265..20cf687709 100644 --- a/backends/platform/ios7/ios7_osys_video.mm +++ b/backends/platform/ios7/ios7_osys_video.mm @@ -28,7 +28,6 @@ #include "graphics/conversion.h" #include "backends/platform/ios7/ios7_app_delegate.h" -#include "common/translation.h" @interface iOS7AlertHandler : NSObject<UIAlertViewDelegate> @end @@ -604,54 +603,3 @@ void OSystem_iOS7::setShowKeyboard(bool show) { bool OSystem_iOS7::isKeyboardShown() const { return [[iOS7AppDelegate iPhoneView] isKeyboardShown]; } - - -bool OSystem_iOS7::hasTextInClipboard() { - return [[UIPasteboard generalPasteboard] containsPasteboardTypes:UIPasteboardTypeListString]; -} - -Common::String OSystem_iOS7::getTextFromClipboard() { - if (!hasTextInClipboard()) - return Common::String(); - - UIPasteboard *pb = [UIPasteboard generalPasteboard]; - NSString *str = pb.string; - if (str == nil) - return Common::String(); - - // If translations are supported, use the current TranslationManager charset and otherwise - // use ASCII. If the string cannot be represented using the requested encoding we get a null - // pointer below, which is fine as ScummVM would not know what to do with the string anyway. -#ifdef USE_TRANSLATION - NSString* encStr = [NSString stringWithCString:TransMan.getCurrentCharset().c_str() encoding:NSASCIIStringEncoding]; - NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)encStr)); -#else - NSStringEncoding encoding = NSISOLatin1StringEncoding; -#endif - return Common::String([str cStringUsingEncoding:encoding]); -} - -bool OSystem_iOS7::setTextInClipboard(const Common::String &text) { -#ifdef USE_TRANSLATION - NSString* encStr = [NSString stringWithCString:TransMan.getCurrentCharset().c_str() encoding:NSASCIIStringEncoding]; - NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)encStr)); -#else - NSStringEncoding encoding = NSISOLatin1StringEncoding; -#endif - UIPasteboard *pb = [UIPasteboard generalPasteboard]; - [pb setString:[NSString stringWithCString:text.c_str() encoding:encoding]]; - return true; -} - -bool OSystem_iOS7::openUrl(const Common::String &url) { - UIApplication *application = [UIApplication sharedApplication]; - NSURL *nsurl = [NSURL URLWithString:[NSString stringWithCString:url.c_str() encoding:NSISOLatin1StringEncoding]]; - // The way to oipen a URL has changed in iOS 10. Check if the iOS 10 method is recognized - // and otherwise use the old method. - if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) { - [application openURL:nsurl options:@{} completionHandler:nil]; - return true; - } else { - return [application openURL:nsurl]; - } -} diff --git a/backends/platform/ios7/module.mk b/backends/platform/ios7/module.mk index ad4f7fda5b..4b821fef51 100644 --- a/backends/platform/ios7/module.mk +++ b/backends/platform/ios7/module.mk @@ -5,6 +5,7 @@ MODULE_OBJS := \ ios7_osys_events.o \ ios7_osys_sound.o \ ios7_osys_video.o \ + ios7_osys_misc.o \ ios7_main.o \ ios7_video.o \ ios7_keyboard.o \ |