forked from teamnwah/openmw-tes3coop
Fixed up the OIS->MyGUI event dispatcher
This commit is contained in:
parent
69a56e8677
commit
fedb1a8025
3 changed files with 50 additions and 13 deletions
|
@ -3,24 +3,59 @@
|
||||||
|
|
||||||
#include "events.hpp"
|
#include "events.hpp"
|
||||||
|
|
||||||
using namespace MyGUI;
|
|
||||||
using namespace OIS;
|
using namespace OIS;
|
||||||
using namespace OEngine::GUI;
|
using namespace OEngine::GUI;
|
||||||
|
|
||||||
void EventInjector::event(Type type, int index, const void *p)
|
void EventInjector::event(Type type, int index, const void *p)
|
||||||
{
|
{
|
||||||
if(enabled) return;
|
if(!enabled) return;
|
||||||
|
|
||||||
KeyEvent *key = (KeyEvent*)p;
|
if(type & EV_Keyboard)
|
||||||
MouseEvent *mouse = (MouseEvent*)p;
|
|
||||||
MouseButtonID id = (MouseButtonID)index;
|
|
||||||
|
|
||||||
switch(type)
|
|
||||||
{
|
{
|
||||||
case EV_KeyDown: gui->injectKeyPress(key); break;
|
KeyEvent *key = (KeyEvent*)p;
|
||||||
case EV_KeyUp: gui->injectKeyRelease(key); break;
|
MyGUI::KeyCode code = MyGUI::KeyCode::Enum(key->key);
|
||||||
case EV_MouseDown: gui->injectMousePress(mouse, id); break;
|
if(type == EV_KeyDown)
|
||||||
case EV_MouseUp: gui->injectMouseRelease(mouse, id); break;
|
{
|
||||||
case EV_MouseMove: gui->injectMouseMove(mouse); break;
|
/*
|
||||||
|
This is just a first approximation. Apparently, OIS sucks
|
||||||
|
to such a degree that it's unable to provide any sort of
|
||||||
|
reliable unicode character on all platforms and for all
|
||||||
|
keys. At least that's what I surmise from the amount of
|
||||||
|
workaround that the MyGUI folks have put in place for
|
||||||
|
this. See Common/Input/OIS/InputManager.cpp in the MyGUI
|
||||||
|
sources for details. If this is indeed necessary (I
|
||||||
|
haven't tested that it is, although I have had dubious
|
||||||
|
experinces with OIS events in the past), then we should
|
||||||
|
probably adapt all that code here. Or even better,
|
||||||
|
directly into the OIS input manager in Mangle.
|
||||||
|
|
||||||
|
Note that all this only affects the 'text' field, and
|
||||||
|
should thus only affect typed text in input boxes (which
|
||||||
|
is still pretty significant.)
|
||||||
|
*/
|
||||||
|
MyGUI::Char text = (MyGUI::Char)key->text;
|
||||||
|
gui->injectKeyPress(code,text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gui->injectKeyRelease(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(type & EV_Mouse)
|
||||||
|
{
|
||||||
|
MouseEvent *mouse = (MouseEvent*)p;
|
||||||
|
MyGUI::MouseButton id = MyGUI::MouseButton::Enum(index);
|
||||||
|
|
||||||
|
// I'm not sure these should be used directly, MyGUI demo code
|
||||||
|
// use local mouse position variables.
|
||||||
|
int mouseX = mouse->state.X.abs;
|
||||||
|
int mouseY = mouse->state.Y.abs;
|
||||||
|
|
||||||
|
if(type == EV_MouseDown)
|
||||||
|
gui->injectMousePress(mouseX, mouseY, id);
|
||||||
|
else if(type == EV_MouseUp)
|
||||||
|
gui->injectMouseRelease(mouseX, mouseY, id);
|
||||||
|
else
|
||||||
|
gui->injectMouseMove(mouseX, mouseY, mouse->state.Z.abs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace GUI
|
||||||
{
|
{
|
||||||
/** Event handler that injects OIS events into MyGUI
|
/** Event handler that injects OIS events into MyGUI
|
||||||
*/
|
*/
|
||||||
class EventInjector : Mangle::Input::Event
|
class EventInjector : public Mangle::Input::Event
|
||||||
{
|
{
|
||||||
MyGUI::Gui *gui;
|
MyGUI::Gui *gui;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@ namespace GUI
|
||||||
|
|
||||||
void setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false);
|
void setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false);
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
MyGUI::Gui *getGui() { return mGui; }
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue