mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-06 19:01:21 +03:00
Added event listeners (mouselook and gui injector) and exit listener for Ogre
This commit is contained in:
parent
e55ef227fe
commit
b9b306cd4c
7 changed files with 178 additions and 2 deletions
23
gui/events.cpp
Normal file
23
gui/events.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <MyGUI.h>
|
||||
#include <OIS/OIS.h>
|
||||
|
||||
using namespace MyGUI;
|
||||
using namespace OIS;
|
||||
|
||||
void EventInjector::event(Type type, int index, const void *p)
|
||||
{
|
||||
if(enabled) return;
|
||||
|
||||
KeyEvent *key = (KeyEvent*)p;
|
||||
MouseEvent *mouse = (MouseEvent*)p;
|
||||
MouseButtonID id = (MouseButtonID)index;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case EV_KeyDown: gui->injectKeyPress(key); break;
|
||||
case EV_KeyUp: gui->injectKeyRelease(key); break;
|
||||
case EV_MouseDown: gui->injectMousePress(mouse, id); break;
|
||||
case EV_MouseUp: gui->injectMouseRelease(mouse, id); break;
|
||||
case EV_MouseMove: gui->injectMouseMove(mouse); break;
|
||||
}
|
||||
}
|
26
gui/events.hpp
Normal file
26
gui/events.hpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef OENGINE_MYGUI_EVENTS_H
|
||||
#define OENGINE_MYGUI_EVENTS_H
|
||||
|
||||
#include <mangle/input/event.hpp>
|
||||
|
||||
namespace MyGUI
|
||||
{
|
||||
class Gui;
|
||||
}
|
||||
|
||||
namespace GUI
|
||||
{
|
||||
/** Event handler that injects OIS events into MyGUI
|
||||
*/
|
||||
class EventInjector : Mangle::Input::Event
|
||||
{
|
||||
MyGUI::Gui *gui;
|
||||
|
||||
public:
|
||||
bool enabled;
|
||||
|
||||
EventInjector(MyGUI::Gui *g) : gui(g), enabled(true) {}
|
||||
void event(Type type, int index, const void *p);
|
||||
};
|
||||
}
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue