Public Member Functions | Static Public Member Functions

mitk::WiiMoteAddOn Class Reference
[Interaction Classes]

EventMapper addon for a Wiimote. More...

#include <mitkWiiMoteAddOn.h>

Inheritance diagram for mitk::WiiMoteAddOn:
Inheritance graph
[legend]
Collaboration diagram for mitk::WiiMoteAddOn:
Collaboration graph
[legend]

List of all members.

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 WiiMoteAddOnGetInstance ()

Detailed Description

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.


Constructor & Destructor Documentation

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();
}

Member Function Documentation

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]
mitk::WiiMoteAddOn * mitk::WiiMoteAddOn::GetInstance (  ) [static]
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;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines