Input Functions

Input functions read controller state for the current script tick. Use them to decide when to start combos, toggle modes, apply output changes, or measure hold timing.

Quick Reference

Function Signature Returns Use
get_val fix32 get_val(int id) Current script-facing value Normal reads used by most scripts
get_actual fix32 get_actual(int id) Physical/translated input value Reads the input before script output changes matter
get_prev fix32 get_prev(int id) Previous translated physical value Manual edge checks and comparisons
is_active int is_active(int id) 1 if active, otherwise 0 Continuous hold checks
is_release int is_release(int id) 1 if inactive, otherwise 0 Continuous release checks
event_active int event_active(int id) 1 for one tick on activation Toggles, menus, one-shot actions
event_release int event_release(int id) 1 for one tick on release Stop actions or detect release edges
time_active int time_active(int id) Time since the latest press transition Transition timing
time_release int time_release(int id) Time since the latest release transition Transition timing and tap windows
check_active int check_active(int id, int ms) 1 when held for at least ms Long press checks
check_release int check_release(int id, int ms) 1 when released for at least ms Release/cooldown checks

Input Values

Use controller constants from Constants as the id argument.

Input kind Typical range
Digital button 0 or 100
Analog trigger 0 to 100
Stick axis -100 to 100

For boolean checks, any non-zero value is treated as active.

get_val

gpc
fix32 get_val(int id);

Returns the current script-facing value for id. This is the read function most scripts use.

Parameter Type Description
id int Controller identifier to read

gpc
main {
    fix32 trigger = get_val(BUTTON_5);

    if (trigger > 50) {
        set_val(BUTTON_5, 100);
    }
}

Because get_val() is script-facing, it can reflect output changes that happened earlier in the same tick. Use get_actual() when you need the physical input view.

get_actual

gpc
fix32 get_actual(int id);

Returns the current physical/translated input value for id, independent of output changes your script makes with set_val().

gpc
main {
    if (get_actual(BUTTON_5) > 0) {
        printf("Physical trigger is down");
    }

    set_val(BUTTON_5, 0);
}

Use get_actual() when a script suppresses or remaps an input but still needs to know what the user is physically doing.

get_prev

gpc
fix32 get_prev(int id);

Returns the previous tick's translated physical value for id. Script output written with set_val() does not become the next get_prev() value.

gpc
main {
    fix32 now = get_val(BUTTON_16);
    fix32 before = get_prev(BUTTON_16);

    if (now > 0 && before == 0) {
        printf("Button became active");
    }
}

Prefer event_active() and event_release() for ordinary edge detection. Use get_prev() when you need custom thresholds or comparisons.

isactive and isrelease

gpc
int is_active(int id);
int is_release(int id);

is_active() returns 1 while the current value is active. is_release() returns 1 while the current value is inactive.

gpc
main {
    if (is_active(BUTTON_9) && is_active(BUTTON_5)) {
        printf("Diagnostic chord active");
    }
}

Use these for continuous state checks. For one-shot toggles, use the event functions instead.

eventactive and eventrelease

gpc
int event_active(int id);
int event_release(int id);

Event functions return 1 for a single tick when an input crosses between inactive and active states.

Function Fires when
event_active(id) The input becomes active this tick
event_release(id) The input becomes inactive this tick

gpc
bool enabled = FALSE;

main {
    if (event_active(BUTTON_11)) {
        enabled = !enabled;
        printf("Enabled: %b", enabled);
    }

    if (event_release(BUTTON_5)) {
        combo_stop(OutputTest);
    }
}

combo OutputTest {
    set_val(BUTTON_16, 100);
    wait(250);
    set_val(BUTTON_16, 0);
    wait(100);
}

Use event_active() for toggles and menus. Checking get_val() directly for a toggle will flip the value every tick while the button is held.

timeactive and timerelease

gpc
int time_active(int id);
int time_release(int id);

Timing functions return milliseconds since the matching physical transition. The timer continues after the input changes to the opposite state, so pair these calls with a state or event check when you mean "currently held" or "currently released."

Function Meaning
time_active(id) Time since the input most recently became active
time_release(id) Time since the input most recently became released

gpc
main {
    if (is_active(BUTTON_1) && time_active(BUTTON_1) > 1000) {
        printf("Button held for over one second");
    }
}

Double Tap Window

gpc
bool waiting_for_second_tap = FALSE;

main {
    if (event_active(BUTTON_16)) {
        if (waiting_for_second_tap && time_release(BUTTON_16) <= 280) {
            printf("Double tap");
            waiting_for_second_tap = FALSE;
        } else {
            waiting_for_second_tap = TRUE;
        }
    }
}

checkactive and checkrelease

gpc
int check_active(int id, int ms);
int check_release(int id, int ms);

These helpers return 1 when the tracked state has lasted at least the requested duration.

Parameter Type Description
id int Controller identifier to check
ms int Required duration in milliseconds

gpc
main {
    if (check_active(BUTTON_4, 750)) {
        printf("Long press");
    }

    if (check_release(BUTTON_16, 250)) {
        // Bottom face button has been released long enough.
    }
}

Compatibility Names

These equivalent names help compatible Titan Two and Cronus scripts compile without rewrites:

Name Equivalent behavior
get_lval(id) get_prev(id)
get_ival(id) get_actual(id)
event_press(id) event_active(id)
get_brtime(id) time_release(id)
block(id, ms) inhibit(id, ms)

get_ptime(id) returns the time spent in the input's current physical state.

Notes

  • Use get_val() for normal script-facing reads.
  • Use get_actual() when output writes should not affect the read.
  • Use get_prev() for the prior translated physical value.
  • Use event_active() for toggles and one-shot actions.
  • Use time_active()/check_active() for hold behavior.
  • Invalid input IDs return an inactive/zero result.