123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #ifndef CONTROLLER_H
- #define CONTROLLER_H
- class Controller : public AbsInput
- {
- public:
- Controller(PadDefinition* p=NULL) : AbsInput(p, CONTROLLER) {m_value=-1;}
- Controller(const Controller& b) : AbsInput(b.m_parent, b.type)
- {
- m_value=-1;
- }
- virtual const Controller& operator=(const AbsInput& b)
- {
- AbsInput::operator=(b);
- m_value=(dynamic_cast<const Controller*>(&b))->m_value;
- return *this;
- }
- virtual ~Controller(){}
- int get_value() const { return m_value; }
- protected:
- int m_value;
- virtual void _on_event(const MidiMessage* m){
- int size=m_actions.size();
- for(int i=0; i<size; i++){
- IInputEventListener* l = m_listeners[i];
- switch(m->type){
- case MidiMessage::CONTROLLER_CHANGE:
- {
- const ControllerChange* cc =dynamic_cast<const ControllerChange*>(m) ;
- m_value=cc->velocity;
- l->on_control_change(this, *cc);
- break;
- }
- }
- }
- }
- };
- #endif // CONTROLLER_H
|