Replace spaces with tabs in OSX and iOS sources

master
MoNTE48 2021-02-26 23:31:26 +01:00
parent 0c9ba6f7fd
commit 07b8f28c2d
5 changed files with 519 additions and 519 deletions

View File

@ -23,7 +23,7 @@
namespace irr namespace irr
{ {
class CIrrDeviceMacOSX; class CIrrDeviceMacOSX;
} }
@interface CIrrDelegateOSX : NSObject @interface CIrrDelegateOSX : NSObject
@ -89,8 +89,8 @@ namespace irr
//! Restore the window to normal size if possible. //! Restore the window to normal size if possible.
virtual void restoreWindow() _IRR_OVERRIDE_; virtual void restoreWindow() _IRR_OVERRIDE_;
//! Get the position of this window on screen //! Get the position of this window on screen
virtual core::position2di getWindowPosition() _IRR_OVERRIDE_; virtual core::position2di getWindowPosition() _IRR_OVERRIDE_;
//! Activate any joysticks, and generate events for them. //! Activate any joysticks, and generate events for them.
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo) _IRR_OVERRIDE_; virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo) _IRR_OVERRIDE_;
@ -108,7 +108,7 @@ namespace irr
void setMouseLocation(int x, int y); void setMouseLocation(int x, int y);
void setResize(int width, int height); void setResize(int width, int height);
void setCursorVisible(bool visible); void setCursorVisible(bool visible);
void setWindow(NSWindow* window); void setWindow(NSWindow* window);
private: private:
@ -128,11 +128,11 @@ namespace irr
} }
void updateWindowSize(const core::dimension2du& size) void updateWindowSize(const core::dimension2du& size)
{ {
WindowSize = size; WindowSize = size;
if (WindowSize.Width != 0) if (WindowSize.Width != 0)
InvWindowSize.Width = 1.0f / WindowSize.Width; InvWindowSize.Width = 1.0f / WindowSize.Width;
if (WindowSize.Height != 0) if (WindowSize.Height != 0)
InvWindowSize.Height = 1.0f / WindowSize.Height; InvWindowSize.Height = 1.0f / WindowSize.Height;
} }
//! Changes the visible state of the mouse cursor. //! Changes the visible state of the mouse cursor.
@ -245,7 +245,7 @@ namespace irr
void pollJoysticks(); void pollJoysticks();
NSWindow* Window; NSWindow* Window;
CGDirectDisplayID Display; CGDirectDisplayID Display;
NSBitmapImageRep* SoftwareDriverTarget; NSBitmapImageRep* SoftwareDriverTarget;
std::map<int,int> KeyCodes; std::map<int,int> KeyCodes;
int DeviceWidth; int DeviceWidth;
@ -253,8 +253,8 @@ namespace irr
int ScreenWidth; int ScreenWidth;
int ScreenHeight; int ScreenHeight;
u32 MouseButtonStates; u32 MouseButtonStates;
u32 SoftwareRendererType; u32 SoftwareRendererType;
bool IsFullscreen; bool IsFullscreen;
bool IsActive; bool IsActive;
bool IsShiftDown; bool IsShiftDown;
bool IsControlDown; bool IsControlDown;

View File

