Controller.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef CONTROLLER_H
  2. #define CONTROLLER_H
  3. class Controller : public AbsInput
  4. {
  5. public:
  6. Controller(PadDefinition* p=NULL) : AbsInput(p, CONTROLLER) {m_value=-1;}
  7. Controller(const Controller& b) : AbsInput(b.m_parent, b.type)
  8. {
  9. m_value=-1;
  10. }
  11. virtual const Controller& operator=(const AbsInput& b)
  12. {
  13. AbsInput::operator=(b);
  14. m_value=(dynamic_cast<const Controller*>(&b))->m_value;
  15. return *this;
  16. }
  17. virtual ~Controller(){}
  18. int get_value() const { return m_value; }
  19. protected:
  20. int m_value;
  21. virtual void _on_event(const MidiMessage* m){
  22. int size=m_actions.size();
  23. for(int i=0; i<size; i++){
  24. IInputEventListener* l = m_listeners[i];
  25. switch(m->type){
  26. case MidiMessage::CONTROLLER_CHANGE:
  27. {
  28. const ControllerChange* cc =dynamic_cast<const ControllerChange*>(m) ;
  29. m_value=cc->velocity;
  30. l->on_control_change(this, *cc);
  31. break;
  32. }
  33. }
  34. }
  35. }
  36. };
  37. #endif // CONTROLLER_H