EventMapper addon for a Wiimote. More...
#include <mitkWiiMoteAddOn.h>


Public Member Functions | |
| WiiMoteAddOn () | |
| ~WiiMoteAddOn () | |
| void | ForwardEvent (const mitk::StateEvent *e) |
| void | ActivateWiiMotes () |
| void | DeactivateWiiMotes () |
| void | WiiMoteInput (const itk::EventObject &e) |
| void | WiiMoteButtonPressed (const itk::EventObject &e) |
| void | WiiMoteCalibrationInput (const itk::EventObject &e) |
Static Public Member Functions | |
| static WiiMoteAddOn * | GetInstance () |
EventMapper addon for a Wiimote.
Documentation in the interface. Some code snippets used here are from the demo
application from gl.tter and therefore are under the same license as wiimote.cpp .
Definition at line 25 of file mitkWiiMoteAddOn.h.
| mitk::WiiMoteAddOn::WiiMoteAddOn | ( | ) |
Definition at line 14 of file mitkWiiMoteAddOn.cpp.
: m_WiiMoteThread(NULL)
{
}
| mitk::WiiMoteAddOn::~WiiMoteAddOn | ( | ) |
Definition at line 18 of file mitkWiiMoteAddOn.cpp.
{
this->DeactivateWiiMotes();
}
| void mitk::WiiMoteAddOn::ActivateWiiMotes | ( | ) |
Starts all available Wiimotes.
Definition at line 23 of file mitkWiiMoteAddOn.cpp.
{
if(m_WiiMoteThread == NULL)
{
m_WiiMoteThread = new WiiMoteThread();
m_WiiMoteThread->Run();
}
}
| void mitk::WiiMoteAddOn::DeactivateWiiMotes | ( | ) |
Disconnects all Wiimotes and stops the thread.
Definition at line 32 of file mitkWiiMoteAddOn.cpp.
{
if(m_WiiMoteThread != NULL)
{
m_WiiMoteThread->StopWiiMote();
//needed, otherwise the mutex wants to unlock
//when the object is already destroyed
Sleep(1000);
m_WiiMoteThread->Delete();
m_WiiMoteThread = NULL;
}
}
| void mitk::WiiMoteAddOn::ForwardEvent | ( | const mitk::StateEvent * | e ) | [virtual] |
Implements mitk::EventMapperAddOn.
Definition at line 86 of file mitkWiiMoteAddOn.cpp.
References mitk::GlobalInteraction::GetInstance(), and mitk::StateMachine::HandleEvent().
{
mitk::GlobalInteraction::GetInstance()->HandleEvent(e);
}
| mitk::WiiMoteAddOn * mitk::WiiMoteAddOn::GetInstance | ( | ) | [static] |
Definition at line 8 of file mitkWiiMoteAddOn.cpp.
Referenced by mitk::WiiMoteThread::WiiMoteButtonPressed(), mitk::WiiMoteThread::WiiMoteCalibrationInput(), and mitk::WiiMoteThread::WiiMoteIRInput().
{
static WiiMoteAddOn instance;
return &instance;
}
| void mitk::WiiMoteAddOn::WiiMoteButtonPressed | ( | const itk::EventObject & | e ) |
Creates suitable events, when the Wiimote sends button events
and forwards it for further processing.
Definition at line 56 of file mitkWiiMoteAddOn.cpp.
References mitk::EV_INIT, mitk::Event::GetKey(), mitk::Key_A, and mitk::Key_Home.
Referenced by mitk::WiiMoteThread::WiiMoteButtonPressed().
{
mitk::WiiMoteButtonEvent const* wiiEvent = (const mitk::WiiMoteButtonEvent*)(&e);
int key = wiiEvent->GetKey();
mitk::StateEvent* se;
switch(key)
{
case mitk::Key_Home:
se = new mitk::StateEvent(mitk::EIDWIIMOTEBUTTON, wiiEvent);
break;
case mitk::Key_A:
se = new mitk::StateEvent(mitk::EV_INIT, wiiEvent);
break;
}
if(se != NULL)
{
this->ForwardEvent(se);
delete se;
}
}
| void mitk::WiiMoteAddOn::WiiMoteCalibrationInput | ( | const itk::EventObject & | e ) |
Creates suitable events, when the Wiimote sends IR data
to configure the sensitivity and forwards it for further processing.
Definition at line 79 of file mitkWiiMoteAddOn.cpp.
Referenced by mitk::WiiMoteThread::WiiMoteCalibrationInput().
{
mitk::StateEvent* se = new mitk::StateEvent(mitk::EIDWIIMOTEINPUT, (const mitk::WiiMoteCalibrationEvent*)&e);
this->ForwardEvent(se);
delete se;
}
| void mitk::WiiMoteAddOn::WiiMoteInput | ( | const itk::EventObject & | e ) |
Creates suitable events, when the Wiimote sends IR data
and forwards it for further processing.
Definition at line 47 of file mitkWiiMoteAddOn.cpp.
Referenced by mitk::WiiMoteThread::WiiMoteIRInput().
{
// apparently the dynamic cast does not work here
// reason unknown - the normal cast however works fine
mitk::StateEvent* se = new mitk::StateEvent(mitk::EIDWIIMOTEINPUT, (const mitk::WiiMoteIREvent*)&e);
this->ForwardEvent(se);
delete se;
}
1.7.2