1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00
vcmi/clientapp/ios/startSDL.mm

60 lines
1.5 KiB
Plaintext
Raw Normal View History

/*
* startSDL.mm, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
2024-03-29 07:48:52 +02:00
#import "startSDL.h"
2022-09-29 11:47:31 +02:00
#import "GameChatKeyboardHandler.h"
#include "../Global.h"
#include "CMT.h"
#include "CServerHandler.h"
#include "CFocusableHelper.h"
#include <SDL_main.h>
#include <SDL_events.h>
#include <SDL_render.h>
#include <SDL_system.h>
#import <UIKit/UIKit.h>
@interface SDLViewObserver : NSObject <UIGestureRecognizerDelegate>
2022-09-29 11:47:31 +02:00
@property (nonatomic, strong) GameChatKeyboardHandler * gameChatHandler;
@end
@implementation SDLViewObserver
@end
int startSDL(int argc, char * argv[], BOOL startManually)
{
@autoreleasepool {
auto observer = [SDLViewObserver new];
2022-09-29 11:47:31 +02:00
observer.gameChatHandler = [GameChatKeyboardHandler new];
id textFieldObserver = [NSNotificationCenter.defaultCenter addObserverForName:UITextFieldTextDidEndEditingNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
removeFocusFromActiveInput();
}];
int result;
if (startManually)
{
// copied from -[SDLUIKitDelegate postFinishLaunch]
SDL_SetMainReady();
SDL_iOSSetEventPump(SDL_TRUE);
result = SDL_main(argc, argv);
SDL_iOSSetEventPump(SDL_FALSE);
}
else
result = SDL_UIKitRunApp(argc, argv, SDL_main);
[NSNotificationCenter.defaultCenter removeObserver:textFieldObserver];
return result;
}
}