@ -477,79 +477,79 @@ static bool firstLaunch = true;
@implementation CIrrDelegateOSX @implementation CIrrDelegateOSX
{ {
irr::CIrrDeviceMacOSX* Device; irr::CIrrDeviceMacOSX* Device;
bool Quit; bool Quit;
} }
- (id)initWithDevice:(irr::CIrrDeviceMacOSX*)device - (id)initWithDevice:(irr::CIrrDeviceMacOSX*)device
{ {
self = [super init]; self = [super init];
if (self) if (self)
Device = device; Device = device;
Quit = false; Quit = false;
return (self); return (self);
} }
- (void)applicationDidFinishLaunching:(NSNotification*)notification - (void)applicationDidFinishLaunching:(NSNotification*)notification
{ {
Quit = false; Quit = false;
} }
- (void)orderFrontStandardAboutPanel:(id)sender - (void)orderFrontStandardAboutPanel:(id)sender
{ {
[NSApp orderFrontStandardAboutPanel:sender]; [NSApp orderFrontStandardAboutPanel:sender];
} }
- (void)unhideAllApplications:(id)sender - (void)unhideAllApplications:(id)sender
{ {
[NSApp unhideAllApplications:sender]; [NSApp unhideAllApplications:sender];
} }
- (void)hide:(id)sender - (void)hide:(id)sender
{ {
[NSApp hide:sender]; [NSApp hide:sender];
} }
- (void)hideOtherApplications:(id)sender - (void)hideOtherApplications:(id)sender
{ {
[NSApp hideOtherApplications:sender]; [NSApp hideOtherApplications:sender];
} }
- (void)terminate:(id)sender - (void)terminate:(id)sender
{ {
Quit = true; Quit = true;
} }
- (void)windowWillClose:(id)sender - (void)windowWillClose:(id)sender
{ {
Device->setWindow(nil); Device->setWindow(nil);
Quit = true; Quit = true;
} }
- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize - (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
{ {
if (Device->isResizable()) if (Device->isResizable())
return proposedFrameSize; return proposedFrameSize;
else else
return [window frame].size; return [window frame].size;
} }
- (void)windowDidResize:(NSNotification *)aNotification - (void)windowDidResize:(NSNotification *)aNotification
{ {
NSWindow *window; NSWindow *window;
NSRect frame; NSRect frame;
window = [aNotification object]; window = [aNotification object];
frame = [window contentRectForFrameRect:[window frame]]; frame = [window contentRectForFrameRect:[window frame]];
Device->setResize((int)frame.size.width,(int)frame.size.height); Device->setResize((int)frame.size.width,(int)frame.size.height);
} }
- (BOOL)isQuit - (BOOL)isQuit
{ {
return (Quit); return (Quit);
} }
@end @end
@ -580,26 +580,26 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
[NSApp setDelegate:(id<NSApplicationDelegate>)[[[CIrrDelegateOSX alloc] initWithDevice:this] autorelease]]; [NSApp setDelegate:(id<NSApplicationDelegate>)[[[CIrrDelegateOSX alloc] initWithDevice:this] autorelease]];
// Create menu // Create menu
NSString* bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; NSString* bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
NSMenu* mainMenu = [[[NSMenu alloc] initWithTitle:@"MainMenu"] autorelease]; NSMenu* mainMenu = [[[NSMenu alloc] initWithTitle:@"MainMenu"] autorelease];
NSMenu* menu = [[[NSMenu alloc] initWithTitle:bundleName] autorelease]; NSMenu* menu = [[[NSMenu alloc] initWithTitle:bundleName] autorelease];
NSMenuItem* menuItem = [mainMenu addItemWithTitle:bundleName action:nil keyEquivalent:@""]; NSMenuItem* menuItem = [mainMenu addItemWithTitle:bundleName action:nil keyEquivalent:@""];
[mainMenu setSubmenu:menu forItem:menuItem]; [mainMenu setSubmenu:menu forItem:menuItem];
menuItem = [menu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"]; menuItem = [menu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
[menuItem setKeyEquivalentModifierMask:NSCommandKeyMask]; [menuItem setKeyEquivalentModifierMask:NSCommandKeyMask];
[NSApp setMainMenu:mainMenu]; [NSApp setMainMenu:mainMenu];
[NSApp finishLaunching]; [NSApp finishLaunching];
} }
path = [[NSBundle mainBundle] bundlePath]; path = [[NSBundle mainBundle] bundlePath];
path = [path stringByAppendingString:@"/Contents/Resources"]; path = [path stringByAppendingString:@"/Contents/Resources"];
chdir([path fileSystemRepresentation]); chdir([path fileSystemRepresentation]);
[path release]; [path release];
} }
uname(&name); uname(&name);
@ -654,8 +654,8 @@ void CIrrDeviceMacOSX::closeDevice()
Window = nil; Window = nil;
} }
if (IsFullscreen) if (IsFullscreen)
CGReleaseAllDisplays(); CGReleaseAllDisplays();
IsFullscreen = false; IsFullscreen = false;
IsActive = false; IsActive = false;
@ -663,175 +663,175 @@ void CIrrDeviceMacOSX::closeDevice()
bool CIrrDeviceMacOSX::createWindow() bool CIrrDeviceMacOSX::createWindow()
{ {
CGDisplayErr error; CGDisplayErr error;
bool result = false; bool result = false;
Display = CGMainDisplayID(); Display = CGMainDisplayID();
CGRect displayRect; CGRect displayRect;
#ifdef __MAC_10_6 #ifdef __MAC_10_6
CGDisplayModeRef displaymode, olddisplaymode; CGDisplayModeRef displaymode, olddisplaymode;
#else #else
CFDictionaryRef displaymode, olddisplaymode; CFDictionaryRef displaymode, olddisplaymode;
#endif #endif
ScreenWidth = (int)CGDisplayPixelsWide(Display); ScreenWidth = (int)CGDisplayPixelsWide(Display);
ScreenHeight = (int)CGDisplayPixelsHigh(Display); ScreenHeight = (int)CGDisplayPixelsHigh(Display);
const NSBackingStoreType type = (CreationParams.DriverType == video::EDT_OPENGL) ? NSBackingStoreBuffered : NSBackingStoreNonretained; const NSBackingStoreType type = (CreationParams.DriverType == video::EDT_OPENGL) ? NSBackingStoreBuffered : NSBackingStoreNonretained;
if (!CreationParams.Fullscreen) if (!CreationParams.Fullscreen)
{ {
if (!CreationParams.WindowId) //create another window when WindowId is null if (!CreationParams.WindowId) //create another window when WindowId is null
{ {
int x = (CreationParams.WindowPosition.X > 0) ? CreationParams.WindowPosition.X : 0; int x = (CreationParams.WindowPosition.X > 0) ? CreationParams.WindowPosition.X : 0;
int y = (CreationParams.WindowPosition.Y > 0) ? CreationParams.WindowPosition.Y : 0; int y = (CreationParams.WindowPosition.Y > 0) ? CreationParams.WindowPosition.Y : 0;
if (CreationParams.WindowPosition.Y > -1) if (CreationParams.WindowPosition.Y > -1)
{ {
int screenHeight = (int) [[NSScreen screens][0] frame].size.height; int screenHeight = (int) [[NSScreen screens][0] frame].size.height;
y = screenHeight - y - CreationParams.WindowSize.Height; y = screenHeight - y - CreationParams.WindowSize.Height;
} }
NSWindowStyleMask style = NSTitledWindowMask+NSClosableWindowMask+NSResizableWindowMask+NSMiniaturizableWindowMask; NSWindowStyleMask style = NSTitledWindowMask+NSClosableWindowMask+NSResizableWindowMask+NSMiniaturizableWindowMask;
Window = [[NSWindow alloc] initWithContentRect:NSMakeRect(x, y, CreationParams.WindowSize.Width,CreationParams.WindowSize.Height) styleMask:style backing:type defer:FALSE]; Window = [[NSWindow alloc] initWithContentRect:NSMakeRect(x, y, CreationParams.WindowSize.Width,CreationParams.WindowSize.Height) styleMask:style backing:type defer:FALSE];
NSView* view = [Window contentView]; NSView* view = [Window contentView];
if ([view respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) if ([view respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)])
[view setWantsBestResolutionOpenGLSurface:YES]; [view setWantsBestResolutionOpenGLSurface:YES];
NativeScale = [Window backingScaleFactor]; NativeScale = [Window backingScaleFactor];
ScreenWidth *= NativeScale; ScreenWidth *= NativeScale;
ScreenHeight *= NativeScale; ScreenHeight *= NativeScale;
NSRect frame = [Window frame]; NSRect frame = [Window frame];
// get title bar height // get title bar height
CGFloat contentHeight = [Window contentRectForFrameRect: Window.frame].size.height; CGFloat contentHeight = [Window contentRectForFrameRect: Window.frame].size.height;
CGFloat titlebarHeight = frame.size.height - contentHeight; CGFloat titlebarHeight = frame.size.height - contentHeight;
// set correct window size // set correct window size
int h = CreationParams.WindowSize.Width; int h = CreationParams.WindowSize.Width;
int w = CreationParams.WindowSize.Height; int w = CreationParams.WindowSize.Height;
if (h % 2 != 0) h += 1; if (h % 2 != 0) h += 1;
if (w % 2 != 0) w += 1; if (w % 2 != 0) w += 1;
frame.size.width = h / NativeScale; frame.size.width = h / NativeScale;
frame.size.height = w / NativeScale + titlebarHeight; frame.size.height = w / NativeScale + titlebarHeight;
[Window setFrame:frame display:YES animate:YES]; [Window setFrame:frame display:YES animate:YES];
if (CreationParams.WindowPosition.X == -1 && CreationParams.WindowPosition.Y == -1) if (CreationParams.WindowPosition.X == -1 && CreationParams.WindowPosition.Y == -1)
[Window center]; [Window center];
} }
int x = CreationParams.WindowSize.Width; int x = CreationParams.WindowSize.Width;
int y = CreationParams.WindowSize.Height; int y = CreationParams.WindowSize.Height;
if (x % 2 != 0) x += 1; if (x % 2 != 0) x += 1;
if (y % 2 != 0) y += 1; if (y % 2 != 0) y += 1;
DeviceWidth = (s32) (x / NativeScale); DeviceWidth = (s32) (x / NativeScale);
DeviceHeight = (s32) (y / NativeScale); DeviceHeight = (s32) (y / NativeScale);
result = true; result = true;
} }
else else
{ {
IsFullscreen = true; IsFullscreen = true;
#ifdef __MAC_10_6 #ifdef __MAC_10_6
displaymode = CGDisplayCopyDisplayMode(Display); displaymode = CGDisplayCopyDisplayMode(Display);
CFArrayRef Modes = CGDisplayCopyAllDisplayModes(Display, NULL); CFArrayRef Modes = CGDisplayCopyAllDisplayModes(Display, NULL);
for(int i = 0; i < CFArrayGetCount(Modes); ++i) for(int i = 0; i < CFArrayGetCount(Modes); ++i)
{ {
CGDisplayModeRef CurrentMode = (CGDisplayModeRef)CFArrayGetValueAtIndex(Modes, i); CGDisplayModeRef CurrentMode = (CGDisplayModeRef)CFArrayGetValueAtIndex(Modes, i);
u8 Depth = 0; u8 Depth = 0;
CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(CurrentMode); CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(CurrentMode);
if (CFStringCompare(pixEnc, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) if (CFStringCompare(pixEnc, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
Depth = 32; Depth = 32;
else if(CFStringCompare(pixEnc, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) else if(CFStringCompare(pixEnc, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
Depth = 16; Depth = 16;
else if(CFStringCompare(pixEnc, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) else if(CFStringCompare(pixEnc, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
Depth = 8; Depth = 8;
if(Depth == CreationParams.Bits) if(Depth == CreationParams.Bits)
if((CGDisplayModeGetWidth(CurrentMode) == CreationParams.WindowSize.Width) && (CGDisplayModeGetHeight(CurrentMode) == CreationParams.WindowSize.Height)) if((CGDisplayModeGetWidth(CurrentMode) == CreationParams.WindowSize.Width) && (CGDisplayModeGetHeight(CurrentMode) == CreationParams.WindowSize.Height))
{ {
displaymode = CurrentMode; displaymode = CurrentMode;
break; break;
} }
} }
#else #else
displaymode = CGDisplayBestModeForParameters(Display,CreationParams.Bits,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height,NULL); displaymode = CGDisplayBestModeForParameters(Display,CreationParams.Bits,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height,NULL);
#endif #endif
if (displaymode != NULL) if (displaymode != NULL)
{ {
#ifdef __MAC_10_6 #ifdef __MAC_10_6
olddisplaymode = CGDisplayCopyDisplayMode(Display); olddisplaymode = CGDisplayCopyDisplayMode(Display);
#else #else
olddisplaymode = CGDisplayCurrentMode(Display); olddisplaymode = CGDisplayCurrentMode(Display);
#endif #endif
error = CGCaptureAllDisplays(); error = CGCaptureAllDisplays();
if (error == CGDisplayNoErr) if (error == CGDisplayNoErr)
{ {
#ifdef __MAC_10_6 #ifdef __MAC_10_6
error = CGDisplaySetDisplayMode(Display, displaymode, NULL); error = CGDisplaySetDisplayMode(Display, displaymode, NULL);
#else #else
error = CGDisplaySwitchToMode(Display, displaymode); error = CGDisplaySwitchToMode(Display, displaymode);
#endif #endif
if (error == CGDisplayNoErr) if (error == CGDisplayNoErr)
{ {
Window = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame] styleMask:NSBorderlessWindowMask backing:type defer:FALSE screen:[NSScreen mainScreen]]; Window = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame] styleMask:NSBorderlessWindowMask backing:type defer:FALSE screen:[NSScreen mainScreen]];
[Window setLevel: CGShieldingWindowLevel()]; [Window setLevel: CGShieldingWindowLevel()];
[Window setBackgroundColor:[NSColor blackColor]]; [Window setBackgroundColor:[NSColor blackColor]];
displayRect = CGDisplayBounds(Display); displayRect = CGDisplayBounds(Display);
ScreenWidth = DeviceWidth = (int)displayRect.size.width; ScreenWidth = DeviceWidth = (int)displayRect.size.width;
ScreenHeight = DeviceHeight = (int)displayRect.size.height; ScreenHeight = DeviceHeight = (int)displayRect.size.height;
CreationParams.WindowSize.set(ScreenWidth, ScreenHeight); CreationParams.WindowSize.set(ScreenWidth, ScreenHeight);
result = true; result = true;
} }
if (!result) if (!result)
CGReleaseAllDisplays(); CGReleaseAllDisplays();
} }
} }
} }
if (result) if (result)
{ {
if (Window) if (Window)
{ {
[Window setDelegate:(id<NSWindowDelegate>)[NSApp delegate]]; [Window setDelegate:(id<NSWindowDelegate>)[NSApp delegate]];
[Window setAcceptsMouseMovedEvents:TRUE]; [Window setAcceptsMouseMovedEvents:TRUE];
[Window setIsVisible:TRUE]; [Window setIsVisible:TRUE];
[Window makeKeyAndOrderFront:nil]; [Window makeKeyAndOrderFront:nil];
} }
if (IsFullscreen) //hide menus in fullscreen mode only if (IsFullscreen) //hide menus in fullscreen mode only
{ {
#ifdef __MAC_10_6 #ifdef __MAC_10_6
[NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)]; [NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
#else #else
SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);
#endif #endif
} }
} }
return result; return result;
} }
void CIrrDeviceMacOSX::setResize(int width, int height) void CIrrDeviceMacOSX::setResize(int width, int height)
{ {
if (width % 2 != 0) width += 1; if (width % 2 != 0) width += 1;
if (height % 2 != 0) height += 1; if (height % 2 != 0) height += 1;
// set new window size // set new window size
DeviceWidth = width; DeviceWidth = width;
@ -840,12 +840,12 @@ void CIrrDeviceMacOSX::setResize(int width, int height)
#if defined(_IRR_COMPILE_WITH_OPENGL_) #if defined(_IRR_COMPILE_WITH_OPENGL_)
// update the size of the opengl rendering context // update the size of the opengl rendering context
if (CreationParams.DriverType == video::EDT_OPENGL) if (CreationParams.DriverType == video::EDT_OPENGL)
{ {
NSOpenGLContext* Context = (NSOpenGLContext*)ContextManager->getContext().OpenGLOSX.Context; NSOpenGLContext* Context = (NSOpenGLContext*)ContextManager->getContext().OpenGLOSX.Context;
if (Context) if (Context)
[Context update]; [Context update];
} }
#endif #endif
// resize the driver to the inner pane size // resize the driver to the inner pane size
@ -858,14 +858,14 @@ void CIrrDeviceMacOSX::setResize(int width, int height)
else else
getVideoDriver()->OnResize(core::dimension2d<u32>((u32) (width * NativeScale), (u32) (height * NativeScale))); getVideoDriver()->OnResize(core::dimension2d<u32>((u32) (width * NativeScale), (u32) (height * NativeScale)));
// update device size to be ready to change screen resolution // update device size to be ready to change screen resolution
CGRect displayRect = CGDisplayBounds(CGMainDisplayID()); CGRect displayRect = CGDisplayBounds(CGMainDisplayID());
ScreenWidth = (int) (displayRect.size.width * NativeScale); ScreenWidth = (int) (displayRect.size.width * NativeScale);
ScreenHeight = (int) (displayRect.size.height * NativeScale); ScreenHeight = (int) (displayRect.size.height * NativeScale);
// reset mouse state on window resize // reset mouse state on window resize
MouseButtonStates = NO; MouseButtonStates = NO;
} }
@ -893,27 +893,27 @@ void CIrrDeviceMacOSX::createDriver()
case video::EDT_OPENGL: case video::EDT_OPENGL:
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
{ {
video::SExposedVideoData data; video::SExposedVideoData data;
data.OpenGLOSX.Window = Window; data.OpenGLOSX.Window = Window;
ContextManager = new video::CNSOGLManager(); ContextManager = new video::CNSOGLManager();
ContextManager->initialize(CreationParams, data); ContextManager->initialize(CreationParams, data);
VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, ContextManager); VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, ContextManager);
if (!VideoDriver) if (!VideoDriver)
{ {
os::Printer::log("Could not create OpenGL driver.", ELL_ERROR); os::Printer::log("Could not create OpenGL driver.", ELL_ERROR);
} }
if (Window) if (Window)
[(NSOpenGLContext*)ContextManager->getContext().OpenGLOSX.Context setView:[Window contentView]]; [(NSOpenGLContext*)ContextManager->getContext().OpenGLOSX.Context setView:[Window contentView]];
else else
[(NSOpenGLContext*)ContextManager->getContext().OpenGLOSX.Context setView:(NSView*)CreationParams.WindowId]; [(NSOpenGLContext*)ContextManager->getContext().OpenGLOSX.Context setView:(NSView*)CreationParams.WindowId];
#ifndef __MAC_10_6 #ifndef __MAC_10_6
CGLContextObj CGLContext = (CGLContextObj)[(NSOpenGLContext*)ContextManager->getContext().OpenGLOSX.Context CGLContextObj]; CGLContextObj CGLContext = (CGLContextObj)[(NSOpenGLContext*)ContextManager->getContext().OpenGLOSX.Context CGLContextObj];
CGLSetFullScreen(CGLContext); CGLSetFullScreen(CGLContext);
#endif #endif
} }
#else #else
os::Printer::log("No OpenGL support compiled in.", ELL_ERROR); os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
#endif #endif
@ -1057,13 +1057,13 @@ bool CIrrDeviceMacOSX::run()
postMouseEvent(event,ievent); postMouseEvent(event,ievent);
break; break;
} }
ievent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; ievent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
ievent.MouseInput.Wheel = (s32) [event deltaY]; ievent.MouseInput.Wheel = (s32) [event deltaY];
if (ievent.MouseInput.Wheel < 1.0f) if (ievent.MouseInput.Wheel < 1.0f)
ievent.MouseInput.Wheel *= 10.0f; ievent.MouseInput.Wheel *= 10.0f;
else else
ievent.MouseInput.Wheel *= 5.0f; ievent.MouseInput.Wheel *= 5.0f;
postMouseEvent(event,ievent); postMouseEvent(event,ievent);
break; break;
default: default:
@ -1251,8 +1251,8 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent)
{ {
ievent.MouseInput.Shift = ([(NSEvent *)event modifierFlags] & NSShiftKeyMask) != 0; ievent.MouseInput.Shift = ([(NSEvent *)event modifierFlags] & NSShiftKeyMask) != 0;
ievent.MouseInput.Control = ([(NSEvent *)event modifierFlags] & NSControlKeyMask) != 0; ievent.MouseInput.Control = ([(NSEvent *)event modifierFlags] & NSControlKeyMask) != 0;
ievent.MouseInput.X *= NativeScale; ievent.MouseInput.X *= NativeScale;
ievent.MouseInput.Y *= NativeScale; ievent.MouseInput.Y *= NativeScale;
postEventFromUser(ievent); postEventFromUser(ievent);
} }
@ -1295,16 +1295,16 @@ void CIrrDeviceMacOSX::storeMouseLocation()
} }
} }
x *= NativeScale; x *= NativeScale;
y *= NativeScale; y *= NativeScale;
((CCursorControl *)CursorControl)->updateInternalCursorPosition(x,y); ((CCursorControl *)CursorControl)->updateInternalCursorPosition(x,y);
} }
void CIrrDeviceMacOSX::setMouseLocation(int x,int y) void CIrrDeviceMacOSX::setMouseLocation(int x,int y)
{ {
x /= NativeScale; x /= NativeScale;
y /= NativeScale; y /= NativeScale;
NSPoint p; NSPoint p;
CGPoint c; CGPoint c;
@ -1326,16 +1326,16 @@ void CIrrDeviceMacOSX::setMouseLocation(int x,int y)
c.x = p.x; c.x = p.x;
c.y = p.y; c.y = p.y;
#ifdef __MAC_10_6 /*#ifdef __MAC_10_6
// CGEventRef ev = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, c, NULL); CGEventRef ev = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, c, NULL);
// CGEventPost(kCGHIDEventTap, ev); CGEventPost(kCGHIDEventTap, ev);
// CFRelease(ev); CFRelease(ev);
#else
CGSetLocalEventsSuppressionInterval(0);
CGWarpMouseCursorPosition(c);
#endif*/
CGSetLocalEventsSuppressionInterval(0); CGSetLocalEventsSuppressionInterval(0);
CGWarpMouseCursorPosition(c); CGWarpMouseCursorPosition(c);
#else
CGSetLocalEventsSuppressionInterval(0);
CGWarpMouseCursorPosition(c);
#endif
} }
@ -1350,7 +1350,7 @@ void CIrrDeviceMacOSX::setCursorVisible(bool visible)
void CIrrDeviceMacOSX::setWindow(NSWindow* window) void CIrrDeviceMacOSX::setWindow(NSWindow* window)
{ {
Window = window; Window = window;
} }

View File

@ -46,28 +46,28 @@ namespace irr
virtual core::position2di getWindowPosition() _IRR_OVERRIDE_; virtual core::position2di getWindowPosition() _IRR_OVERRIDE_;
virtual bool activateAccelerometer(float updateInterval = 0.016666f) _IRR_OVERRIDE_; virtual bool activateAccelerometer(float updateInterval = 0.016666f) _IRR_OVERRIDE_;
virtual bool deactivateAccelerometer() _IRR_OVERRIDE_; virtual bool deactivateAccelerometer() _IRR_OVERRIDE_;
virtual bool isAccelerometerActive() _IRR_OVERRIDE_; virtual bool isAccelerometerActive() _IRR_OVERRIDE_;
virtual bool isAccelerometerAvailable() _IRR_OVERRIDE_; virtual bool isAccelerometerAvailable() _IRR_OVERRIDE_;
virtual bool activateGyroscope(float updateInterval = 0.016666f) _IRR_OVERRIDE_; virtual bool activateGyroscope(float updateInterval = 0.016666f) _IRR_OVERRIDE_;
virtual bool deactivateGyroscope() _IRR_OVERRIDE_; virtual bool deactivateGyroscope() _IRR_OVERRIDE_;
virtual bool isGyroscopeActive() _IRR_OVERRIDE_; virtual bool isGyroscopeActive() _IRR_OVERRIDE_;
virtual bool isGyroscopeAvailable() _IRR_OVERRIDE_; virtual bool isGyroscopeAvailable() _IRR_OVERRIDE_;
virtual bool activateDeviceMotion(float updateInterval = 0.016666f) _IRR_OVERRIDE_; virtual bool activateDeviceMotion(float updateInterval = 0.016666f) _IRR_OVERRIDE_;
virtual bool deactivateDeviceMotion() _IRR_OVERRIDE_; virtual bool deactivateDeviceMotion() _IRR_OVERRIDE_;
virtual bool isDeviceMotionActive() _IRR_OVERRIDE_; virtual bool isDeviceMotionActive() _IRR_OVERRIDE_;
virtual bool isDeviceMotionAvailable() _IRR_OVERRIDE_; virtual bool isDeviceMotionAvailable() _IRR_OVERRIDE_;
virtual E_DEVICE_TYPE getType() const _IRR_OVERRIDE_; virtual E_DEVICE_TYPE getType() const _IRR_OVERRIDE_;
void *getViewController(); void *getViewController();
private: private:
void createWindow(); void createWindow();
void createViewAndDriver(); void createViewAndDriver();
void* DataStorage; void* DataStorage;
bool Close; bool Close;
}; };

