iOS: patches

master
MoNTE48 2019-08-15 16:29:49 +02:00
parent 908542b78f
commit 52880eaf1a
2 changed files with 149 additions and 126 deletions

View File

@ -61,6 +61,8 @@ namespace irr
virtual E_DEVICE_TYPE getType() const _IRR_OVERRIDE_;
void *getViewController();
private:
void createWindow();
void createViewAndDriver();

View File

@ -29,6 +29,17 @@ namespace irr
class CIrrDeviceiOS;
}
/* IrrUIViewController */
@interface IrrUIViewController : UIViewController
@end
@implementation IrrUIViewController
- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures {
return UIRectEdgeAll;
}
@end
/* CIrrDelegateiOS */
@interface CIrrDelegateiOS : NSObject<UIApplicationDelegate>
@ -186,7 +197,7 @@ namespace irr
if (self)
{
Device = device;
Scale = ([self respondsToSelector:@selector(setContentScaleFactor:)]) ? [[UIScreen mainScreen] scale] : 1.f;
Scale = 1.f;
}
return self;
@ -202,6 +213,7 @@ namespace irr
irr::SEvent ev;
ev.EventType = irr::EET_TOUCH_INPUT_EVENT;
ev.TouchInput.Event = irr::ETIE_PRESSED_DOWN;
ev.TouchInput.touchedCount = [touches count];
for (UITouch* touch in touches)
{
@ -221,6 +233,7 @@ namespace irr
irr::SEvent ev;
ev.EventType = irr::EET_TOUCH_INPUT_EVENT;
ev.TouchInput.Event = irr::ETIE_MOVED;
ev.TouchInput.touchedCount = [touches count];
for (UITouch* touch in touches)
{
@ -240,6 +253,7 @@ namespace irr
irr::SEvent ev;
ev.EventType = irr::EET_TOUCH_INPUT_EVENT;
ev.TouchInput.Event = irr::ETIE_LEFT_UP;
ev.TouchInput.touchedCount = [touches count];
for (UITouch* touch in touches)
{
@ -259,6 +273,7 @@ namespace irr
irr::SEvent ev;
ev.EventType = irr::EET_TOUCH_INPUT_EVENT;
ev.TouchInput.Event = irr::ETIE_LEFT_UP;
ev.TouchInput.touchedCount = [touches count];
for (UITouch* touch in touches)
{
@ -683,6 +698,12 @@ namespace irr
return EIDT_IOS;
}
void *CIrrDeviceiOS::getViewController()
{
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
return (__bridge void*) dataStorage->ViewController;
}
void CIrrDeviceiOS::createWindow()
{
if (CreationParams.DriverType != video::EDT_NULL)
@ -694,7 +715,7 @@ namespace irr
if (externalView == nil)
{
dataStorage->Window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
dataStorage->ViewController = [[UIViewController alloc] init];
dataStorage->ViewController = [[IrrUIViewController alloc] init];
dataStorage->Window.rootViewController = dataStorage->ViewController;
[dataStorage->Window makeKeyAndVisible];