Input Sequencing Examples
These patterns show how to produce short, deliberate output sequences for controller testing and accessible controls. Use edge events so a physical press starts one sequence instead of continuously repeating it.
Single Diagnostic Pulse
gpc
main {
if (event_active(BUTTON_5)) {
combo_restart(OutputTest);
}
}
combo OutputTest {
set_val(BUTTON_15, 100);
wait(120);
set_val(BUTTON_15, 0);
}Use this pattern to confirm that a selected output path is working.
Multi-Step Device Test
gpc
main {
if (event_active(BUTTON_11)) {
combo_restart(FaceButtonTest);
}
}
combo FaceButtonTest {
set_val(BUTTON_16, 100);
wait(100);
set_val(BUTTON_16, 0);
wait(100);
set_val(BUTTON_13, 100);
wait(100);
set_val(BUTTON_13, 0);
wait(100);
set_val(BUTTON_14, 100);
wait(100);
set_val(BUTTON_14, 0);
wait(100);
set_val(BUTTON_15, 100);
wait(100);
set_val(BUTTON_15, 0);
}The sequence makes it easier to verify button order in Device Monitor or on a connected test target.
Long-Press Conversion
gpc
int held_ms = 0;
int threshold_ms = 600;
bool handled = FALSE;
main {
if (get_val(BUTTON_5) > 50) {
held_ms = held_ms + elapsed_time();
if (!handled && held_ms >= threshold_ms) {
combo_restart(ConfirmedAction);
handled = TRUE;
}
} else {
held_ms = 0;
handled = FALSE;
}
}
combo ConfirmedAction {
set_val(BUTTON_15, 100);
wait(120);
set_val(BUTTON_15, 0);
}This gives an action a deliberate hold threshold, which can reduce accidental activation.
Reusable Test Steps
gpc
combo TestLeftButton {
set_val(BUTTON_16, 100);
wait(100);
set_val(BUTTON_16, 0);
wait(100);
}
combo TestRightButton {
set_val(BUTTON_14, 100);
wait(100);
set_val(BUTTON_14, 0);
wait(100);
}
combo PairedButtonTest {
call(TestLeftButton);
call(TestRightButton);
}
main {
if (event_active(BUTTON_11)) {
combo_restart(PairedButtonTest);
}
}Use call() to compose a longer diagnostic sequence from small, reusable steps.
Button Swap
gpc
main {
fix32 bottom_face = get_val(BUTTON_16);
fix32 right_face = get_val(BUTTON_15);
set_val(BUTTON_16, right_face);
set_val(BUTTON_15, bottom_face);
}Read both values before writing either output so the source values are preserved for the swap.