|
|
@ -1,5 +1,15 @@
|
|
|
|
#include "sdlinputwrapper.hpp"
|
|
|
|
#include "sdlinputwrapper.hpp"
|
|
|
|
#include <SDL2/SDL.h>
|
|
|
|
#include <SDL2/SDL.h>
|
|
|
|
|
|
|
|
#include <SDL2/SDL_syswm.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <OgrePlatform.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
|
|
|
|
|
|
|
|
# include <X11/Xlib.h>
|
|
|
|
|
|
|
|
# include <X11/Xutil.h>
|
|
|
|
|
|
|
|
# include <X11/Xos.h>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace MWInput
|
|
|
|
namespace MWInput
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -62,9 +72,45 @@ namespace MWInput
|
|
|
|
size_t windowHnd;
|
|
|
|
size_t windowHnd;
|
|
|
|
mWindow->getCustomAttribute("WINDOW", &windowHnd);
|
|
|
|
mWindow->getCustomAttribute("WINDOW", &windowHnd);
|
|
|
|
|
|
|
|
|
|
|
|
//just use that one for input
|
|
|
|
//kindly ask SDL not to trash our OGL context
|
|
|
|
SDL_Init(flags);
|
|
|
|
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software");
|
|
|
|
|
|
|
|
SDL_Init(SDL_INIT_VIDEO);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//wrap our own event handler around ogre's
|
|
|
|
mSDLWindow = SDL_CreateWindowFrom((void*)windowHnd);
|
|
|
|
mSDLWindow = SDL_CreateWindowFrom((void*)windowHnd);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
|
|
|
|
|
|
|
|
//linux-specific event-handling fixups
|
|
|
|
|
|
|
|
SDL_SysWMinfo wm_info;
|
|
|
|
|
|
|
|
SDL_VERSION(&wm_info.version);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(SDL_GetWindowWMInfo(mSDLWindow,&wm_info))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("SDL version %d.%d.%d\n", wm_info.version.major, wm_info.version.minor, wm_info.version.patch);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Display* display = wm_info.info.x11.display;
|
|
|
|
|
|
|
|
Window w = wm_info.info.x11.window;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set the input hints so we get keyboard input
|
|
|
|
|
|
|
|
XWMHints *wmhints = XAllocWMHints();
|
|
|
|
|
|
|
|
if (wmhints) {
|
|
|
|
|
|
|
|
wmhints->input = True;
|
|
|
|
|
|
|
|
wmhints->flags = InputHint;
|
|
|
|
|
|
|
|
XSetWMHints(display, w, wmhints);
|
|
|
|
|
|
|
|
XFree(wmhints);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//make sure to subscribe to XLib's events
|
|
|
|
|
|
|
|
XSelectInput(display, w,
|
|
|
|
|
|
|
|
(FocusChangeMask | EnterWindowMask | LeaveWindowMask |
|
|
|
|
|
|
|
|
ExposureMask | ButtonPressMask | ButtonReleaseMask |
|
|
|
|
|
|
|
|
PointerMotionMask | KeyPressMask | KeyReleaseMask |
|
|
|
|
|
|
|
|
PropertyChangeMask | StructureNotifyMask |
|
|
|
|
|
|
|
|
KeymapStateMask));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XFlush(display);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|