Merge remote-tracking branch 'corristo/master'

actorid
Marc Zinnschlag 12 years ago
commit b8cd3f3915

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

@ -19,11 +19,11 @@ namespace SFO
mMouseZ(0), mMouseZ(0),
mMouseY(0), mMouseY(0),
mMouseX(0), mMouseX(0),
mMouseInWindow(true), mMouseInWindow(true),
mJoyListener(NULL), mJoyListener(NULL),
mKeyboardListener(NULL), mKeyboardListener(NULL),
mMouseListener(NULL), mMouseListener(NULL),
mWindowListener(NULL) mWindowListener(NULL)
{ {
_setupOISKeys(); _setupOISKeys();
} }
@ -72,25 +72,25 @@ namespace SFO
case SDL_TEXTINPUT: case SDL_TEXTINPUT:
mKeyboardListener->textInput(evt.text); mKeyboardListener->textInput(evt.text);
break; break;
case SDL_JOYAXISMOTION: case SDL_JOYAXISMOTION:
if (mJoyListener) if (mJoyListener)
mJoyListener->axisMoved(evt.jaxis, evt.jaxis.axis); mJoyListener->axisMoved(evt.jaxis, evt.jaxis.axis);
break; break;
case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONDOWN:
if (mJoyListener) if (mJoyListener)
mJoyListener->buttonPressed(evt.jbutton, evt.jbutton.button); mJoyListener->buttonPressed(evt.jbutton, evt.jbutton.button);
break; break;
case SDL_JOYBUTTONUP: case SDL_JOYBUTTONUP:
if (mJoyListener) if (mJoyListener)
mJoyListener->buttonReleased(evt.jbutton, evt.jbutton.button); mJoyListener->buttonReleased(evt.jbutton, evt.jbutton.button);
break; break;
case SDL_JOYDEVICEADDED: case SDL_JOYDEVICEADDED:
//SDL_JoystickOpen(evt.jdevice.which); //SDL_JoystickOpen(evt.jdevice.which);
//std::cout << "Detected a new joystick: " << SDL_JoystickNameForIndex(evt.jdevice.which) << std::endl; //std::cout << "Detected a new joystick: " << SDL_JoystickNameForIndex(evt.jdevice.which) << std::endl;
break; break;
case SDL_JOYDEVICEREMOVED: case SDL_JOYDEVICEREMOVED:
//std::cout << "A joystick has been removed" << std::endl; //std::cout << "A joystick has been removed" << std::endl;
break; break;
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
handleWindowEvent(evt); handleWindowEvent(evt);
break; break;
@ -115,61 +115,62 @@ namespace SFO
SDL_SetWindowGrab(mSDLWindow, SDL_FALSE); SDL_SetWindowGrab(mSDLWindow, SDL_FALSE);
SDL_SetRelativeMouseMode(SDL_FALSE); SDL_SetRelativeMouseMode(SDL_FALSE);
break; break;
case SDL_WINDOWEVENT_SIZE_CHANGED: case SDL_WINDOWEVENT_SIZE_CHANGED:
int w,h; int w,h;
SDL_GetWindowSize(mSDLWindow, &w, &h); SDL_GetWindowSize(mSDLWindow, &w, &h);
// TODO: Fix Ogre to handle this more consistently // TODO: Fix Ogre to handle this more consistently
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
mOgreWindow->resize(w, h); mOgreWindow->resize(w, h);
#else #else
mOgreWindow->windowMovedOrResized(); mOgreWindow->windowMovedOrResized();
#endif #endif
if (mWindowListener) if (mWindowListener)
mWindowListener->windowResized(evt.window.data1, evt.window.data2); mWindowListener->windowResized(evt.window.data1, evt.window.data2);
break;
case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_RESIZED:
// TODO: Fix Ogre to handle this more consistently // TODO: Fix Ogre to handle this more consistently
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
mOgreWindow->resize(evt.window.data1, evt.window.data2); mOgreWindow->resize(evt.window.data1, evt.window.data2);
#else #else
mOgreWindow->windowMovedOrResized(); mOgreWindow->windowMovedOrResized();
#endif #endif
if (mWindowListener) if (mWindowListener)
mWindowListener->windowResized(evt.window.data1, evt.window.data2); mWindowListener->windowResized(evt.window.data1, evt.window.data2);
break; break;
case SDL_WINDOWEVENT_FOCUS_GAINED: case SDL_WINDOWEVENT_FOCUS_GAINED:
if (mWindowListener) if (mWindowListener)
mWindowListener->windowFocusChange(true); mWindowListener->windowFocusChange(true);
break; break;
case SDL_WINDOWEVENT_FOCUS_LOST: case SDL_WINDOWEVENT_FOCUS_LOST:
if (mWindowListener) if (mWindowListener)
mWindowListener->windowFocusChange(false); mWindowListener->windowFocusChange(false);
break; break;
case SDL_WINDOWEVENT_CLOSE: case SDL_WINDOWEVENT_CLOSE:
break; break;
case SDL_WINDOWEVENT_SHOWN: case SDL_WINDOWEVENT_SHOWN:
mOgreWindow->setVisible(true); mOgreWindow->setVisible(true);
if (mWindowListener) if (mWindowListener)
mWindowListener->windowVisibilityChange(true); mWindowListener->windowVisibilityChange(true);
break; break;
case SDL_WINDOWEVENT_HIDDEN: case SDL_WINDOWEVENT_HIDDEN:
mOgreWindow->setVisible(false); mOgreWindow->setVisible(false);
if (mWindowListener) if (mWindowListener)
mWindowListener->windowVisibilityChange(false); mWindowListener->windowVisibilityChange(false);
break; break;
} }
} }
bool InputWrapper::isModifierHeld(SDL_Keymod mod) bool InputWrapper::isModifierHeld(SDL_Keymod mod)
{ {
return SDL_GetModState() & mod; return SDL_GetModState() & mod;
} }
bool InputWrapper::isKeyDown(SDL_Scancode key) bool InputWrapper::isKeyDown(SDL_Scancode key)
{ {
return SDL_GetKeyboardState(NULL)[key]; return SDL_GetKeyboardState(NULL)[key];
} }
/// \brief Moves the mouse to the specified point within the viewport /// \brief Moves the mouse to the specified point within the viewport
void InputWrapper::warpMouse(int x, int y) void InputWrapper::warpMouse(int x, int y)

@ -21,7 +21,7 @@ SDLWindowHelper::SDLWindowHelper (SDL_Window* window, int w, int h,
struct SDL_SysWMinfo wmInfo; struct SDL_SysWMinfo wmInfo;
SDL_VERSION(&wmInfo.version); SDL_VERSION(&wmInfo.version);
if (SDL_GetWindowWMInfo(mSDLWindow, &wmInfo) == -1) if (SDL_GetWindowWMInfo(mSDLWindow, &wmInfo) == SDL_FALSE)
throw std::runtime_error("Couldn't get WM Info!"); throw std::runtime_error("Couldn't get WM Info!");
Ogre::String winHandle; Ogre::String winHandle;

Loading…
Cancel
Save