add MIDI Button actions

pull/743/head
Gergo Koteles 2 weeks ago
parent 8c18e60e51
commit c78c9c5a38
  1. 59
      src/config.cpp
  2. 26
      src/config.h
  3. 10
      src/minidexed.ini
  4. 29
      src/uibuttons.cpp
  5. 22
      src/uibuttons.h
  6. 11
      src/userinterface.cpp

@ -174,17 +174,29 @@ void CConfig::Load (void)
m_nMIDIButtonCh = m_Properties.GetNumber ("MIDIButtonCh", 0); m_nMIDIButtonCh = m_Properties.GetNumber ("MIDIButtonCh", 0);
m_nMIDIButtonNotes = m_Properties.GetNumber ("MIDIButtonNotes", 0); m_nMIDIButtonNotes = m_Properties.GetNumber ("MIDIButtonNotes", 0);
m_nMIDIButtonPrev = m_Properties.GetNumber ("MIDIButtonPrev", 0); m_nMIDIButtonPrev = m_Properties.GetNumber ("MIDIButtonPrev", 0);
m_nMIDIButtonNext = m_Properties.GetNumber ("MIDIButtonNext", 0); m_nMIDIButtonNext = m_Properties.GetNumber ("MIDIButtonNext", 0);
m_nMIDIButtonBack = m_Properties.GetNumber ("MIDIButtonBack", 0); m_nMIDIButtonBack = m_Properties.GetNumber ("MIDIButtonBack", 0);
m_nMIDIButtonSelect = m_Properties.GetNumber ("MIDIButtonSelect", 0); m_nMIDIButtonSelect = m_Properties.GetNumber ("MIDIButtonSelect", 0);
m_nMIDIButtonHome = m_Properties.GetNumber ("MIDIButtonHome", 0); m_nMIDIButtonHome = m_Properties.GetNumber ("MIDIButtonHome", 0);
m_MIDIButtonActionPrev = m_Properties.GetString ("MIDIButtonActionPrev", "");
m_MIDIButtonActionNext = m_Properties.GetString ("MIDIButtonActionNext", "");
m_MIDIButtonActionBack = m_Properties.GetString ("MIDIButtonActionBack", "");
m_MIDIButtonActionSelect = m_Properties.GetString ("MIDIButtonActionSelect", "");
m_MIDIButtonActionHome = m_Properties.GetString ("MIDIButtonActionHome", "");
m_nMIDIButtonPgmUp = m_Properties.GetNumber ("MIDIButtonPgmUp", 0); m_nMIDIButtonPgmUp = m_Properties.GetNumber ("MIDIButtonPgmUp", 0);
m_nMIDIButtonPgmDown = m_Properties.GetNumber ("MIDIButtonPgmDown", 0); m_nMIDIButtonPgmDown = m_Properties.GetNumber ("MIDIButtonPgmDown", 0);
m_nMIDIButtonTGUp = m_Properties.GetNumber ("MIDIButtonTGUp", 0); m_nMIDIButtonTGUp = m_Properties.GetNumber ("MIDIButtonTGUp", 0);
m_nMIDIButtonTGDown = m_Properties.GetNumber ("MIDIButtonTGDown", 0); m_nMIDIButtonTGDown = m_Properties.GetNumber ("MIDIButtonTGDown", 0);
m_MIDIButtonActionPgmUp = m_Properties.GetString ("MIDIButtonActionPgmUp", "");
m_MIDIButtonActionPgmDown = m_Properties.GetString ("MIDIButtonActionPgmDown", "");
m_MIDIButtonActionTGUp = m_Properties.GetString ("MIDIButtonActionTGUp", "");
m_MIDIButtonActionTGDown = m_Properties.GetString ("MIDIButtonActionTGDown", "");
m_bEncoderEnabled = m_Properties.GetNumber ("EncoderEnabled", 0) != 0; m_bEncoderEnabled = m_Properties.GetNumber ("EncoderEnabled", 0) != 0;
m_nEncoderPinClock = m_Properties.GetNumber ("EncoderPinClock", 10); m_nEncoderPinClock = m_Properties.GetNumber ("EncoderPinClock", 10);
m_nEncoderPinData = m_Properties.GetNumber ("EncoderPinData", 9); m_nEncoderPinData = m_Properties.GetNumber ("EncoderPinData", 9);
@ -626,6 +638,31 @@ unsigned CConfig::GetMIDIButtonHome (void) const
return m_nMIDIButtonHome; return m_nMIDIButtonHome;
} }
const char *CConfig::GetMIDIButtonActionPrev (void) const
{
return m_MIDIButtonActionPrev.c_str();
}
const char *CConfig::GetMIDIButtonActionNext (void) const
{
return m_MIDIButtonActionNext.c_str();
}
const char *CConfig::GetMIDIButtonActionBack (void) const
{
return m_MIDIButtonActionBack.c_str();
}
const char *CConfig::GetMIDIButtonActionSelect (void) const
{
return m_MIDIButtonActionSelect.c_str();
}
const char *CConfig::GetMIDIButtonActionHome (void) const
{
return m_MIDIButtonActionHome.c_str();
}
unsigned CConfig::GetMIDIButtonPgmUp (void) const unsigned CConfig::GetMIDIButtonPgmUp (void) const
{ {
return m_nMIDIButtonPgmUp; return m_nMIDIButtonPgmUp;
@ -646,6 +683,26 @@ unsigned CConfig::GetMIDIButtonTGDown (void) const
return m_nMIDIButtonTGDown; return m_nMIDIButtonTGDown;
} }
const char *CConfig::GetMIDIButtonActionPgmUp (void) const
{
return m_MIDIButtonActionPgmUp.c_str();
}
const char *CConfig::GetMIDIButtonActionPgmDown (void) const
{
return m_MIDIButtonActionPgmDown.c_str();
}
const char *CConfig::GetMIDIButtonActionTGUp (void) const
{
return m_MIDIButtonActionTGUp.c_str();
}
const char *CConfig::GetMIDIButtonActionTGDown (void) const
{
return m_MIDIButtonActionTGDown.c_str();
}
bool CConfig::GetEncoderEnabled (void) const bool CConfig::GetEncoderEnabled (void) const
{ {
return m_bEncoderEnabled; return m_bEncoderEnabled;

@ -206,18 +206,32 @@ public:
// MIDI Button Navigation // MIDI Button Navigation
unsigned GetMIDIButtonCh (void) const; unsigned GetMIDIButtonCh (void) const;
unsigned GetMIDIButtonNotes (void) const; unsigned GetMIDIButtonNotes (void) const;
unsigned GetMIDIButtonPrev (void) const; unsigned GetMIDIButtonPrev (void) const;
unsigned GetMIDIButtonNext (void) const; unsigned GetMIDIButtonNext (void) const;
unsigned GetMIDIButtonBack (void) const; unsigned GetMIDIButtonBack (void) const;
unsigned GetMIDIButtonSelect (void) const; unsigned GetMIDIButtonSelect (void) const;
unsigned GetMIDIButtonHome (void) const; unsigned GetMIDIButtonHome (void) const;
// Action type for Midi buttons: "click", "doubleclick", "longpress", "dec", "inc", ""
const char *GetMIDIButtonActionPrev (void) const;
const char *GetMIDIButtonActionNext (void) const;
const char *GetMIDIButtonActionBack (void) const;
const char *GetMIDIButtonActionSelect (void) const;
const char *GetMIDIButtonActionHome (void) const;
// MIDI Button Program and TG Selection // MIDI Button Program and TG Selection
unsigned GetMIDIButtonPgmUp (void) const; unsigned GetMIDIButtonPgmUp (void) const;
unsigned GetMIDIButtonPgmDown (void) const; unsigned GetMIDIButtonPgmDown (void) const;
unsigned GetMIDIButtonTGUp (void) const; unsigned GetMIDIButtonTGUp (void) const;
unsigned GetMIDIButtonTGDown (void) const; unsigned GetMIDIButtonTGDown (void) const;
// Action type for buttons: "click", "doubleclick", "longpress", "dec", "inc", ""
const char *GetMIDIButtonActionPgmUp (void) const;
const char *GetMIDIButtonActionPgmDown (void) const;
const char *GetMIDIButtonActionTGUp (void) const;
const char *GetMIDIButtonActionTGDown (void) const;
// KY-040 Rotary Encoder // KY-040 Rotary Encoder
// GPIO pin numbers are chip numbers, not header positions // GPIO pin numbers are chip numbers, not header positions
bool GetEncoderEnabled (void) const; bool GetEncoderEnabled (void) const;
@ -331,6 +345,16 @@ private:
unsigned m_nMIDIButtonTGUp; unsigned m_nMIDIButtonTGUp;
unsigned m_nMIDIButtonTGDown; unsigned m_nMIDIButtonTGDown;
std::string m_MIDIButtonActionPrev;
std::string m_MIDIButtonActionNext;
std::string m_MIDIButtonActionBack;
std::string m_MIDIButtonActionSelect;
std::string m_MIDIButtonActionHome;
std::string m_MIDIButtonActionPgmUp;
std::string m_MIDIButtonActionPgmDown;
std::string m_MIDIButtonActionTGUp;
std::string m_MIDIButtonActionTGDown;
bool m_bEncoderEnabled; bool m_bEncoderEnabled;
unsigned m_nEncoderPinClock; unsigned m_nEncoderPinClock;
unsigned m_nEncoderPinData; unsigned m_nEncoderPinData;

@ -118,15 +118,25 @@ LongPressTimeout=400
# Note numbers, triggered with NoteOn/NoteOff, not CC numbers. # Note numbers, triggered with NoteOn/NoteOff, not CC numbers.
MIDIButtonCh=0 MIDIButtonCh=0
MIDIButtonNotes=0 MIDIButtonNotes=0
MIDIButtonPrev=0 MIDIButtonPrev=0
MIDIButtonActionPrev=
MIDIButtonNext=0 MIDIButtonNext=0
MIDIButtonActionNext=
MIDIButtonBack=0 MIDIButtonBack=0
MIDIButtonActionBack=
MIDIButtonSelect=0 MIDIButtonSelect=0
MIDIButtonActionSelect=
MIDIButtonHome=0 MIDIButtonHome=0
MIDIButtonActionHome=
MIDIButtonPgmUp=0 MIDIButtonPgmUp=0
MIDIButtonActionPgmUp=
MIDIButtonPgmDown=0 MIDIButtonPgmDown=0
MIDIButtonActionPgmDown=
MIDIButtonTGUp=0 MIDIButtonTGUp=0
MIDIButtonActionTGUp=
MIDIButtonTGDown=0 MIDIButtonTGDown=0
MIDIButtonActionTGDown=
# KY-040 Rotary Encoder # KY-040 Rotary Encoder
EncoderEnabled=1 EncoderEnabled=1

@ -268,8 +268,16 @@ CUIButtons::CUIButtons (
unsigned TGUpPin, const char *TGUpAction, unsigned TGUpPin, const char *TGUpAction,
unsigned TGDownPin, const char *TGDownAction, unsigned TGDownPin, const char *TGDownAction,
unsigned doubleClickTimeout, unsigned longPressTimeout, unsigned doubleClickTimeout, unsigned longPressTimeout,
unsigned notesMidi, unsigned prevMidi, unsigned nextMidi, unsigned backMidi, unsigned selectMidi, unsigned homeMidi, unsigned notesMidi,
unsigned pgmUpMidi, unsigned pgmDownMidi, unsigned TGUpMidi, unsigned TGDownMidi unsigned prevMidi, const char *prevMidiAction,
unsigned nextMidi, const char *nextMidiAction,
unsigned backMidi, const char *backMidiAction,
unsigned selectMidi, const char *selectMidiAction,
unsigned homeMidi, const char *homeMidiAction,
unsigned pgmUpMidi, const char *pgmUpMidiAction,
unsigned pgmDownMidi, const char *pgmDownMidiAction,
unsigned TGUpMidi, const char *TGUpMidiAction,
unsigned TGDownMidi, const char *TGDownMidiAction
) )
: m_doubleClickTimeout(doubleClickTimeout), : m_doubleClickTimeout(doubleClickTimeout),
m_longPressTimeout(longPressTimeout), m_longPressTimeout(longPressTimeout),
@ -293,14 +301,23 @@ CUIButtons::CUIButtons (
m_TGDownAction(CUIButton::triggerTypeFromString(TGDownAction)), m_TGDownAction(CUIButton::triggerTypeFromString(TGDownAction)),
m_notesMidi(notesMidi), m_notesMidi(notesMidi),
m_prevMidi(ccToMidiPin(prevMidi)), m_prevMidi(ccToMidiPin(prevMidi)),
m_prevMidiAction(CUIButton::triggerTypeFromString(prevMidiAction)),
m_nextMidi(ccToMidiPin(nextMidi)), m_nextMidi(ccToMidiPin(nextMidi)),
m_nextMidiAction(CUIButton::triggerTypeFromString(nextMidiAction)),
m_backMidi(ccToMidiPin(backMidi)), m_backMidi(ccToMidiPin(backMidi)),
m_backMidiAction(CUIButton::triggerTypeFromString(backMidiAction)),
m_selectMidi(ccToMidiPin(selectMidi)), m_selectMidi(ccToMidiPin(selectMidi)),
m_selectMidiAction(CUIButton::triggerTypeFromString(selectMidiAction)),
m_homeMidi(ccToMidiPin(homeMidi)), m_homeMidi(ccToMidiPin(homeMidi)),
m_homeMidiAction(CUIButton::triggerTypeFromString(homeMidiAction)),
m_pgmUpMidi(ccToMidiPin(pgmUpMidi)), m_pgmUpMidi(ccToMidiPin(pgmUpMidi)),
m_pgmUpMidiAction(CUIButton::triggerTypeFromString(pgmUpMidiAction)),
m_pgmDownMidi(ccToMidiPin(pgmDownMidi)), m_pgmDownMidi(ccToMidiPin(pgmDownMidi)),
m_pgmDownMidiAction(CUIButton::triggerTypeFromString(pgmDownMidiAction)),
m_TGUpMidi(ccToMidiPin(TGUpMidi)), m_TGUpMidi(ccToMidiPin(TGUpMidi)),
m_TGUpMidiAction(CUIButton::triggerTypeFromString(TGUpMidiAction)),
m_TGDownMidi(ccToMidiPin(TGDownMidi)), m_TGDownMidi(ccToMidiPin(TGDownMidi)),
m_TGDownMidiAction(CUIButton::triggerTypeFromString(TGDownMidiAction)),
m_eventHandler (0), m_eventHandler (0),
m_lastTick (0) m_lastTick (0)
{ {
@ -330,7 +347,7 @@ boolean CUIButtons::Initialize (void)
// Each normal button can be assigned up to 3 actions: click, doubleclick and // Each normal button can be assigned up to 3 actions: click, doubleclick and
// longpress. We may not initialise all of the buttons. // longpress. We may not initialise all of the buttons.
// MIDI buttons only support a single click. // MIDI buttons can be assigned to click, doubleclick, lopngpress
unsigned pins[MAX_BUTTONS] = { unsigned pins[MAX_BUTTONS] = {
m_prevPin, m_nextPin, m_backPin, m_selectPin, m_homePin, m_pgmUpPin, m_pgmDownPin, m_TGUpPin, m_TGDownPin, m_prevPin, m_nextPin, m_backPin, m_selectPin, m_homePin, m_pgmUpPin, m_pgmDownPin, m_TGUpPin, m_TGDownPin,
m_prevMidi, m_nextMidi, m_backMidi, m_selectMidi, m_homeMidi, m_pgmUpMidi, m_pgmDownMidi, m_TGUpMidi, m_TGDownMidi m_prevMidi, m_nextMidi, m_backMidi, m_selectMidi, m_homeMidi, m_pgmUpMidi, m_pgmDownMidi, m_TGUpMidi, m_TGDownMidi
@ -339,9 +356,9 @@ boolean CUIButtons::Initialize (void)
// Normal buttons // Normal buttons
m_prevAction, m_nextAction, m_backAction, m_selectAction, m_homeAction, m_prevAction, m_nextAction, m_backAction, m_selectAction, m_homeAction,
m_pgmUpAction, m_pgmDownAction, m_TGUpAction, m_TGDownAction, m_pgmUpAction, m_pgmDownAction, m_TGUpAction, m_TGDownAction,
// MIDI Buttons only support a single click (at present) // MIDI buttons
CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, m_prevMidiAction, m_nextMidiAction, m_backMidiAction, m_selectMidiAction, m_homeMidiAction,
CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick m_pgmUpMidiAction, m_pgmDownMidiAction, m_TGUpMidiAction, m_TGDownMidiAction,
}; };
CUIButton::BtnEvent events[MAX_BUTTONS] = { CUIButton::BtnEvent events[MAX_BUTTONS] = {
// Normal buttons // Normal buttons

@ -122,8 +122,16 @@ public:
unsigned TGUpPin, const char *TGUpAction, unsigned TGUpPin, const char *TGUpAction,
unsigned TGDownPin, const char *TGDownAction, unsigned TGDownPin, const char *TGDownAction,
unsigned doubleClickTimeout, unsigned longPressTimeout, unsigned doubleClickTimeout, unsigned longPressTimeout,
unsigned notesMidi, unsigned prevMidi, unsigned nextMidi, unsigned backMidi, unsigned selectMidi, unsigned homeMidi, unsigned notesMidi,
unsigned pgmUpMidi, unsigned pgmDownMidi, unsigned TGUpMidi, unsigned TGDownMidi unsigned prevMidi, const char *prevMidiAction,
unsigned nextMidi, const char *nextMidiAction,
unsigned backMidi, const char *backMidiAction,
unsigned selectMidi, const char *selectMidiAction,
unsigned homeMidi, const char *homeMidiAction,
unsigned pgmUpMidi, const char *pgmUpMidiAction,
unsigned pgmDownMidi, const char *pgmDownMidiAction,
unsigned TGUpMidi, const char *TGUpMidiAction,
unsigned TGDownMidi, const char *TGDownMidiAction
); );
~CUIButtons (void); ~CUIButtons (void);
@ -170,16 +178,26 @@ private:
// MIDI button configuration // MIDI button configuration
unsigned m_notesMidi; unsigned m_notesMidi;
unsigned m_prevMidi; unsigned m_prevMidi;
CUIButton::BtnTrigger m_prevMidiAction;
unsigned m_nextMidi; unsigned m_nextMidi;
CUIButton::BtnTrigger m_nextMidiAction;
unsigned m_backMidi; unsigned m_backMidi;
CUIButton::BtnTrigger m_backMidiAction;
unsigned m_selectMidi; unsigned m_selectMidi;
CUIButton::BtnTrigger m_selectMidiAction;
unsigned m_homeMidi; unsigned m_homeMidi;
CUIButton::BtnTrigger m_homeMidiAction;
unsigned m_pgmUpMidi; unsigned m_pgmUpMidi;
CUIButton::BtnTrigger m_pgmUpMidiAction;
unsigned m_pgmDownMidi; unsigned m_pgmDownMidi;
CUIButton::BtnTrigger m_pgmDownMidiAction;
unsigned m_TGUpMidi; unsigned m_TGUpMidi;
CUIButton::BtnTrigger m_TGUpMidiAction;
unsigned m_TGDownMidi; unsigned m_TGDownMidi;
CUIButton::BtnTrigger m_TGDownMidiAction;
BtnEventHandler *m_eventHandler; BtnEventHandler *m_eventHandler;
void *m_eventParam; void *m_eventParam;

@ -184,14 +184,23 @@ bool CUserInterface::Initialize (void)
m_pConfig->GetLongPressTimeout (), m_pConfig->GetLongPressTimeout (),
m_pConfig->GetMIDIButtonNotes (), m_pConfig->GetMIDIButtonNotes (),
m_pConfig->GetMIDIButtonPrev (), m_pConfig->GetMIDIButtonPrev (),
m_pConfig->GetMIDIButtonActionPrev (),
m_pConfig->GetMIDIButtonNext (), m_pConfig->GetMIDIButtonNext (),
m_pConfig->GetMIDIButtonActionNext (),
m_pConfig->GetMIDIButtonBack (), m_pConfig->GetMIDIButtonBack (),
m_pConfig->GetMIDIButtonActionBack (),
m_pConfig->GetMIDIButtonSelect (), m_pConfig->GetMIDIButtonSelect (),
m_pConfig->GetMIDIButtonActionSelect (),
m_pConfig->GetMIDIButtonHome (), m_pConfig->GetMIDIButtonHome (),
m_pConfig->GetMIDIButtonActionHome (),
m_pConfig->GetMIDIButtonPgmUp (), m_pConfig->GetMIDIButtonPgmUp (),
m_pConfig->GetMIDIButtonActionPgmUp (),
m_pConfig->GetMIDIButtonPgmDown (), m_pConfig->GetMIDIButtonPgmDown (),
m_pConfig->GetMIDIButtonActionPgmDown (),
m_pConfig->GetMIDIButtonTGUp (), m_pConfig->GetMIDIButtonTGUp (),
m_pConfig->GetMIDIButtonTGDown () m_pConfig->GetMIDIButtonActionTGUp (),
m_pConfig->GetMIDIButtonTGDown (),
m_pConfig->GetMIDIButtonActionTGDown ()
); );
assert (m_pUIButtons); assert (m_pUIButtons);

Loading…
Cancel
Save