Home › Forums › Logelloop 6 (English spoken) › Matrix Macro Template › Reply To: Matrix Macro Template
3 January 2025 at 17 h 54 min
#6849
Pacocreative
Participant
Currently Matrix “case” and “case_longpress” can be programmed separately and are useful if you want to execute one action on short press down AND another one afterwards on longpress. However, this does not handle the case where you want to execute EITHER short press or longpress, but not both.
Here’s a small routine I use for programming single press vs longpress functionalities on Matrix macros so that when you longpress, the short press code is not executed. It’s usable for non time-critical actions of course, because the short press action is deferred to “case_up” event.
// in the head
Declare Local Once int $m_press_flag$ = 0 // Flag for detecting short/long
// in case branches
CaseBranch "K"
$m_press_flag$ = 1
BreakCaseBranch
CaseBranch "K_longpress"
$m_press_flag$ = 0
// put long press action here
BreakCaseBranch
CaseBranch "K_up"
// exec deferred short press action
If {$m_press_flag$ == 1}
// put deferred short press action here
$m_press_flag$ = 0
EndIf
BreakCaseBranch