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

5. Intermediate: one-writer stick pipeline

Difficulty: Intermediate

one-writer-stick-pipeline.gpc
define GAIN_PERCENT = 125;

int raw_x;
int raw_y;
int final_x;
int final_y;

main {
    raw_x = get_ival(PS5_RX);
    raw_y = get_ival(PS5_RY);

    final_x = (raw_x * GAIN_PERCENT) / 100;
    final_y = (raw_y * GAIN_PERCENT) / 100;

    final_x = bound_axis(final_x);
    final_y = bound_axis(final_y);

    set_val(PS5_RX, final_x);
    set_val(PS5_RY, final_y);

    set_val(TRACE_1, raw_x);
    set_val(TRACE_2, final_x);
}

function bound_axis(value) {
    if(value < -100) return -100;
    if(value > 100) return 100;
    return value;
}

What it teaches: scaled integer math, clamping without excluded helpers, final writer.

Last updated