This example shows how to create and register an event processor.
This event processor bypasses the key mapping system. It toggles wireframe mode on or off whenever the F key is pressed, regardless of any key mapping to the contrary.
Note: Any functions mapped to the F key in a key map will not be executed, because the event processor returns true, indicating that the event has been handled.
virtual bool processKeyboardEvent(const DtKeyEvent& ev, DtChannel& channel)
{
if (ev.eventType() == DtKeyEvent::KEY_DOWN &&
ev.keyState().keyType() == DtKeyState::KEY_F &&
ev.keyState().modifiers() == DtKeyState::NO_MODIFIER)
{
myDe.sharedState().setWireframeMode(!myDe.sharedState().wireframeMode());
DtWarn("processKeyboardEvent handled\n");
return true;
}
return false;
}
This example is a plug-in. You can run it by running vrvStealth.exe –plugin ../examples/plugins/release/exampleEventProcessor.dll –showConsole (on Windows) or vrvStealth.exe –plugin ../examples/plugins/release/libexampleEventProcessor.so (on Linux) from the command prompt. Once exampleEventProcessor is started press the "f" key to trigger the "processKeyboardEvent" and have a message print out to the console.
#include <boost/bind/bind.hpp>
static vrvSignalsLib::connection postInitializeConnection;
{
public:
MyEventProcessor(
DtDe& de)
: myDe(de)
, myClassName("MyEventProcessor")
{
}
virtual ~MyEventProcessor()
{
}
{
return false;
}
{
{
myDe.sharedState().setWireframeMode(!myDe.sharedState().wireframeMode());
DtWarn("processKeyboardEvent handled\n");
return true;
}
return false;
}
virtual const std::string& className()
{
return myClassName;
}
protected:
DtDe& myDe;
std::string myClassName;
};
void installEventProcessor(
DtDe& de)
{
MyEventProcessor* captureF = new MyEventProcessor(de);
}
{
}
{
{
if (app)
{
}
&installEventProcessor, std::ref(de)));
}
}
{
return true;
}
Contains makVrv::DtDe class.
#define DT_DE_INIT_ONCE(de)
This macro is called by modules in their init() function. This macro ensures that the module is only ...
Definition DtDe.h:30
Contains makVrv::DtDeSharedState class.
Contains makVrv:DtMasterScene class.
Interface for an event processor for a channel.
Contains makVrv::DtKeyMap and related classes.
Contains makVrv::DtKeyMapManager class.
Contains makVrv::DtVrvApplication implementation.
The abstract Channel Class.
Definition DtChannel.h:36
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer,...
Definition DtDe.h:77
virtual bool isInMasterMode() const
Returns true if the DtDe is in master mode.
virtual DtDriverManager & driverManager()
The DtMasterScene accessor. The function will throw before the initialize function is called.
boost::signalslib::signal< void()> signal_postInitialize
Definition DtDe.h:535
The initialization configuration for the makVrv::DtDe.
Definition DtDeInitializer.h:40
DtInputDriver & inputDriver()
Return the DtInputDriver associated with the master scene.
The DtEventProcessorInterface defines the generic interface for classes which handle input events....
Definition DtEventProcessorInterface.h:35
This class encapsulates a Key event.
Definition DtKeyEvent.h:17
const DtKeyState & keyState() const
Get the state object associated with this event.
Definition DtKeyEvent.h:44
DtKeyEvent::KeyEventType eventType() const
Get the event type this event.
Definition DtKeyEvent.h:59
@ KEY_DOWN
Definition DtKeyEvent.h:22
@ KEY_F
Definition DtKeyState.h:61
virtual KeyModifier modifiers() const
get the entire modifier vector instead of using the boolean accessors
@ NO_MODIFIER
Definition DtKeyState.h:137
virtual KeyType keyType() const
Get the type of key.
This class encapsulates a mouse button event.
Definition DtMouseEvent.h:20
A configuration of the pages in the gui.
Definition DtPageConfiguration.h:26
This owns a list of display engine configurations.
Definition DtVrvApplicationConfiguration.h:33
const UIConfiguration & masterModeUIConfiguration() const
void setMasterModePageConfiguration(const DtPageConfiguration &pageConfig)
void setMasterModeToolbarConfiguration(const DtToolbarConfiguration &toolbarConfig)
void setMasterModeMenuConfiguration(const DtMenuConfiguration &menuConfig)
The Root IG Application object. To run the IG simply create one, initialize it and call run.
Definition DtVrvApplication.h:58
static DtVrvApplication * findFromDe(DtDe &)
virtual void installPostPluginTransform(const ApplicationTransform &transform, const std::string &id)
Add a transformer that runs after plug-ins are loaded.
boost::function< void(DtDeInitializer &, DtDe &, DtVrvApplicationConfiguration &)> ApplicationTransform
Definition DtVrvApplication.h:147
DT_DLL_EXAMPLEACCESSORY void init(makVrv::DtDe &de)
Contains DLL export macros.
DT_DE_PLUGIN_EXPORT_MACRO bool initDeModule(makVrv::DtDe *de)
Contains DtCreateSensorFieldOfViewCommand and DtCreateSensorFieldOfViewCommandCreator class declarati...
Definition DtGridLinesSettingsRecord.h:16
bool myShowStartupScreen
Definition DtVrvApplicationConfiguration.h:42