SDL2 input: seems to work on OS X, has some input issues though

actorid
Nikolay Kasyanov 12 years ago
parent 3fded2d8bf
commit 6abb7a18b0

@ -79,6 +79,11 @@ set(OENGINE_OGRE
${LIBDIR}/openengine/ogre/selectionbuffer.cpp ${LIBDIR}/openengine/ogre/selectionbuffer.cpp
${LIBDIR}/openengine/ogre/imagerotate.cpp ${LIBDIR}/openengine/ogre/imagerotate.cpp
) )
if (APPLE)
set(OENGINE_OGRE ${OENGINE_OGRE} ${LIBDIR}/openengine/ogre/osx_utils.mm)
endif ()
set(OENGINE_GUI set(OENGINE_GUI
${LIBDIR}/openengine/gui/manager.cpp ${LIBDIR}/openengine/gui/manager.cpp
) )

@ -0,0 +1,14 @@
#ifndef OENGINE_OGRE_OSX_UTILS_H
#define OENGINE_OGRE_OSX_UTILS_H
#include <SDL_syswm.h>
namespace OEngine {
namespace Render {
extern unsigned long WindowContentViewHandle(SDL_SysWMinfo &info);
}
}
#endif

@ -0,0 +1,16 @@
#include "osx_utils.h"
#import <AppKit/NSWindow.h>
namespace OEngine {
namespace Render {
unsigned long WindowContentViewHandle(SDL_SysWMinfo &info)
{
NSWindow *window = info.info.cocoa.window;
NSView *view = [window contentView];
return (unsigned long)view;
}
}
}

@ -23,6 +23,10 @@
#include <cstdlib> #include <cstdlib>
#include <stdexcept> #include <stdexcept>
#ifdef __MACOSX__
#include "osx_utils.h"
#endif
using namespace Ogre; using namespace Ogre;
using namespace OEngine::Render; using namespace OEngine::Render;
@ -257,13 +261,13 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings&
// Windows code // Windows code
winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.win.window); winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.win.window);
break; break;
#elif __APPLE__ #elif __MACOSX__
case SDL_SYSWM_COCOA: case SDL_SYSWM_COCOA:
//required to make OGRE play nice with our window //required to make OGRE play nice with our window
params.insert(std::make_pair("macAPI", "cocoa")); params.insert(std::make_pair("macAPI", "cocoa"));
params.insert(std::make_pair("macAPICocoaUseNSView", "true")); params.insert(std::make_pair("macAPICocoaUseNSView", "true"));
winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.cocoa.window); winHandle = Ogre::StringConverter::toString(WindowContentViewHandle(wmInfo));
break; break;
#else #else
case SDL_SYSWM_X11: case SDL_SYSWM_X11:

Loading…
Cancel
Save