mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 11:09:43 +00:00
SDL2 input: seems to work on OS X, has some input issues though
This commit is contained in:
parent
3fded2d8bf
commit
6abb7a18b0
4 changed files with 41 additions and 2 deletions
|
@ -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
|
||||||
)
|
)
|
||||||
|
|
14
libs/openengine/ogre/osx_utils.h
Normal file
14
libs/openengine/ogre/osx_utils.h
Normal file
|
@ -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
|
16
libs/openengine/ogre/osx_utils.mm
Normal file
16
libs/openengine/ogre/osx_utils.mm
Normal file
|
@ -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…
Reference in a new issue