View File

@ -187,19 +187,19 @@ namespace irr
@implementation CIrrViewiOS @implementation CIrrViewiOS
{ {
irr::CIrrDeviceiOS* Device; irr::CIrrDeviceiOS* Device;
} }
- (id)initWithFrame:(CGRect)frame forDevice:(irr::CIrrDeviceiOS*)device; - (id)initWithFrame:(CGRect)frame forDevice:(irr::CIrrDeviceiOS*)device;
{ {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
self.Scale = 1.0f; self.Scale = 1.0f;
if (self) if (self)
{ {
Device = device; Device = device;
} }
return self; return self;
} }
- (BOOL)isMultipleTouchEnabled - (BOOL)isMultipleTouchEnabled
@ -216,14 +216,14 @@ namespace irr
for (UITouch* touch in touches) for (UITouch* touch in touches)
{ {
ev.TouchInput.ID = (size_t)touch; ev.TouchInput.ID = (size_t)touch;
CGPoint touchPoint = [touch locationInView:self]; CGPoint touchPoint = [touch locationInView:self];
ev.TouchInput.X = touchPoint.x * self.Scale; ev.TouchInput.X = touchPoint.x * self.Scale;
ev.TouchInput.Y = touchPoint.y * self.Scale; ev.TouchInput.Y = touchPoint.y * self.Scale;
Device->postEventFromUser(ev); Device->postEventFromUser(ev);
} }
} }
@ -236,14 +236,14 @@ namespace irr
for (UITouch* touch in touches) for (UITouch* touch in touches)
{ {
ev.TouchInput.ID = (size_t)touch; ev.TouchInput.ID = (size_t)touch;
CGPoint touchPoint = [touch locationInView:self]; CGPoint touchPoint = [touch locationInView:self];
ev.TouchInput.X = touchPoint.x * self.Scale; ev.TouchInput.X = touchPoint.x * self.Scale;
ev.TouchInput.Y = touchPoint.y * self.Scale; ev.TouchInput.Y = touchPoint.y * self.Scale;
Device->postEventFromUser(ev); Device->postEventFromUser(ev);
} }
} }
@ -256,14 +256,14 @@ namespace irr
for (UITouch* touch in touches) for (UITouch* touch in touches)
{ {
ev.TouchInput.ID = (size_t)touch; ev.TouchInput.ID = (size_t)touch;
CGPoint touchPoint = [touch locationInView:self]; CGPoint touchPoint = [touch locationInView:self];
ev.TouchInput.X = touchPoint.x * self.Scale; ev.TouchInput.X = touchPoint.x * self.Scale;
ev.TouchInput.Y = touchPoint.y * self.Scale; ev.TouchInput.Y = touchPoint.y * self.Scale;
Device->postEventFromUser(ev); Device->postEventFromUser(ev);
} }
} }
@ -276,14 +276,14 @@ namespace irr
for (UITouch* touch in touches) for (UITouch* touch in touches)
{ {
ev.TouchInput.ID = (size_t)touch; ev.TouchInput.ID = (size_t)touch;
CGPoint touchPoint = [touch locationInView:self]; CGPoint touchPoint = [touch locationInView:self];
ev.TouchInput.X = touchPoint.x * self.Scale; ev.TouchInput.X = touchPoint.x * self.Scale;
ev.TouchInput.Y = touchPoint.y * self.Scale; ev.TouchInput.Y = touchPoint.y * self.Scale;
Device->postEventFromUser(ev); Device->postEventFromUser(ev);
} }
} }
@ -313,24 +313,24 @@ namespace irr
IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager); IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
} }
struct SIrrDeviceiOSDataStorage struct SIrrDeviceiOSDataStorage
{ {
SIrrDeviceiOSDataStorage() : Window(0), ViewController(0), View(0), MotionManager(0), ReferenceAttitude(0) SIrrDeviceiOSDataStorage() : Window(0), ViewController(0), View(0), MotionManager(0), ReferenceAttitude(0)
{ {
MotionManager = [[CMMotionManager alloc] init]; MotionManager = [[CMMotionManager alloc] init];
} }
UIWindow* Window; UIWindow* Window;
UIViewController* ViewController; UIViewController* ViewController;
CIrrViewiOS* View; CIrrViewiOS* View;
CMMotionManager* MotionManager; CMMotionManager* MotionManager;
CMAttitude* ReferenceAttitude; CMAttitude* ReferenceAttitude;
}; };
CIrrDeviceiOS::CIrrDeviceiOS(const SIrrlichtCreationParameters& params) : CIrrDeviceStub(params), DataStorage(0), Close(false) CIrrDeviceiOS::CIrrDeviceiOS(const SIrrlichtCreationParameters& params) : CIrrDeviceStub(params), DataStorage(0), Close(false)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CIrrDeviceiOS"); setDebugName("CIrrDeviceiOS");
#endif #endif
#ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
@ -338,35 +338,35 @@ namespace irr
[delegate setDevice:this]; [delegate setDevice:this];
#endif #endif
DataStorage = new SIrrDeviceiOSDataStorage(); DataStorage = new SIrrDeviceiOSDataStorage();
FileSystem->changeWorkingDirectoryTo([[[NSBundle mainBundle] resourcePath] UTF8String]); FileSystem->changeWorkingDirectoryTo([[[NSBundle mainBundle] resourcePath] UTF8String]);
createWindow(); createWindow();
createViewAndDriver(); createViewAndDriver();
if (!VideoDriver) if (!VideoDriver)
return; return;
createGUIAndScene(); createGUIAndScene();
} }
CIrrDeviceiOS::~CIrrDeviceiOS() CIrrDeviceiOS::~CIrrDeviceiOS()
{ {
deactivateDeviceMotion(); deactivateDeviceMotion();
deactivateGyroscope(); deactivateGyroscope();
deactivateAccelerometer(); deactivateAccelerometer();
delete static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); delete static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
#ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
CIrrDelegateiOS* delegate = [UIApplication sharedApplication].delegate; CIrrDelegateiOS* delegate = [UIApplication sharedApplication].delegate;
[delegate setDevice:nil]; [delegate setDevice:nil];
#endif #endif
} }
bool CIrrDeviceiOS::run() bool CIrrDeviceiOS::run()
{ {
if (!Close) if (!Close)
{ {
const CFTimeInterval timeInSeconds = 0.000002; const CFTimeInterval timeInSeconds = 0.000002;
@ -432,37 +432,37 @@ namespace irr
} }
return !Close; return !Close;
} }
void CIrrDeviceiOS::yield() void CIrrDeviceiOS::yield()
{ {
struct timespec ts = {0,0}; struct timespec ts = {0,0};
nanosleep(&ts, NULL); nanosleep(&ts, NULL);
} }
void CIrrDeviceiOS::sleep(u32 timeMs, bool pauseTimer=false) void CIrrDeviceiOS::sleep(u32 timeMs, bool pauseTimer=false)
{ {
bool wasStopped = Timer ? Timer->isStopped() : true; bool wasStopped = Timer ? Timer->isStopped() : true;
struct timespec ts; struct timespec ts;
ts.tv_sec = (time_t) (timeMs / 1000); ts.tv_sec = (time_t) (timeMs / 1000);
ts.tv_nsec = (long) (timeMs % 1000) * 1000000; ts.tv_nsec = (long) (timeMs % 1000) * 1000000;
if (pauseTimer && !wasStopped) if (pauseTimer && !wasStopped)
Timer->stop(); Timer->stop();
nanosleep(&ts, NULL); nanosleep(&ts, NULL);
if (pauseTimer && !wasStopped) if (pauseTimer && !wasStopped)
Timer->start(); Timer->start();
} }
void CIrrDeviceiOS::setWindowCaption(const wchar_t* text) void CIrrDeviceiOS::setWindowCaption(const wchar_t* text)
{ {
} }
bool CIrrDeviceiOS::isWindowActive() const bool CIrrDeviceiOS::isWindowActive() const
{ {
#ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
CIrrDelegateiOS* delegate = [UIApplication sharedApplication].delegate; CIrrDelegateiOS* delegate = [UIApplication sharedApplication].delegate;
@ -470,10 +470,10 @@ namespace irr
#else #else
return false; return false;
#endif #endif
} }
bool CIrrDeviceiOS::isWindowFocused() const bool CIrrDeviceiOS::isWindowFocused() const
{ {
#ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
CIrrDelegateiOS* delegate = [UIApplication sharedApplication].delegate; CIrrDelegateiOS* delegate = [UIApplication sharedApplication].delegate;
@ -481,10 +481,10 @@ namespace irr
#else #else
return false; return false;
#endif #endif
} }
bool CIrrDeviceiOS::isWindowMinimized() const bool CIrrDeviceiOS::isWindowMinimized() const
{ {
#ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
CIrrDelegateiOS* delegate = [UIApplication sharedApplication].delegate; CIrrDelegateiOS* delegate = [UIApplication sharedApplication].delegate;
@ -492,219 +492,219 @@ namespace irr
#else #else
return false; return false;
#endif #endif
} }
bool CIrrDeviceiOS::present(video::IImage* image, void * windowId, core::rect<s32>* src) bool CIrrDeviceiOS::present(video::IImage* image, void * windowId, core::rect<s32>* src)
{ {
return false; return false;
} }
void CIrrDeviceiOS::closeDevice() void CIrrDeviceiOS::closeDevice()
{ {
CFRunLoopStop(CFRunLoopGetMain()); CFRunLoopStop(CFRunLoopGetMain());
Close = true; Close = true;
} }
void CIrrDeviceiOS::setResizable(bool resize) void CIrrDeviceiOS::setResizable(bool resize)
{ {
} }
void CIrrDeviceiOS::minimizeWindow() void CIrrDeviceiOS::minimizeWindow()
{ {
} }
void CIrrDeviceiOS::maximizeWindow() void CIrrDeviceiOS::maximizeWindow()
{ {
} }
void CIrrDeviceiOS::restoreWindow() void CIrrDeviceiOS::restoreWindow()
{ {
} }
core::position2di CIrrDeviceiOS::getWindowPosition() core::position2di CIrrDeviceiOS::getWindowPosition()
{ {
return core::position2di(0, 0); return core::position2di(0, 0);
} }
bool CIrrDeviceiOS::activateAccelerometer(float updateInterval) bool CIrrDeviceiOS::activateAccelerometer(float updateInterval)
{ {
bool status = false; bool status = false;
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
CMMotionManager* motionManager = dataStorage->MotionManager; CMMotionManager* motionManager = dataStorage->MotionManager;
if (motionManager.isAccelerometerAvailable) if (motionManager.isAccelerometerAvailable)
{ {
if (!motionManager.isAccelerometerActive) if (!motionManager.isAccelerometerActive)
{ {
motionManager.accelerometerUpdateInterval = updateInterval; motionManager.accelerometerUpdateInterval = updateInterval;
[motionManager startAccelerometerUpdates]; [motionManager startAccelerometerUpdates];
} }
status = true; status = true;
} }
return status; return status;
} }
bool CIrrDeviceiOS::deactivateAccelerometer() bool CIrrDeviceiOS::deactivateAccelerometer()
{ {
bool status = false; bool status = false;
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
CMMotionManager* motionManager = dataStorage->MotionManager; CMMotionManager* motionManager = dataStorage->MotionManager;
if (motionManager.isAccelerometerAvailable) if (motionManager.isAccelerometerAvailable)
{ {
if (motionManager.isAccelerometerActive) if (motionManager.isAccelerometerActive)
[motionManager stopAccelerometerUpdates]; [motionManager stopAccelerometerUpdates];
status = true; status = true;
} }
return status; return status;
} }
bool CIrrDeviceiOS::isAccelerometerActive() bool CIrrDeviceiOS::isAccelerometerActive()
{ {
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
return (dataStorage->MotionManager.isAccelerometerActive); return (dataStorage->MotionManager.isAccelerometerActive);
} }
bool CIrrDeviceiOS::isAccelerometerAvailable() bool CIrrDeviceiOS::isAccelerometerAvailable()
{ {
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
return (dataStorage->MotionManager.isAccelerometerAvailable); return (dataStorage->MotionManager.isAccelerometerAvailable);
} }
bool CIrrDeviceiOS::activateGyroscope(float updateInterval) bool CIrrDeviceiOS::activateGyroscope(float updateInterval)
{ {
bool status = false; bool status = false;
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
CMMotionManager* motionManager = dataStorage->MotionManager; CMMotionManager* motionManager = dataStorage->MotionManager;
if (motionManager.isGyroAvailable) if (motionManager.isGyroAvailable)
{ {
if (!motionManager.isGyroActive) if (!motionManager.isGyroActive)
{ {
motionManager.gyroUpdateInterval = updateInterval; motionManager.gyroUpdateInterval = updateInterval;
[motionManager startGyroUpdates]; [motionManager startGyroUpdates];
} }
status = true; status = true;
} }
return status; return status;
} }
bool CIrrDeviceiOS::deactivateGyroscope() bool CIrrDeviceiOS::deactivateGyroscope()
{ {
bool status = false; bool status = false;
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
CMMotionManager* motionManager = dataStorage->MotionManager; CMMotionManager* motionManager = dataStorage->MotionManager;
if (motionManager.isGyroAvailable) if (motionManager.isGyroAvailable)
{ {
if (motionManager.isGyroActive) if (motionManager.isGyroActive)
[motionManager stopGyroUpdates]; [motionManager stopGyroUpdates];
status = true; status = true;
} }
return status; return status;
} }
bool CIrrDeviceiOS::isGyroscopeActive() bool CIrrDeviceiOS::isGyroscopeActive()
{ {
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
return (dataStorage->MotionManager.isGyroActive); return (dataStorage->MotionManager.isGyroActive);
} }
bool CIrrDeviceiOS::isGyroscopeAvailable() bool CIrrDeviceiOS::isGyroscopeAvailable()
{ {
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
return (dataStorage->MotionManager.isGyroAvailable); return (dataStorage->MotionManager.isGyroAvailable);
} }
bool CIrrDeviceiOS::activateDeviceMotion(float updateInterval) bool CIrrDeviceiOS::activateDeviceMotion(float updateInterval)
{ {
bool status = false; bool status = false;
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
CMMotionManager* motionManager = dataStorage->MotionManager; CMMotionManager* motionManager = dataStorage->MotionManager;
if (motionManager.isDeviceMotionAvailable) if (motionManager.isDeviceMotionAvailable)
{ {
if (!motionManager.isDeviceMotionActive) if (!motionManager.isDeviceMotionActive)
{ {
dataStorage->ReferenceAttitude = nil; dataStorage->ReferenceAttitude = nil;
motionManager.deviceMotionUpdateInterval = updateInterval; motionManager.deviceMotionUpdateInterval = updateInterval;
[motionManager startDeviceMotionUpdates]; [motionManager startDeviceMotionUpdates];
} }
status = true; status = true;
} }
return status; return status;
} }
bool CIrrDeviceiOS::deactivateDeviceMotion() bool CIrrDeviceiOS::deactivateDeviceMotion()
{ {
bool status = false; bool status = false;
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
CMMotionManager* motionManager = dataStorage->MotionManager; CMMotionManager* motionManager = dataStorage->MotionManager;
if (motionManager.isDeviceMotionAvailable) if (motionManager.isDeviceMotionAvailable)
{ {
if (motionManager.isDeviceMotionActive) if (motionManager.isDeviceMotionActive)
{ {
[motionManager stopDeviceMotionUpdates]; [motionManager stopDeviceMotionUpdates];
dataStorage->ReferenceAttitude = nil; dataStorage->ReferenceAttitude = nil;
} }
status = true; status = true;
} }
return status; return status;
} }
bool CIrrDeviceiOS::isDeviceMotionActive() bool CIrrDeviceiOS::isDeviceMotionActive()
{ {
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
return (dataStorage->MotionManager.isDeviceMotionActive); return (dataStorage->MotionManager.isDeviceMotionActive);
} }
bool CIrrDeviceiOS::isDeviceMotionAvailable() bool CIrrDeviceiOS::isDeviceMotionAvailable()
{ {
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
return (dataStorage->MotionManager.isDeviceMotionAvailable); return (dataStorage->MotionManager.isDeviceMotionAvailable);
} }
E_DEVICE_TYPE CIrrDeviceiOS::getType() const E_DEVICE_TYPE CIrrDeviceiOS::getType() const
{ {
return EIDT_IOS; return EIDT_IOS;
} }
void *CIrrDeviceiOS::getViewController() void *CIrrDeviceiOS::getViewController()
{ {
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
return (__bridge void*) dataStorage->ViewController; return (__bridge void*) dataStorage->ViewController;
} }
void CIrrDeviceiOS::createWindow() void CIrrDeviceiOS::createWindow()
{ {
if (CreationParams.DriverType != video::EDT_NULL) if (CreationParams.DriverType != video::EDT_NULL)
{ {
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
@ -748,10 +748,10 @@ namespace irr
while (currentResponder != nil); while (currentResponder != nil);
} }
} }
} }
void CIrrDeviceiOS::createViewAndDriver() void CIrrDeviceiOS::createViewAndDriver()
{ {
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
video::SExposedVideoData data; video::SExposedVideoData data;
@ -762,11 +762,11 @@ namespace irr
CGRect resolution = (externalView == nil) ? [[UIScreen mainScreen] bounds] : externalView.bounds; CGRect resolution = (externalView == nil) ? [[UIScreen mainScreen] bounds] : externalView.bounds;
switch (CreationParams.DriverType) switch (CreationParams.DriverType)
{ {
case video::EDT_OGLES1: case video::EDT_OGLES1:
#ifdef _IRR_COMPILE_WITH_OGLES1_ #ifdef _IRR_COMPILE_WITH_OGLES1_
{ {
CIrrViewEAGLiOS* view = [[CIrrViewEAGLiOS alloc] initWithFrame:resolution forDevice:this]; CIrrViewEAGLiOS* view = [[CIrrViewEAGLiOS alloc] initWithFrame:resolution forDevice:this];
view.contentScaleFactor = dataStorage->Window.screen.nativeScale; view.contentScaleFactor = dataStorage->Window.screen.nativeScale;
view.Scale = view.contentScaleFactor; view.Scale = view.contentScaleFactor;
@ -779,30 +779,30 @@ namespace irr
dataStorage->View = view; dataStorage->View = view;
data.OpenGLiOS.View = (__bridge void*)view; data.OpenGLiOS.View = (__bridge void*)view;
ContextManager = new video::CEAGLManager(); ContextManager = new video::CEAGLManager();
ContextManager->initialize(CreationParams, data); ContextManager->initialize(CreationParams, data);
VideoDriver = video::createOGLES1Driver(CreationParams, FileSystem, ContextManager); VideoDriver = video::createOGLES1Driver(CreationParams, FileSystem, ContextManager);
if (!VideoDriver) if (!VideoDriver)
os::Printer::log("Could not create OpenGL ES 1.x driver.", ELL_ERROR); os::Printer::log("Could not create OpenGL ES 1.x driver.", ELL_ERROR);
} }
#else #else
os::Printer::log("No OpenGL ES 1.x support compiled in.", ELL_ERROR); os::Printer::log("No OpenGL ES 1.x support compiled in.", ELL_ERROR);
#endif #endif
break; break;
case video::EDT_OGLES2: case video::EDT_OGLES2:
#ifdef _IRR_COMPILE_WITH_OGLES2_ #ifdef _IRR_COMPILE_WITH_OGLES2_
{ {
CIrrViewEAGLiOS* view = [[CIrrViewEAGLiOS alloc] initWithFrame:resolution forDevice:this]; CIrrViewEAGLiOS* view = [[CIrrViewEAGLiOS alloc] initWithFrame:resolution forDevice:this];
view.contentScaleFactor = dataStorage->Window.screen.nativeScale; view.contentScaleFactor = dataStorage->Window.screen.nativeScale;
view.Scale = view.contentScaleFactor; view.Scale = view.contentScaleFactor;
CreationParams.WindowSize = CreationParams.WindowSize =
{ {
view.frame.size.width * view.contentScaleFactor, view.frame.size.width * view.contentScaleFactor,
view.frame.size.height * view.contentScaleFactor view.frame.size.height * view.contentScaleFactor
}; };
dataStorage->View = view; dataStorage->View = view;
data.OpenGLiOS.View = (__bridge void*)view; data.OpenGLiOS.View = (__bridge void*)view;
@ -820,22 +820,22 @@ namespace irr
#endif #endif
break; break;
case video::EDT_SOFTWARE: case video::EDT_SOFTWARE:
case video::EDT_BURNINGSVIDEO: case video::EDT_BURNINGSVIDEO:
case video::DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS: case video::DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS:
case video::EDT_DIRECT3D9: case video::EDT_DIRECT3D9:
case video::EDT_OPENGL: case video::EDT_OPENGL:
os::Printer::log("This driver is not available in iOS. Try OpenGL ES.", ELL_ERROR); os::Printer::log("This driver is not available in iOS. Try OpenGL ES.", ELL_ERROR);
break; break;
case video::EDT_NULL: case video::EDT_NULL:
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
break; break;
default: default:
os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR);
break; break;
} }
if (externalView == nil) if (externalView == nil)
dataStorage->ViewController.view = dataStorage->View; dataStorage->ViewController.view = dataStorage->View;
@ -847,9 +847,9 @@ namespace irr
#ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
int result = UIApplicationMain(argc, argv, 0, NSStringFromClass([CIrrDelegateiOS class])); int result = UIApplicationMain(argc, argv, 0, NSStringFromClass([CIrrDelegateiOS class]));
return result; return result;
} }
#endif #endif

View File

@ -902,8 +902,8 @@
5E34C8051B7F51D900F212E8 /* irrXML.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = irrXML.cpp; sourceTree = "<group>"; }; 5E34C8051B7F51D900F212E8 /* irrXML.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = irrXML.cpp; sourceTree = "<group>"; };
5E34C80D1B7F52AC00F212E8 /* CIrrDeviceStub.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CIrrDeviceStub.cpp; sourceTree = "<group>"; }; 5E34C80D1B7F52AC00F212E8 /* CIrrDeviceStub.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CIrrDeviceStub.cpp; sourceTree = "<group>"; };
5E34C80E1B7F52AC00F212E8 /* CIrrDeviceStub.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CIrrDeviceStub.h; sourceTree = "<group>"; }; 5E34C80E1B7F52AC00F212E8 /* CIrrDeviceStub.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CIrrDeviceStub.h; sourceTree = "<group>"; };
5E34C8131B7F535C00F212E8 /* CIrrDeviceOSX.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CIrrDeviceOSX.h; sourceTree = "<group>"; }; 5E34C8131B7F535C00F212E8 /* CIrrDeviceOSX.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CIrrDeviceOSX.h; sourceTree = "<group>"; usesTabs = 1; };
5E34C8141B7F535C00F212E8 /* CIrrDeviceOSX.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CIrrDeviceOSX.mm; sourceTree = "<group>"; }; 5E34C8141B7F535C00F212E8 /* CIrrDeviceOSX.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CIrrDeviceOSX.mm; sourceTree = "<group>"; usesTabs = 1; };
5E34C8151B7F540B00F212E8 /* aes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = aes.h; path = aesGladman/aes.h; sourceTree = "<group>"; }; 5E34C8151B7F540B00F212E8 /* aes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = aes.h; path = aesGladman/aes.h; sourceTree = "<group>"; };
5E34C8161B7F540B00F212E8 /* aescrypt.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = aescrypt.cpp; path = aesGladman/aescrypt.cpp; sourceTree = "<group>"; }; 5E34C8161B7F540B00F212E8 /* aescrypt.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = aescrypt.cpp; path = aesGladman/aescrypt.cpp; sourceTree = "<group>"; };
5E34C8171B7F540B00F212E8 /* aeskey.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = aeskey.cpp; path = aesGladman/aeskey.cpp; sourceTree = "<group>"; }; 5E34C8171B7F540B00F212E8 /* aeskey.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = aeskey.cpp; path = aesGladman/aeskey.cpp; sourceTree = "<group>"; };
@ -1330,8 +1330,8 @@
5E34C9EE1B7F6CCC00F212E8 /* CNSOGLManager.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CNSOGLManager.mm; sourceTree = "<group>"; }; 5E34C9EE1B7F6CCC00F212E8 /* CNSOGLManager.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CNSOGLManager.mm; sourceTree = "<group>"; };
5E34C9F31B7F6E3400F212E8 /* libIrrlicht.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libIrrlicht.a; sourceTree = BUILT_PRODUCTS_DIR; }; 5E34C9F31B7F6E3400F212E8 /* libIrrlicht.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libIrrlicht.a; sourceTree = BUILT_PRODUCTS_DIR; };
5E5733E51C18E212003F664E /* libIrrlicht.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libIrrlicht.a; sourceTree = BUILT_PRODUCTS_DIR; }; 5E5733E51C18E212003F664E /* libIrrlicht.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libIrrlicht.a; sourceTree = BUILT_PRODUCTS_DIR; };
5E5733E61C18E254003F664E /* CIrrDeviceiOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CIrrDeviceiOS.h; sourceTree = "<group>"; }; 5E5733E61C18E254003F664E /* CIrrDeviceiOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CIrrDeviceiOS.h; sourceTree = "<group>"; usesTabs = 1; };
5E5733E71C18E254003F664E /* CIrrDeviceiOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CIrrDeviceiOS.mm; sourceTree = "<group>"; }; 5E5733E71C18E254003F664E /* CIrrDeviceiOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CIrrDeviceiOS.mm; sourceTree = "<group>"; usesTabs = 1; };
5E5733EC1C18E2C0003F664E /* COGLESCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = COGLESCommon.h; sourceTree = "<group>"; }; 5E5733EC1C18E2C0003F664E /* COGLESCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = COGLESCommon.h; sourceTree = "<group>"; };
5E5733ED1C18E2C0003F664E /* COGLESDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = COGLESDriver.cpp; sourceTree = "<group>"; }; 5E5733ED1C18E2C0003F664E /* COGLESDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = COGLESDriver.cpp; sourceTree = "<group>"; };
5E5733EE1C18E2C0003F664E /* COGLESDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = COGLESDriver.h; sourceTree = "<group>"; }; 5E5733EE1C18E2C0003F664E /* COGLESDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = COGLESDriver.h; sourceTree = "<group>"; };