For the complete documentation index, see llms.txt. This page is also available as Markdown.

2. Beginner: platform-selected confirm button

Difficulty: Beginner

platform-selected-confirm-button.gpc
int confirm_button;
int input_protocol;

init {
    input_protocol = get_controller();

    switch(input_protocol) {
        case PIO_PS5: { confirm_button = PS5_CROSS; break; }
        case PIO_PS4: { confirm_button = PS4_CROSS; break; }
        case PIO_XB1: { confirm_button = XB1_A; break; }
        case PIO_XB360: { confirm_button = XB360_A; break; }
        case PIO_SWITCH: { confirm_button = SWI_B; break; }
        default: { confirm_button = PS5_CROSS; break; }
    }
}

main {
    if(event_press(confirm_button)) {
        set_val(TRACE_1, input_protocol);
    }
}

What it teaches: init, protocol identity, switch, stable runtime identifier.

Last updated