forked from mirror/openmw-tes3mp
Merge remote-tracking branch 'corristo/sdl_input2' into sdl_input2
This commit is contained in:
commit
9331a6380c
8 changed files with 40 additions and 99 deletions
|
@ -79,6 +79,11 @@ set(OENGINE_OGRE
|
|||
${LIBDIR}/openengine/ogre/selectionbuffer.cpp
|
||||
${LIBDIR}/openengine/ogre/imagerotate.cpp
|
||||
)
|
||||
|
||||
if (APPLE)
|
||||
set(OENGINE_OGRE ${OENGINE_OGRE} ${LIBDIR}/openengine/ogre/osx_utils.mm)
|
||||
endif ()
|
||||
|
||||
set(OENGINE_GUI
|
||||
${LIBDIR}/openengine/gui/manager.cpp
|
||||
)
|
||||
|
|
|
@ -17,11 +17,6 @@ target_link_libraries(esmtool
|
|||
components
|
||||
)
|
||||
|
||||
#if (APPLE)
|
||||
# find_library(CARBON_FRAMEWORK Carbon)
|
||||
# target_link_libraries(openmw ${CARBON_FRAMEWORK})
|
||||
#endif (APPLE)
|
||||
|
||||
if (BUILD_WITH_CODE_COVERAGE)
|
||||
add_definitions (--coverage)
|
||||
target_link_libraries(esmtool gcov)
|
||||
|
|
|
@ -131,10 +131,9 @@ endif()
|
|||
|
||||
|
||||
if(APPLE)
|
||||
find_library(CARBON_FRAMEWORK Carbon)
|
||||
find_library(COCOA_FRAMEWORK Cocoa)
|
||||
find_library(IOKIT_FRAMEWORK IOKit)
|
||||
target_link_libraries(openmw ${CARBON_FRAMEWORK} ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK})
|
||||
target_link_libraries(openmw ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK})
|
||||
|
||||
if (FFMPEG_FOUND)
|
||||
find_library(COREVIDEO_FRAMEWORK CoreVideo)
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
#include "inputmanagerimp.hpp"
|
||||
|
||||
#if defined(__APPLE__) && !defined(__LP64__)
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
#include <OgreRoot.h>
|
||||
#include <OgreRenderWindow.h>
|
||||
|
||||
|
@ -56,12 +52,6 @@ namespace MWInput
|
|||
, mOverencumberedMessageDelay(0.f)
|
||||
, mAlwaysRunActive(false)
|
||||
{
|
||||
#if defined(__APPLE__) && !defined(__LP64__)
|
||||
// Give the application window focus to receive input events
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
SetFrontProcess(&psn);
|
||||
#endif
|
||||
|
||||
Ogre::RenderWindow* window = ogre.getWindow ();
|
||||
|
||||
|
@ -430,16 +420,6 @@ namespace MWInput
|
|||
MWBase::Environment::get().getWindowManager()->enterPressed();
|
||||
}
|
||||
|
||||
//TODO: Check if we need this with SDL
|
||||
/*
|
||||
#ifdef __APPLE__ // filter \016 symbol for F-keys on OS X
|
||||
if ((arg.key >= SDLK_F1 && arg.key <= SDLK_F10) ||
|
||||
(arg.key >= SDLK_F11 && arg.key <= SDLK_F15)) {
|
||||
text = 0;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
|
||||
|
||||
MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), text);
|
||||
|
|
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,29 +23,13 @@
|
|||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
|
||||
#if defined(__APPLE__) && !defined(__LP64__)
|
||||
#include <Carbon/Carbon.h>
|
||||
#ifdef __MACOSX__
|
||||
#include "osx_utils.h"
|
||||
#endif
|
||||
|
||||
using namespace Ogre;
|
||||
using namespace OEngine::Render;
|
||||
|
||||
|
||||
#if defined(__APPLE__) && !defined(__LP64__)
|
||||
|
||||
CustomRoot::CustomRoot(const Ogre::String& pluginFileName,
|
||||
const Ogre::String& configFileName,
|
||||
const Ogre::String& logFileName)
|
||||
: Ogre::Root(pluginFileName, configFileName, logFileName)
|
||||
{}
|
||||
|
||||
bool CustomRoot::isQueuedEnd() const
|
||||
{
|
||||
return mQueuedEnd;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void OgreRenderer::cleanup()
|
||||
{
|
||||
delete mFader;
|
||||
|
@ -68,34 +52,7 @@ void OgreRenderer::cleanup()
|
|||
|
||||
void OgreRenderer::start()
|
||||
{
|
||||
//TODO: Check if we still need to do this if we're using SDL's
|
||||
//message pump
|
||||
#if defined(__APPLE__) && !defined(__LP64__)
|
||||
// OSX Carbon Message Pump
|
||||
do {
|
||||
EventRef event = NULL;
|
||||
EventTargetRef targetWindow;
|
||||
targetWindow = GetEventDispatcherTarget();
|
||||
|
||||
// If we are unable to get the target then we no longer care about events.
|
||||
if (!targetWindow) return;
|
||||
|
||||
// Grab the next event while possible
|
||||
while (ReceiveNextEvent(0, NULL, kEventDurationNoWait, true, &event) == noErr)
|
||||
{
|
||||
// Dispatch the event
|
||||
SendEventToEventTarget(event, targetWindow);
|
||||
ReleaseEvent(event);
|
||||
}
|
||||
|
||||
if (!mRoot->renderOneFrame()) {
|
||||
break;
|
||||
}
|
||||
|
||||
} while (!mRoot->isQueuedEnd());
|
||||
#else
|
||||
mRoot->startRendering();
|
||||
#endif
|
||||
}
|
||||
|
||||
void OgreRenderer::loadPlugins()
|
||||
|
@ -188,11 +145,7 @@ void OgreRenderer::configure(const std::string &logPath,
|
|||
// Disable logging
|
||||
log->setDebugOutputEnabled(false);
|
||||
|
||||
#if defined(__APPLE__) && !defined(__LP64__)
|
||||
mRoot = new CustomRoot("", "", "");
|
||||
#else
|
||||
mRoot = new Root("", "", "");
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX)
|
||||
loadPlugins();
|
||||
|
@ -308,13 +261,13 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings&
|
|||
// Windows code
|
||||
winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.win.window);
|
||||
break;
|
||||
#elif MACOS
|
||||
#elif __MACOSX__
|
||||
case SDL_SYSWM_COCOA:
|
||||
//required to make OGRE play nice with our window
|
||||
params.insert(std::make_pair("macAPI", "cocoa"));
|
||||
params.insert(std::make_pair("macAPICocoaUseNSView", "true"));
|
||||
|
||||
winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.cocoa.window);
|
||||
winHandle = Ogre::StringConverter::toString(WindowContentViewHandle(wmInfo));
|
||||
break;
|
||||
#else
|
||||
case SDL_SYSWM_X11:
|
||||
|
|
|
@ -27,18 +27,12 @@
|
|||
#include "OgreTexture.h"
|
||||
#include <OgreWindowEventUtilities.h>
|
||||
|
||||
#if defined(__APPLE__) && !defined(__LP64__)
|
||||
#include <OgreRoot.h>
|
||||
#endif
|
||||
|
||||
struct SDL_Window;
|
||||
struct SDL_Surface;
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
#if !defined(__APPLE__) || defined(__LP64__)
|
||||
class Root;
|
||||
#endif
|
||||
class RenderWindow;
|
||||
class SceneManager;
|
||||
class Camera;
|
||||
|
@ -60,26 +54,11 @@ namespace OEngine
|
|||
std::string icon;
|
||||
};
|
||||
|
||||
#if defined(__APPLE__) && !defined(__LP64__)
|
||||
class CustomRoot : public Ogre::Root {
|
||||
public:
|
||||
bool isQueuedEnd() const;
|
||||
|
||||
CustomRoot(const Ogre::String& pluginFileName = "plugins.cfg",
|
||||
const Ogre::String& configFileName = "ogre.cfg",
|
||||
const Ogre::String& logFileName = "Ogre.log");
|
||||
};
|
||||
#endif
|
||||
|
||||
class Fader;
|
||||
|
||||
class OgreRenderer
|
||||
{
|
||||
#if defined(__APPLE__) && !defined(__LP64__)
|
||||
CustomRoot *mRoot;
|
||||
#else
|
||||
Ogre::Root *mRoot;
|
||||
#endif
|
||||
Ogre::RenderWindow *mWindow;
|
||||
SDL_Window *mSDLWindow;
|
||||
SDL_Surface *mWindowIconSurface;
|
||||
|
|
Loading…
Reference in a new issue