-Event implemented to remove individual MIDI bindings

This commit is contained in:
Harry van Haaren 2013-11-19 21:51:20 +00:00
parent aabc3ad9d6
commit 9ab22c78b8
5 changed files with 49 additions and 2 deletions

View file

@ -692,6 +692,19 @@ int GenericMIDI::loadController( std::string file )
return LUPPP_RETURN_OK;
}
void GenericMIDI::removeBinding( int bindingID )
{
for(unsigned int i = 0; i < midiToAction.size(); i++)
{
if ( midiToAction.at(i)->ID == bindingID )
{
LUPPP_NOTE("MIDI binding REMOVED with bindingID %i", bindingID );
// CRITICAL FIXME
return;
}
}
}
void GenericMIDI::setupBinding( LupppAction eventType, int midiStatus, int midiData, int track, int scene, int send, int active )
{
LUPPP_NOTE("MIDI binding, track %d, from eventType %d to %d, %d", track, eventType, midiStatus, midiData );

View file

@ -70,6 +70,7 @@ class GenericMIDI : public Controller, public MidiIO
// for adding bindings from MIDI / GUI event pair
void setupBinding( LupppAction eventType, int midiStatus, int midiData, int track, int scene, int send, int active );
void removeBinding( int bindingID );
private:
STATUS stat;

View file

@ -96,6 +96,7 @@ namespace Event
CONTROLLER_BINDING_ENABLE,
CONTROLLER_BINDING_TARGET,
CONTROLLER_BINDING_MADE,
CONTROLLER_BINDING_REMOVE,
QUIT,
@ -133,6 +134,17 @@ class EventControllerBindingMade : public EventBase
EventControllerBindingMade(int id = 0, void* b=0): controllerID(id), binding(b){}
};
class EventControllerBindingRemove : public EventBase
{
public:
int type() { return int(CONTROLLER_BINDING_REMOVE); }
uint32_t size() { return sizeof(EventControllerBindingRemove); }
int controllerID;
int bindingID;
void* binding;
EventControllerBindingRemove(int ctlrID = 0, int bindID=0, void* b=0): controllerID(ctlrID), bindingID(bindID), binding(b){}
};
class EventControllerBindingEnable : public EventBase
{
public:

View file

@ -12,6 +12,7 @@
#include "jack.hxx"
#include "event.hxx"
#include "controller/controller.hxx"
#include "controller/genericmidi.hxx"
#include "eventhandler.hxx"
#include "logic.hxx"
@ -292,6 +293,26 @@ void handleDspEvents()
jack->bindingEventRecordEnable = ev.enable;
} break; }
case Event::CONTROLLER_BINDING_REMOVE: {
if ( availableRead >= sizeof(EventControllerBindingRemove) ) {
EventControllerBindingRemove ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventControllerBindingRemove) );
// get Controller* from controllerID
Controller* c =jack->getControllerUpdater()->getController(ev.controllerID);
// dynamic cast to check for GenericMIDI controller
GenericMIDI* g = dynamic_cast<GenericMIDI*>(c);
if ( g )
{
// kick out BindingID
g->removeBinding( ev.bindingID );
}
else
{
// GUI print notify of error removing binding
}
} break; }
case Event::CONTROLLER_INSTANCE_GET_TO_WRITE: {
if ( availableRead >= sizeof(EventControllerInstanceGetToWrite) ) {
EventControllerInstanceGetToWrite ev;

View file

@ -166,8 +166,8 @@ static void deleteBindingFromController(Fl_Widget* w, void* ud)
s >> tmp;
LUPPP_NOTE("CtlrID %i: Deleting binding with ID %i", self->controllerID, tmp );
EventControllerBindingRemove e( self->controllerID, tmp );
writeToDspRingbuffer( &e );
}