You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ovaCNeurofeedbackSwitch.cpp 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "ovaCNeurofeedbackSwitch.h"
  2. REGISTER_OBJECT_FACTORY(CNeurofeedbackSwitch, "ovaCNeurofeedbackSwitch");
  3. CNeurofeedbackSwitch::CNeurofeedbackSwitch(OMK::Controller& controller, const OMK::ObjectDescriptor& objectDesc)
  4. :OMK::SimulatedObject(controller, objectDesc)
  5. {
  6. }
  7. CNeurofeedbackSwitch::~CNeurofeedbackSwitch()
  8. {
  9. }
  10. void CNeurofeedbackSwitch::init()
  11. {
  12. _FarAway_[0] = 1000;
  13. _FarAway_[1] = 1000;
  14. _FarAway_[2] = 1000;
  15. _Position_[0] = 0;
  16. _Position_[1] = 0;
  17. _Position_[2] = 0;
  18. sendValuedEvent("OpenViBE_ball", g_sManipulate3DEntity_SetPosition, PositionType(_FarAway_));
  19. sendValuedEvent("OpenViBE_passive_ball", g_sManipulate3DEntity_SetPosition, PositionType(_FarAway_));
  20. registerForSignal(g_sVrpnButtonStateUpdate);
  21. }
  22. void CNeurofeedbackSwitch::compute()
  23. {
  24. }
  25. bool CNeurofeedbackSwitch::processEvent(OMK::Event* pEvent)
  26. {
  27. if (pEvent->eventId == g_sVrpnButtonStateUpdate)
  28. {
  29. VrpnButtonStateEvent* event = dynamic_cast <VrpnButtonStateEvent*>(pEvent);
  30. if (event)
  31. {
  32. const VrpnButtonState& vrpnButtonState = event->value;
  33. if (vrpnButtonState.first<int(sizeof(m_button) / sizeof(m_button[0])))
  34. {
  35. m_button[vrpnButtonState.first] = (vrpnButtonState.second ? true : false);
  36. #if _DEBUG_
  37. std::cout << "got event " << *event << std::endl;
  38. #endif
  39. sendValuedEvent("OpenViBE_ball", g_sManipulate3DEntity_SetPosition, PositionType(m_button[2] ? _Position_ : _FarAway_));
  40. sendValuedEvent("OpenViBE_passive_ball", g_sManipulate3DEntity_SetPosition, PositionType(m_button[3] ? _Position_ : _FarAway_));
  41. }
  42. }
  43. return true;
  44. }
  45. return false;
  46. }