mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-07-13 13:21:42 +00:00
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/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
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,11 +17,6 @@ target_link_libraries(esmtool
|
||||||
components
|
components
|
||||||
)
|
)
|
||||||
|
|
||||||
#if (APPLE)
|
|
||||||
# find_library(CARBON_FRAMEWORK Carbon)
|
|
||||||
# target_link_libraries(openmw ${CARBON_FRAMEWORK})
|
|
||||||
#endif (APPLE)
|
|
||||||
|
|
||||||
if (BUILD_WITH_CODE_COVERAGE)
|
if (BUILD_WITH_CODE_COVERAGE)
|
||||||
add_definitions (--coverage)
|
add_definitions (--coverage)
|
||||||
target_link_libraries(esmtool gcov)
|
target_link_libraries(esmtool gcov)
|
||||||
|
|
|
@ -131,10 +131,9 @@ endif()
|
||||||
|
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
find_library(CARBON_FRAMEWORK Carbon)
|
|
||||||
find_library(COCOA_FRAMEWORK Cocoa)
|
find_library(COCOA_FRAMEWORK Cocoa)
|
||||||
find_library(IOKIT_FRAMEWORK IOKit)
|
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)
|
if (FFMPEG_FOUND)
|
||||||
find_library(COREVIDEO_FRAMEWORK CoreVideo)
|
find_library(COREVIDEO_FRAMEWORK CoreVideo)
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
#include "inputmanagerimp.hpp"
|
#include "inputmanagerimp.hpp"
|
||||||
|
|
||||||
#if defined(__APPLE__) && !defined(__LP64__)
|
|
||||||
#include <Carbon/Carbon.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <OgreRoot.h>
|
#include <OgreRoot.h>
|
||||||
#include <OgreRenderWindow.h>
|
#include <OgreRenderWindow.h>
|
||||||
|
|
||||||
|
@ -56,12 +52,6 @@ namespace MWInput
|
||||||
, mOverencumberedMessageDelay(0.f)
|
, mOverencumberedMessageDelay(0.f)
|
||||||
, mAlwaysRunActive(false)
|
, 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 ();
|
Ogre::RenderWindow* window = ogre.getWindow ();
|
||||||
|
|
||||||
|
@ -430,16 +420,6 @@ namespace MWInput
|
||||||
MWBase::Environment::get().getWindowManager()->enterPressed();
|
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);
|
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
|
||||||
|
|
||||||
MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), text);
|
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 <cstdlib>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#if defined(__APPLE__) && !defined(__LP64__)
|
#ifdef __MACOSX__
|
||||||
#include <Carbon/Carbon.h>
|
#include "osx_utils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace Ogre;
|
using namespace Ogre;
|
||||||
using namespace OEngine::Render;
|
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()
|
void OgreRenderer::cleanup()
|
||||||
{
|
{
|
||||||
delete mFader;
|
delete mFader;
|
||||||
|
@ -68,34 +52,7 @@ void OgreRenderer::cleanup()
|
||||||
|
|
||||||
void OgreRenderer::start()
|
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();
|
mRoot->startRendering();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OgreRenderer::loadPlugins()
|
void OgreRenderer::loadPlugins()
|
||||||
|
@ -188,11 +145,7 @@ void OgreRenderer::configure(const std::string &logPath,
|
||||||
// Disable logging
|
// Disable logging
|
||||||
log->setDebugOutputEnabled(false);
|
log->setDebugOutputEnabled(false);
|
||||||
|
|
||||||
#if defined(__APPLE__) && !defined(__LP64__)
|
|
||||||
mRoot = new CustomRoot("", "", "");
|
|
||||||
#else
|
|
||||||
mRoot = new Root("", "", "");
|
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)
|
#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX)
|
||||||
loadPlugins();
|
loadPlugins();
|
||||||
|
@ -308,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 MACOS
|
#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:
|
||||||
|
|
|
@ -27,18 +27,12 @@
|
||||||
#include "OgreTexture.h"
|
#include "OgreTexture.h"
|
||||||
#include <OgreWindowEventUtilities.h>
|
#include <OgreWindowEventUtilities.h>
|
||||||
|
|
||||||
#if defined(__APPLE__) && !defined(__LP64__)
|
|
||||||
#include <OgreRoot.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
struct SDL_Surface;
|
struct SDL_Surface;
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
{
|
{
|
||||||
#if !defined(__APPLE__) || defined(__LP64__)
|
|
||||||
class Root;
|
class Root;
|
||||||
#endif
|
|
||||||
class RenderWindow;
|
class RenderWindow;
|
||||||
class SceneManager;
|
class SceneManager;
|
||||||
class Camera;
|
class Camera;
|
||||||
|
@ -60,26 +54,11 @@ namespace OEngine
|
||||||
std::string icon;
|
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 Fader;
|
||||||
|
|
||||||
class OgreRenderer
|
class OgreRenderer
|
||||||
{
|
{
|
||||||
#if defined(__APPLE__) && !defined(__LP64__)
|
|
||||||
CustomRoot *mRoot;
|
|
||||||
#else
|
|
||||||
Ogre::Root *mRoot;
|
Ogre::Root *mRoot;
|
||||||
#endif
|
|
||||||
Ogre::RenderWindow *mWindow;
|
Ogre::RenderWindow *mWindow;
|
||||||
SDL_Window *mSDLWindow;
|
SDL_Window *mSDLWindow;
|
||||||
SDL_Surface *mWindowIconSurface;
|
SDL_Surface *mWindowIconSurface;
|
||||||
|
|
Loading…
Reference in a new issue