GPC3 Overview

GPC3 is a controller scripting language for reading input, changing output, and running timed button or stick sequences. It is C-like, compact, and designed for real-time controller logic.

Use GPC3 when you want to:

  • Remap buttons or sticks
  • Build toggles, holds, and timed actions
  • Adjust analog stick or trigger behavior
  • Read keyboard or mouse state when the host/plugin provides it
  • Write reusable controller scripts with a familiar syntax

Script Shape

A typical script has global variables, an optional init block, a required main block, and optional combo blocks.

gpc
bool alternate_layout = FALSE;

init {
    printf("Script loaded");
}

main {
    if (event_active(BUTTON_11)) {
        alternate_layout = !alternate_layout;
        printf("Alternate layout: %d", alternate_layout);
    }

    if (alternate_layout) {
        fix32 source = get_val(BUTTON_15);
        set_val(BUTTON_14, source);
        set_val(BUTTON_15, 0);
    }
}

How It Runs

init runs once when the script starts.

main runs continuously. Keep it fast and avoid loops that can run forever.

combo blocks run timed sequences. Use wait() inside combos, not in main.

Input translation happens before the script tick, so get_actual() reads the current translated physical input view. get_val() reads the current script-facing value, including changes already made during the tick.

Value Ranges

Most controller values use the Titan-style -100 to 100 range.

Input type Typical range
Digital buttons 0 or 100
Analog triggers 0 to 100
Stick axes -100 to 100
Gyro/accelerometer axes Host-provided axis values

Use fix32 for decimal math, especially stick scaling and smoothing.

Data Types

Type Use it for
int Counters, button states, IDs, whole-number settings
uint Non-negative counters and bit masks
fix32 Decimal stick math and scaling
bool Toggles and enabled/disabled flags
int8, uint8, int16, uint16 Compact values, byte buffers, protocol-style data

Notes

  • Prefer event_active() for toggles. It fires once on the press frame.
  • Prefer get_actual() when you need the physical input even after your script changes output.
  • Clamp stick and trigger output before calling set_val() if your math can exceed normal ranges.
  • Use printf() while building a script, then reduce noisy logs when the script is stable.
  • Host-dependent keyboard and mouse features require a compatible plugin/runtime.
  • If a script compiles but output does not move, verify the host input-to-output path before debugging the script logic.