From 98216544dee9877bcf3557b5b1ecb491e421b2bb Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 1 Aug 2013 10:52:50 +0400 Subject: [PATCH 1/3] screw tabs --- extern/sdl4ogre/osx_utils.mm | 9 +-- extern/sdl4ogre/sdlinputwrapper.cpp | 108 ++++++++++++++-------------- 2 files changed, 59 insertions(+), 58 deletions(-) diff --git a/extern/sdl4ogre/osx_utils.mm b/extern/sdl4ogre/osx_utils.mm index 0ba17b30c..4069959cb 100644 --- a/extern/sdl4ogre/osx_utils.mm +++ b/extern/sdl4ogre/osx_utils.mm @@ -1,14 +1,15 @@ #include "osx_utils.h" - #import + namespace SFO { unsigned long WindowContentViewHandle(SDL_SysWMinfo &info) { - NSWindow *window = info.info.cocoa.window; - NSView *view = [window contentView]; - return (unsigned long)view; + NSWindow *window = info.info.cocoa.window; + NSView *view = [window contentView]; + + return (unsigned long)view; } } diff --git a/extern/sdl4ogre/sdlinputwrapper.cpp b/extern/sdl4ogre/sdlinputwrapper.cpp index a6c0e1ccf..4343faaa1 100644 --- a/extern/sdl4ogre/sdlinputwrapper.cpp +++ b/extern/sdl4ogre/sdlinputwrapper.cpp @@ -19,11 +19,11 @@ namespace SFO mMouseZ(0), mMouseY(0), mMouseX(0), - mMouseInWindow(true), - mJoyListener(NULL), - mKeyboardListener(NULL), - mMouseListener(NULL), - mWindowListener(NULL) + mMouseInWindow(true), + mJoyListener(NULL), + mKeyboardListener(NULL), + mMouseListener(NULL), + mWindowListener(NULL) { _setupOISKeys(); } @@ -72,25 +72,25 @@ namespace SFO case SDL_TEXTINPUT: mKeyboardListener->textInput(evt.text); break; - case SDL_JOYAXISMOTION: - if (mJoyListener) - mJoyListener->axisMoved(evt.jaxis, evt.jaxis.axis); - break; - case SDL_JOYBUTTONDOWN: - if (mJoyListener) - mJoyListener->buttonPressed(evt.jbutton, evt.jbutton.button); - break; - case SDL_JOYBUTTONUP: - if (mJoyListener) - mJoyListener->buttonReleased(evt.jbutton, evt.jbutton.button); - break; - case SDL_JOYDEVICEADDED: - //SDL_JoystickOpen(evt.jdevice.which); - //std::cout << "Detected a new joystick: " << SDL_JoystickNameForIndex(evt.jdevice.which) << std::endl; - break; - case SDL_JOYDEVICEREMOVED: - //std::cout << "A joystick has been removed" << std::endl; - break; + case SDL_JOYAXISMOTION: + if (mJoyListener) + mJoyListener->axisMoved(evt.jaxis, evt.jaxis.axis); + break; + case SDL_JOYBUTTONDOWN: + if (mJoyListener) + mJoyListener->buttonPressed(evt.jbutton, evt.jbutton.button); + break; + case SDL_JOYBUTTONUP: + if (mJoyListener) + mJoyListener->buttonReleased(evt.jbutton, evt.jbutton.button); + break; + case SDL_JOYDEVICEADDED: + //SDL_JoystickOpen(evt.jdevice.which); + //std::cout << "Detected a new joystick: " << SDL_JoystickNameForIndex(evt.jdevice.which) << std::endl; + break; + case SDL_JOYDEVICEREMOVED: + //std::cout << "A joystick has been removed" << std::endl; + break; case SDL_WINDOWEVENT: handleWindowEvent(evt); break; @@ -115,61 +115,61 @@ namespace SFO SDL_SetWindowGrab(mSDLWindow, SDL_FALSE); SDL_SetRelativeMouseMode(SDL_FALSE); break; - case SDL_WINDOWEVENT_SIZE_CHANGED: - int w,h; - SDL_GetWindowSize(mSDLWindow, &w, &h); - // TODO: Fix Ogre to handle this more consistently + case SDL_WINDOWEVENT_SIZE_CHANGED: + int w,h; + SDL_GetWindowSize(mSDLWindow, &w, &h); + // TODO: Fix Ogre to handle this more consistently #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX - mOgreWindow->resize(w, h); + mOgreWindow->resize(w, h); #else - mOgreWindow->windowMovedOrResized(); + mOgreWindow->windowMovedOrResized(); #endif - if (mWindowListener) - mWindowListener->windowResized(evt.window.data1, evt.window.data2); + if (mWindowListener) + mWindowListener->windowResized(evt.window.data1, evt.window.data2); - case SDL_WINDOWEVENT_RESIZED: - // TODO: Fix Ogre to handle this more consistently + case SDL_WINDOWEVENT_RESIZED: + // TODO: Fix Ogre to handle this more consistently #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX - mOgreWindow->resize(evt.window.data1, evt.window.data2); + mOgreWindow->resize(evt.window.data1, evt.window.data2); #else - mOgreWindow->windowMovedOrResized(); + mOgreWindow->windowMovedOrResized(); #endif - if (mWindowListener) - mWindowListener->windowResized(evt.window.data1, evt.window.data2); - break; + if (mWindowListener) + mWindowListener->windowResized(evt.window.data1, evt.window.data2); + break; case SDL_WINDOWEVENT_FOCUS_GAINED: - if (mWindowListener) - mWindowListener->windowFocusChange(true); - break; + if (mWindowListener) + mWindowListener->windowFocusChange(true); + break; case SDL_WINDOWEVENT_FOCUS_LOST: - if (mWindowListener) - mWindowListener->windowFocusChange(false); - break; + if (mWindowListener) + mWindowListener->windowFocusChange(false); + break; case SDL_WINDOWEVENT_CLOSE: break; case SDL_WINDOWEVENT_SHOWN: mOgreWindow->setVisible(true); - if (mWindowListener) - mWindowListener->windowVisibilityChange(true); + if (mWindowListener) + mWindowListener->windowVisibilityChange(true); break; case SDL_WINDOWEVENT_HIDDEN: mOgreWindow->setVisible(false); - if (mWindowListener) - mWindowListener->windowVisibilityChange(false); + if (mWindowListener) + mWindowListener->windowVisibilityChange(false); break; } } - bool InputWrapper::isModifierHeld(SDL_Keymod mod) + bool InputWrapper::isModifierHeld(SDL_Keymod mod) { return SDL_GetModState() & mod; } - bool InputWrapper::isKeyDown(SDL_Scancode key) - { - return SDL_GetKeyboardState(NULL)[key]; - } + bool InputWrapper::isKeyDown(SDL_Scancode key) + { + return SDL_GetKeyboardState(NULL)[key]; + } /// \brief Moves the mouse to the specified point within the viewport void InputWrapper::warpMouse(int x, int y) From 4e9ef31375c26c1d4ef5576aee663fb18b8e5f95 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 1 Aug 2013 10:53:28 +0400 Subject: [PATCH 2/3] Added missing(?) break --- extern/sdl4ogre/sdlinputwrapper.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/extern/sdl4ogre/sdlinputwrapper.cpp b/extern/sdl4ogre/sdlinputwrapper.cpp index 4343faaa1..a3e99c187 100644 --- a/extern/sdl4ogre/sdlinputwrapper.cpp +++ b/extern/sdl4ogre/sdlinputwrapper.cpp @@ -126,6 +126,7 @@ namespace SFO #endif if (mWindowListener) mWindowListener->windowResized(evt.window.data1, evt.window.data2); + break; case SDL_WINDOWEVENT_RESIZED: // TODO: Fix Ogre to handle this more consistently From 3849c8488c1a0b45f66549502167051a602abffd Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 1 Aug 2013 10:54:53 +0400 Subject: [PATCH 3/3] Use SDL_False instead of -1 --- extern/sdl4ogre/sdlwindowhelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/sdl4ogre/sdlwindowhelper.cpp b/extern/sdl4ogre/sdlwindowhelper.cpp index 79a214753..f819043cf 100644 --- a/extern/sdl4ogre/sdlwindowhelper.cpp +++ b/extern/sdl4ogre/sdlwindowhelper.cpp @@ -21,7 +21,7 @@ SDLWindowHelper::SDLWindowHelper (SDL_Window* window, int w, int h, struct SDL_SysWMinfo wmInfo; 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!"); Ogre::String winHandle;