> For the complete documentation index, see [llms.txt](https://guide.cronuszen.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.cronuszen.com/gpcscripting/gpc-script-guide/reference/core-built-ins.md).

# Core built-ins

This reference follows the existing GPC guide style: description, syntax, parameters, returns, and example. Deprecated but still recognized compatibility aliases are included and clearly marked.

The remaining built-ins are organized by topic in the [additional built-in](/gpcscripting/gpc-script-guide/reference/additional-built-ins.md) reference. Combo controls and commands have their own [combo reference](/gpcscripting/gpc-script-guide/reference/combo-reference.md).

For exact counts and what falls outside the scope of this guide, see [Scope and limits](/gpcscripting/gpc-script-guide/reference/scope-and-limits.md).

### Controller input and transformation

<table data-search="false"><thead><tr><th>Function</th><th>Purpose</th></tr></thead><tbody><tr><td><code>turn_off</code></td><td>Turns off the wireless controller connected to the Zen input port.</td></tr><tr><td><code>get_battery</code></td><td>Returns the connected wireless controller battery state: 0 discharged, 10 fully charged, and 11 charging.</td></tr><tr><td><code>get_controller</code></td><td>Returns the protocol/type of the controller connected on the input side.</td></tr><tr><td><code>get_val</code></td><td>Returns an identifier’s current value after any earlier modifications in the current VM cycle.</td></tr><tr><td><code>get_ival</code></td><td>Returns the raw input value received from the controller before script modification.</td></tr><tr><td><code>get_keyboard</code></td><td>Reports whether the specified keyboard usage/key is currently held.</td></tr><tr><td><code>get_modifiers</code></td><td>Returns the requested modifier-mask bits that are currently held.</td></tr><tr><td><code>get_lval</code></td><td>Returns the identifier's final outgoing value from the previous main iteration.</td></tr><tr><td><code>get_ptime</code></td><td>Returns milliseconds since the identifier last changed between false and true states.</td></tr><tr><td><code>get_brtime</code></td><td>Returns milliseconds since the identifier was last released; useful for double-press timing.</td></tr><tr><td><code>event_press</code></td><td>Returns true for the iteration in which an identifier changes from false to true.</td></tr><tr><td><code>event_release</code></td><td>Returns true for the iteration in which an identifier changes from true to false.</td></tr><tr><td><code>swap</code></td><td>Swaps the current values of two controller identifiers for the outgoing report.</td></tr><tr><td><code>block</code></td><td>Prevents the specified identifier from being forwarded for a duration in milliseconds.</td></tr><tr><td><code>sensitivity</code></td><td>Scales an identifier around a midpoint. Live uses the three-argument form; 100 percent leaves sensitivity unchanged.</td></tr><tr><td><code>deadzone</code></td><td>Pushes a stick's smallest nonzero input outward past an inner deadzone, or applies a circular deadzone with <code>DZ_CIRCLE</code>.</td></tr><tr><td><code>stickize</code></td><td>Changes the outer stick shape/radius; 141 maps a circular range toward a square output area.</td></tr><tr><td><code>ps4_touchpad</code></td><td>Reads DS4 touch presence or coordinates selected by a PS4T_* constant.</td></tr><tr><td><code>ps4_set_touchpad</code></td><td>Produces a DS4 touch point at a normalized X/Y position.</td></tr></tbody></table>

#### `turn_off`

Turns off the wireless controller connected to the Zen input port.

**Syntax**

```gpc
turn_off();
```

**Parameters**

None.

**Returns**

Nothing.

**Example**

```gpc
main {
    if(get_val(PS5_OPTIONS) && get_ptime(PS5_OPTIONS) > 3000) {
        turn_off();
    }
}
```

***

#### `get_battery`

Returns the connected wireless controller battery state: 0 discharged, 10 fully charged, and 11 charging.

**Syntax**

```gpc
result = get_battery();
```

**Parameters**

None.

**Returns**

Integer `0..11`.

**Example**

```gpc
int battery;
main { battery = get_battery(); }
```

***

#### `get_controller`

Returns the protocol/type of the controller connected on the input side.

**Syntax**

```gpc
result = get_controller();
```

**Parameters**

None.

**Returns**

A `PIO_*` controller protocol value.

**Example**

```gpc
int controller;
main { controller = get_controller(); }
```

***

#### `get_val`

Returns an identifier’s current value after any earlier modifications in the current VM cycle.

**Syntax**

```gpc
result = get_val(identifier);
```

**Parameters**

| Parameter    | Accepted value                     |
| ------------ | ---------------------------------- |
| `identifier` | `BUTTON_MIN..BUTTON_MAX_EXTENDED`. |

**Returns**

Current identifier value, normally `-100..100`.

**Example**

```gpc
main {
    if(get_val(PS5_R2) > 50) set_val(TRACE_1, 1);
}
```

***

#### `get_ival`

Returns the raw input value received from the controller before script modification.

**Syntax**

```gpc
result = get_ival(identifier);
```

**Parameters**

| Parameter    | Accepted value                     |
| ------------ | ---------------------------------- |
| `identifier` | `BUTTON_MIN..BUTTON_MAX_EXTENDED`. |

**Returns**

Raw identifier value, normally `-100..100`.

**Example**

```gpc
int raw_rx;
main { raw_rx = get_ival(PS5_RX); }
```

***

#### `get_keyboard`

Reports whether the specified keyboard usage/key is currently held.

**Syntax**

```gpc
result = get_keyboard(identifier);
```

**Parameters**

| Parameter    | Accepted value                               |
| ------------ | -------------------------------------------- |
| `identifier` | A keyboard usage constant/value in `4..251`. |

**Returns**

`TRUE` or `FALSE`.

**Example**

```gpc
main {
    if(get_keyboard(KEY_A)) set_val(PS5_CROSS, 100);
}
```

***

#### `get_modifiers`

Returns the requested modifier-mask bits that are currently held.

**Syntax**

```gpc
result = get_modifiers(identifier);
```

**Parameters**

| Parameter    | Accepted value                                   |
| ------------ | ------------------------------------------------ |
| `identifier` | Bitwise-OR mask of `MOD_*` constants (`1..255`). |

**Returns**

Mask of requested `MOD_*` bits currently held.

**Example**

```gpc
main {
    if(get_modifiers(MOD_LCTRL | MOD_LALT) == (MOD_LCTRL | MOD_LALT)) {
        set_val(TRACE_1, 1);
    }
}
```

***

#### `get_lval`

Returns the identifier's final outgoing value from the previous main iteration. This is the previous cycle's output after script processing, not the previous physical input.

**Syntax**

```gpc
result = get_lval(identifier);
```

**Parameters**

| Parameter    | Accepted value            |
| ------------ | ------------------------- |
| `identifier` | `BUTTON_MIN..BUTTON_MAX`. |

**Returns**

Previous-cycle identifier value.

**Example**

```gpc
int previous;
main { previous = get_lval(PS5_R2); }
```

***

#### `get_ptime`

Returns milliseconds since the identifier last changed between false and true states.

**Syntax**

```gpc
result = get_ptime(identifier);
```

**Parameters**

| Parameter    | Accepted value            |
| ------------ | ------------------------- |
| `identifier` | `BUTTON_MIN..BUTTON_MAX`. |

**Returns**

Elapsed milliseconds.

**Example**

```gpc
main {
    if(get_val(PS5_CROSS) && get_ptime(PS5_CROSS) > 500) set_val(TRACE_1, 1);
}
```

***

#### `get_brtime`

Returns milliseconds since the identifier was last released; useful for double-press timing.

**Syntax**

```gpc
result = get_brtime(identifier);
```

**Parameters**

| Parameter    | Accepted value            |
| ------------ | ------------------------- |
| `identifier` | `BUTTON_MIN..BUTTON_MAX`. |

**Returns**

Elapsed milliseconds since release.

**Example**

```gpc
main {
    if(event_press(PS5_CROSS) && get_brtime(PS5_CROSS) < 300) set_val(TRACE_1, 2);
}
```

#### `event_press`

Returns true for the iteration in which an identifier changes from false to true.

**Syntax**

```gpc
result = event_press(identifier);
```

**Parameters**

| Parameter    | Accepted value            |
| ------------ | ------------------------- |
| `identifier` | `BUTTON_MIN..BUTTON_MAX`. |

**Returns**

`TRUE` on the press edge, otherwise `FALSE`.

**Example**

```gpc
main {
    if(event_press(PS5_CROSS)) set_val(TRACE_1, 1);
}
```

***

#### `event_release`

Returns true for the iteration in which an identifier changes from true to false.

**Syntax**

```gpc
result = event_release(identifier);
```

**Parameters**

| Parameter    | Accepted value            |
| ------------ | ------------------------- |
| `identifier` | `BUTTON_MIN..BUTTON_MAX`. |

**Returns**

`TRUE` on the release edge, otherwise `FALSE`.

**Example**

```gpc
main {
    if(event_release(PS5_CROSS)) set_val(TRACE_1, 0);
}
```

#### `swap`

Swaps the current values of two controller identifiers for the outgoing report.

**Syntax**

```gpc
swap(identifier1, identifier2);
```

**Parameters**

| Parameter     | Accepted value            |
| ------------- | ------------------------- |
| `identifier1` | `BUTTON_MIN..BUTTON_MAX`. |
| `identifier2` | `BUTTON_MIN..BUTTON_MAX`. |

**Returns**

Nothing.

**Example**

```gpc
main {
    if(get_ival(PS5_L2)) swap(PS5_CROSS, PS5_CIRCLE);
}
```

***

#### `block`

Prevents the specified identifier from being forwarded for a duration in milliseconds.

**Syntax**

```gpc
block(identifier, milliseconds);
```

**Parameters**

| Parameter      | Accepted value            |
| -------------- | ------------------------- |
| `identifier`   | `BUTTON_MIN..BUTTON_MAX`. |
| `milliseconds` | `1..TIME_MAX`.            |

**Returns**

Nothing.

**Example**

```gpc
main {
    if(event_press(PS5_CROSS)) block(PS5_CROSS, 250);
}
```

***

#### `sensitivity`

Scales an identifier around a midpoint. Live uses the three-argument form; 100 percent leaves sensitivity unchanged.

**Syntax**

```gpc
sensitivity(identifier, midpoint, sensitivity);
```

**Parameters**

| Parameter     | Accepted value                                    |
| ------------- | ------------------------------------------------- |
| `identifier`  | `BUTTON_MIN..BUTTON_MAX`.                         |
| `midpoint`    | `0..100`; outside the recommended range may warn. |
| `sensitivity` | `0..327`; outside the recommended range may warn. |

**Returns**

Nothing.

**Example**

```gpc
main { sensitivity(PS5_RX, NOT_USE, 120); }
```

> **Compiler note:** Function 'sensitivity' no longer accepts 6 parameters. Deadzone adjustment and cutoff values are ignored. Remove the last 3 arguments.

{% hint style="warning" %}
**Compiler note (`GPC9002`):** Function 'sensitivity' no longer accepts 6 parameters. Deadzone adjustment and cutoff values are ignored. Remove the last 3 arguments.
{% endhint %}

***

#### `deadzone`

Pushes the smallest nonzero stick input outward past the configured inner deadzone. In axis mode, `deadzone_x` and `deadzone_y` set the minimum output distance on each axis. With `DZ_CIRCLE`, `deadzone_y` is the minimum radial distance. This changes where motion begins; it does not merely discard values below a cutoff.

**Syntax**

```gpc
deadzone(identifier_x, identifier_y, deadzone_x, deadzone_y);
```

**Parameters**

| Parameter      | Accepted value                                                                               |
| -------------- | -------------------------------------------------------------------------------------------- |
| `identifier_x` | `BUTTON_MIN..BUTTON_MAX`.                                                                    |
| `identifier_y` | `BUTTON_MIN..BUTTON_MAX`.                                                                    |
| `deadzone_x`   | `-100..101`, or `DZ_CIRCLE` to select circular mode; outside the recommended range may warn. |
| `deadzone_y`   | `-100..100`; this is the radius when `deadzone_x` is `DZ_CIRCLE`.                            |

**Returns**

Nothing.

**Example**

```gpc
main { deadzone(PS5_RX, PS5_RY, DZ_CIRCLE, 20); }
```

***

#### `stickize`

Changes the outer stick shape/radius; 141 maps a circular range toward a square output area.

**Syntax**

```gpc
stickize(identifier_x, identifier_y, radius);
```

**Parameters**

| Parameter      | Accepted value                                                                                                                                            |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `identifier_x` | `PS4_LX`, `PS4_LY`, `PS4_RX`, `PS4_RY`, `POLAR_RX`, `POLAR_RY`, `POLAR_LX`, `POLAR_LY`, `ANALOG_RX`, `ANALOG_RY`, `ANALOG_LX`, `ANALOG_LY`, or `NOT_USE`. |
| `identifier_y` | Same set as `identifier_x`.                                                                                                                               |
| `radius`       | `0..141`; outside the recommended range may warn.                                                                                                         |

{% hint style="info" %}
`ANALOG_GHOSTX` and `ANALOG_GHOSTY` are **not** accepted, even though they sit next to the other analog axes.
{% endhint %}

**Returns**

Nothing.

**Example**

```gpc
main { stickize(PS5_RX, PS5_RY, 141); }
```

***

#### `ps4_touchpad`

Reads DS4 touch presence or coordinates selected by a PS4T\_\* constant.

**Syntax**

```gpc
result = ps4_touchpad(PS4T_constant);
```

**Parameters**

| Parameter       | Accepted value                                                                  |
| --------------- | ------------------------------------------------------------------------------- |
| `PS4T_constant` | One of `PS4T_P1`, `PS4T_P1X`, `PS4T_P1Y`, `PS4T_P2`, `PS4T_P2X`, or `PS4T_P2Y`. |

**Returns**

Touch-active boolean or selected coordinate.

**Example**

```gpc
int touch_x;
main {
    if(ps4_touchpad(PS4T_P1)) touch_x = ps4_touchpad(PS4T_P1X);
}
```

***

#### `ps4_set_touchpad`

Produces a DS4 touch point at a normalized X/Y position.

**Syntax**

```gpc
ps4_set_touchpad(value_x, value_y);
```

**Parameters**

| Parameter | Accepted value |
| --------- | -------------- |
| `value_x` | `-100..100`.   |
| `value_y` | `-100..100`.   |

**Returns**

Nothing.

**Example**

```gpc
main {
    if(get_ival(PS4_L2)) ps4_set_touchpad(0, 0);
}
```

***

### Console output and polar I/O

<table data-search="false"><thead><tr><th>Function</th><th>Purpose</th></tr></thead><tbody><tr><td><code>get_console</code></td><td>Returns the output console protocol currently connected to Zen.</td></tr><tr><td><code>set_val</code></td><td>Overwrites an identifier’s current outgoing value for this report.</td></tr><tr><td><code>block_all_inputs</code></td><td>Blocks every controller output for the current main cycle.</td></tr><tr><td><code>set_polar</code></td><td>Writes a high-resolution stick or ghost-stick angle and radius on the 0..32767 radius scale.</td></tr><tr><td><code>set_polar2</code></td><td>Writes a stick or ghost-stick angle and radius on the 0..15000 radius scale.</td></tr><tr><td><code>get_polar</code></td><td>Reads the current modified/output polar angle or radius.</td></tr><tr><td><code>get_ipolar</code></td><td>Reads the raw, unmodified polar input angle or radius.</td></tr><tr><td><code>ps4_authtimeout</code></td><td>Returns PS4 authentication timeout status. It is retained by Live but is rarely relevant on current firmware.</td></tr><tr><td><code>output_reconnection</code></td><td>Requests/checks output reconnection behavior as implemented by the current Live firmware.</td></tr></tbody></table>

#### `get_console`

Returns the output console protocol currently connected to Zen.

**Syntax**

```gpc
result = get_console();
```

**Parameters**

None.

**Returns**

A `PIO_*` console protocol value.

**Example**

```gpc
int console;
init { console = get_console(); }
```

***

#### `set_val`

Overwrites an identifier’s current outgoing value for this report.

**Syntax**

```gpc
set_val(identifier, value);
```

**Parameters**

| Parameter    | Accepted value                                       |
| ------------ | ---------------------------------------------------- |
| `identifier` | `BUTTON_MIN..BUTTON_MAX_EXTENDED`.                   |
| `value`      | `-100..100`; outside the recommended range may warn. |

**Returns**

Nothing.

**Example**

```gpc
main {
    if(get_ival(PS5_R2) > 10) set_val(PS5_R2, 100);
}
```

***

#### `block_all_inputs`

Blocks every controller output for the current main cycle.

This effectively writes `0` to every controller output. When a later `set_polar()` targets a physical stick in the same cycle, restore both of that stick's axes with `set_val(axis, get_ival(axis))` before the polar write. See Blocking and polar output.

**Syntax**

```gpc
block_all_inputs();
```

**Parameters**

None.

**Returns**

Nothing.

**Example**

```gpc
main {
    if(get_ival(PS5_OPTIONS)) block_all_inputs();
}
```

***

#### `set_polar`

Writes a high-resolution stick or ghost-stick angle and radius on the 0..32767 radius scale.

After `block_all_inputs()`, restore both axes of the target physical stick with `set_val(axis, get_ival(axis))` before this call; otherwise, nonzero physical input can override the corresponding polar axis. See Blocking and polar output.

**Syntax**

```gpc
set_polar(stick, angle, radius);
```

**Parameters**

| Parameter | Accepted value                            |
| --------- | ----------------------------------------- |
| `stick`   | `POLAR_RS`, `POLAR_LS`, or `POLAR_GHOST`. |
| `angle`   | `0..359`.                                 |
| `radius`  | `0..32767`.                               |

**Returns**

Nothing.

**Example**

```gpc
main { set_polar(POLAR_RS, 90, 32767); }
```

***

#### `set_polar2`

Writes a stick or ghost-stick angle and radius on the 0..15000 radius scale.

**Syntax**

```gpc
set_polar2(stick, angle, radius);
```

**Parameters**

| Parameter | Accepted value                            |
| --------- | ----------------------------------------- |
| `stick`   | `POLAR_RS`, `POLAR_LS`, or `POLAR_GHOST`. |
| `angle`   | `0..359`.                                 |
| `radius`  | `0..15000`.                               |

**Returns**

Nothing.

**Example**

```gpc
main { set_polar2(POLAR_GHOST, 180, 7500); }
```

***

#### `get_polar`

Reads the current modified/output polar angle or radius.

**Syntax**

```gpc
result = get_polar(stick, radius_or_angle);
```

**Parameters**

| Parameter         | Accepted value                            |
| ----------------- | ----------------------------------------- |
| `stick`           | `POLAR_RS`, `POLAR_LS`, or `POLAR_GHOST`. |
| `radius_or_angle` | `POLAR_RADIUS` or `POLAR_ANGLE`.          |

**Returns**

Angle `0..359` or radius `0..32767`.

**Example**

```gpc
int angle;
main { angle = get_polar(POLAR_RS, POLAR_ANGLE); }
```

***

#### `get_ipolar`

Reads the raw, unmodified polar input angle or radius.

**Syntax**

```gpc
result = get_ipolar(stick, radius_or_angle);
```

**Parameters**

| Parameter         | Accepted value                            |
| ----------------- | ----------------------------------------- |
| `stick`           | `POLAR_RS`, `POLAR_LS`, or `POLAR_GHOST`. |
| `radius_or_angle` | `POLAR_RADIUS` or `POLAR_ANGLE`.          |

**Returns**

Raw angle `0..359` or radius `0..32767`.

**Example**

```gpc
int radius;
main { radius = get_ipolar(POLAR_RS, POLAR_RADIUS); }
```

***

#### `ps4_authtimeout`

Returns PS4 authentication timeout status. It is retained by Live but is rarely relevant on current firmware.

**Syntax**

```gpc
result = ps4_authtimeout();
```

**Parameters**

None.

**Returns**

Firmware-defined authentication status integer.

**Example**

```gpc
int auth_status;
main { auth_status = ps4_authtimeout(); }
```

***

#### `output_reconnection`

Requests/checks output reconnection behavior as implemented by the current Live firmware.

**Syntax**

```gpc
output_reconnection();
```

**Parameters**

None.

**Returns**

Nothing.

**Example**

```gpc
main {
    if(event_press(PS5_OPTIONS)) output_reconnection();
}
```

***

### LED and lightbar

<table data-search="false"><thead><tr><th>Function</th><th>Purpose</th></tr></thead><tbody><tr><td><code>get_ps4_lbar</code></td><td>Reads one color channel of the PS4 lightbar value supplied by the console.</td></tr><tr><td><code>set_ps4_lbar</code></td><td>Overrides the DS4 lightbar with red, green, and blue channel values.</td></tr><tr><td><code>get_led</code></td><td>Returns the current state of a selected controller LED.</td></tr><tr><td><code>set_led</code></td><td>Sets a controller LED off, on, fast blink, or slow blink.</td></tr><tr><td><code>set_ledx</code></td><td>Starts a finite LED blink count; a count of zero leaves the LED on.</td></tr><tr><td><code>get_ledx</code></td><td>Reports whether an LED sequence started by set_ledx is still active.</td></tr><tr><td><code>reset_leds</code></td><td>Returns LED control to the console and clears script overrides.</td></tr></tbody></table>

#### `get_ps4_lbar`

Reads one color channel of the PS4 lightbar value supplied by the console.

**Syntax**

```gpc
result = get_ps4_lbar(color_channel);
```

**Parameters**

| Parameter       | Accepted value                                              |
| --------------- | ----------------------------------------------------------- |
| `color_channel` | `0..7`; use the matching PS4/DS4 lightbar-channel constant. |

**Returns**

Selected color-channel value `0..255`.

**Example**

```gpc
int green;
main { green = get_ps4_lbar(PS4_GREEN); }
```

***

#### `set_ps4_lbar`

Overrides the DS4 lightbar with red, green, and blue channel values.

**Syntax**

```gpc
set_ps4_lbar(red, green, blue);
```

**Parameters**

| Parameter | Accepted value |
| --------- | -------------- |
| `red`     | `0..255`.      |
| `green`   | `0..255`.      |
| `blue`    | `0..255`.      |

**Returns**

Nothing.

**Example**

```gpc
main { set_ps4_lbar(255, 0, 0); }
```

***

#### `get_led`

Returns the current state of a selected controller LED.

**Syntax**

```gpc
result = get_led(led_identifier);
```

**Parameters**

| Parameter        | Accepted value            |
| ---------------- | ------------------------- |
| `led_identifier` | `LED_ID_MIN..LED_ID_MAX`. |

**Returns**

LED state `0..3`.

**Example**

```gpc
int led_state;
main { led_state = get_led(LED_1); }
```

***

#### `set_led`

Sets a controller LED off, on, fast blink, or slow blink.

**Syntax**

```gpc
set_led(led_identifier, state);
```

**Parameters**

| Parameter        | Accepted value            |
| ---------------- | ------------------------- |
| `led_identifier` | `LED_ID_MIN..LED_ID_MAX`. |
| `state`          | `LED_MIN..LED_MAX`.       |

**Returns**

Nothing.

**Example**

```gpc
init { set_led(LED_1, 1); }
```

***

#### `set_ledx`

Starts a finite LED blink count; a count of zero leaves the LED on.

**Syntax**

```gpc
set_ledx(led_identifier, no_of_blinks);
```

**Parameters**

| Parameter        | Accepted value            |
| ---------------- | ------------------------- |
| `led_identifier` | `LED_ID_MIN..LED_ID_MAX`. |
| `no_of_blinks`   | `LEDX_MIN..LEDX_MAX`.     |

**Returns**

Nothing.

**Example**

```gpc
main {
    if(event_press(PS5_CROSS)) set_ledx(LED_1, 3);
}
```

***

#### `get_ledx`

Reports whether an LED sequence started by set\_ledx is still active.

**Syntax**

```gpc
result = get_ledx();
```

**Parameters**

None.

**Returns**

`TRUE` while the finite blink sequence is active.

**Example**

```gpc
main {
    if(get_ledx()) set_val(TRACE_1, 1);
}
```

***

#### `reset_leds`

Returns LED control to the console and clears script overrides.

**Syntax**

```gpc
reset_leds();
```

**Parameters**

None.

**Returns**

Nothing.

**Example**

```gpc
main {
    if(event_press(PS5_CIRCLE)) reset_leds();
}
```

***

### Rumble and haptics

| Function       | Purpose                                                             |
| -------------- | ------------------------------------------------------------------- |
| `get_rumble`   | Returns the current strength of a selected rumble/haptic actuator.  |
| `set_rumble`   | Overrides a selected rumble/haptic actuator with a 0..100 strength. |
| `block_rumble` | Blocks rumble signals from the console.                             |
| `reset_rumble` | Clears script rumble overrides and returns control to the console.  |

#### `get_rumble`

Returns the current strength of a selected rumble/haptic actuator.

**Syntax**

```gpc
result = get_rumble(limit);
```

**Parameters**

| Parameter | Accepted value                                        |
| --------- | ----------------------------------------------------- |
| `limit`   | A `RUMBLE_*` or supported `PS5_HAPTICS_*` identifier. |

**Returns**

Strength `0..100`.

**Example**

```gpc
int strength;
main { strength = get_rumble(RUMBLE_A); }
```

***

#### `set_rumble`

Overrides a selected rumble/haptic actuator with a 0..100 strength.

**Syntax**

```gpc
set_rumble(rumble_identifier, speed);
```

**Parameters**

| Parameter           | Accepted value                  |
| ------------------- | ------------------------------- |
| `rumble_identifier` | `RUMBLE_MIN..RUMBLE_MAX`.       |
| `speed`             | Strength from `0..100` percent. |

**Returns**

Nothing.

**Example**

```gpc
main {
    if(get_ival(PS5_CROSS)) set_rumble(RUMBLE_A, 100);
}
```

***

#### `block_rumble`

Blocks rumble signals from the console.

**Syntax**

```gpc
block_rumble();
```

**Parameters**

None.

**Returns**

Nothing.

**Example**

```gpc
init { block_rumble(); }
```

***

#### `reset_rumble`

Clears script rumble overrides and returns control to the console.

**Syntax**

```gpc
reset_rumble();
```

**Parameters**

None.

**Returns**

Nothing.

**Example**

```gpc
main {
    if(event_release(PS5_CROSS)) reset_rumble();
}
```

***

### PS5 adaptive triggers

| Function   | Purpose                                                                              |
| ---------- | ------------------------------------------------------------------------------------ |
| `get_adt`  | Reads one byte field from a PS5 adaptive-trigger report.                             |
| `set_adt`  | Writes one byte field of a PS5 adaptive-trigger report.                              |
| `adt_off`  | Disables and resets script changes for one PS5 adaptive trigger.                     |
| `adt_cmp`  | Compares a trigger’s raw 11-byte adaptive-trigger record with a const ps5adt record. |
| `adt_setx` | Applies an entire const ps5adt record to a trigger.                                  |

#### `get_adt`

Reads one byte field from a PS5 adaptive-trigger report.

**Syntax**

```gpc
result = get_adt(trigger, limit);
```

**Parameters**

| Parameter | Accepted value                          |
| --------- | --------------------------------------- |
| `trigger` | `PS5_R2` or `PS5_L2`.                   |
| `limit`   | One of the `PS5_ADT_*` field constants. |

**Returns**

Selected adaptive-trigger byte `0..255`.

**Example**

```gpc
int mode;
main { mode = get_adt(PS5_R2, PS5_ADT_MODE); }
```

***

#### `set_adt`

Writes one byte field of a PS5 adaptive-trigger report.

**Syntax**

```gpc
set_adt(trigger, type, value);
```

**Parameters**

| Parameter | Accepted value                          |
| --------- | --------------------------------------- |
| `trigger` | `PS5_R2` or `PS5_L2`.                   |
| `type`    | One of the `PS5_ADT_*` field constants. |
| `value`   | `0..255`.                               |

**Returns**

Nothing.

**Example**

```gpc
main { set_adt(PS5_R2, PS5_ADT_MODE, PS5_ADT_CR); }
```

***

#### `adt_off`

Disables and resets script changes for one PS5 adaptive trigger.

**Syntax**

```gpc
adt_off(trigger);
```

**Parameters**

| Parameter | Accepted value        |
| --------- | --------------------- |
| `trigger` | `PS5_R2` or `PS5_L2`. |

**Returns**

Nothing.

**Example**

```gpc
main {
    if(event_press(PS5_CIRCLE)) adt_off(PS5_R2);
}
```

***

#### `adt_cmp`

Compares a trigger’s raw 11-byte adaptive-trigger record with a const ps5adt record.

**Syntax**

```gpc
result = adt_cmp(trigger, addr);
```

**Parameters**

| Parameter | Accepted value                      |
| --------- | ----------------------------------- |
| `trigger` | `PS5_R2` or `PS5_L2`.               |
| `addr`    | Address of a const `ps5adt` record. |

**Returns**

`TRUE` if the records match, otherwise `FALSE`.

**Example**

```gpc
const ps5adt PROFILE = { 1, 0, 128, 128, 64, 128, 192, 0, 0, 100, 0 };
main {
    if(adt_cmp(PS5_R2, addr(PROFILE))) set_val(TRACE_1, 1);
}
```

***

#### `adt_setx`

Applies an entire const ps5adt record to a trigger.

**Syntax**

```gpc
adt_setx(trigger, addr);
```

**Parameters**

| Parameter | Accepted value                      |
| --------- | ----------------------------------- |
| `trigger` | `PS5_R2` or `PS5_L2`.               |
| `addr`    | Address of a const `ps5adt` record. |

**Returns**

Nothing.

**Example**

```gpc
const ps5adt PROFILE = { 1, 0, 128, 128, 64, 128, 192, 0, 0, 100, 0 };
main { adt_setx(PS5_R2, addr(PROFILE)); }
```

***

### Persistent variables

| Function   | Purpose                                                                                          |
| ---------- | ------------------------------------------------------------------------------------------------ |
| `get_pvar` | Reads a Zen SPVAR and substitutes a default when the stored value is outside the supplied range. |
| `set_pvar` | Stores a signed 32-bit value in a Zen SPVAR. Save only on an explicit change/event.              |

#### `get_pvar`

Reads a slot-private Zen SPVAR and substitutes a default when the stored value is outside the supplied range.

**Syntax**

```gpc
result = get_pvar(spvar_constant, min_value, max_value, default_value);
```

**Parameters**

| Parameter        | Accepted value              |
| ---------------- | --------------------------- |
| `spvar_constant` | One of `SPVAR_1..SPVAR_64`. |
| `min_value`      | `VALUE_MIN..VALUE_MAX`.     |
| `max_value`      | `VALUE_MIN..VALUE_MAX`.     |
| `default_value`  | `VALUE_MIN..VALUE_MAX`.     |

**Returns**

Stored value when in range; otherwise `default_value`.

**Example**

```gpc
int strength;
init { strength = get_pvar(SPVAR_1, 0, 100, 25); }
```

***

#### `set_pvar`

Stores a signed 32-bit value in a slot-private Zen SPVAR. Save only on an explicit change/event.

**Syntax**

```gpc
set_pvar(spvar_constant, value);
```

**Parameters**

| Parameter        | Accepted value              |
| ---------------- | --------------------------- |
| `spvar_constant` | One of `SPVAR_1..SPVAR_64`. |
| `value`          | `VALUE_MIN..VALUE_MAX`.     |

**Returns**

Nothing.

**Example**

```gpc
int strength = 25;
main {
    if(event_press(PS5_OPTIONS)) set_pvar(SPVAR_1, strength);
}
```

***

### Data-section readers

| Function  | Purpose                                                                      |
| --------- | ---------------------------------------------------------------------------- |
| `dint8`   | Reads one signed 8-bit value from a byte offset in the data section.         |
| `duint8`  | Reads one unsigned 8-bit value from a byte offset in the data section.       |
| `dint16`  | Reads one signed 16-bit value from a byte offset in the data section.        |
| `duint16` | Reads one unsigned 16-bit value from a byte offset in the Live data section. |
| `dint32`  | Reads one signed 32-bit value from a byte offset in the Live data section.   |

#### `dint8`

Reads one signed 8-bit value from a byte offset in the data section.

**Syntax**

```gpc
result = dint8(index);
```

**Parameters**

| Parameter | Accepted value                          |
| --------- | --------------------------------------- |
| `index`   | Data-section byte offset; reads 1 byte. |

**Returns**

Signed value `-128..127`.

**Example**

```gpc
data(0xFF, 0x7F);
int value;
main { value = dint8(0); }
```

***

#### `duint8`

Reads one unsigned 8-bit value from a byte offset in the data section.

**Syntax**

```gpc
result = duint8(index);
```

**Parameters**

| Parameter | Accepted value                          |
| --------- | --------------------------------------- |
| `index`   | Data-section byte offset; reads 1 byte. |

**Returns**

Unsigned value `0..255`.

**Example**

```gpc
data(0xFF, 0x7F);
int value;
main { value = duint8(0); }
```

***

#### `dint16`

Reads one signed 16-bit value from a byte offset in the data section.

**Syntax**

```gpc
result = dint16(index);
```

**Parameters**

| Parameter | Accepted value                           |
| --------- | ---------------------------------------- |
| `index`   | Data-section byte offset; reads 2 bytes. |

**Returns**

Signed value `-32768..32767`.

**Example**

```gpc
data(0x34, 0x12);
int value;
main { value = dint16(0); }
```

***

#### `duint16`

Reads one unsigned 16-bit value from a byte offset in the Live data section.

**Syntax**

```gpc
result = duint16(index);
```

**Parameters**

| Parameter | Accepted value                           |
| --------- | ---------------------------------------- |
| `index`   | Data-section byte offset; reads 2 bytes. |

**Returns**

Unsigned value `0..65535`.

**Example**

```gpc
data(0xFF, 0xFF);
int value;
main { value = duint16(0); }
```

***

#### `dint32`

Reads one signed 32-bit value from a byte offset in the Live data section.

**Syntax**

```gpc
result = dint32(index);
```

**Parameters**

| Parameter | Accepted value                           |
| --------- | ---------------------------------------- |
| `index`   | Data-section byte offset; reads 4 bytes. |

**Returns**

Signed 32-bit value.

**Example**

```gpc
data(0x78, 0x56, 0x34, 0x12);
int value;
main { value = dint32(0); }
```

***

### Deprecated compatibility aliases

These names still compile on the audited Live target, so they are included for recognition and maintenance of older source. New code should use the named replacement. A deprecated call produces a compiler warning.

| Function | Replacement | Diagnostic |
| -------- | ----------- | ---------- |
| `printf` | `print`     | `GPC6011`  |
| `dchar`  | `dint8`     | `GPC9000`  |
| `dbyte`  | `duint8`    | `GPC9000`  |
| `dword`  | `dint16`    | `GPC9000`  |

#### `printf`

Deprecated five-argument OLED string formatter retained for Live source compatibility. New 32-bit-target code should use `print`.

**Syntax**

```gpc
printf(x, y, font, color, stringaddr);
```

**Parameters**

| Parameter    | Accepted value                                                    |
| ------------ | ----------------------------------------------------------------- |
| `x`          | OLED X position `0..127`.                                         |
| `y`          | OLED Y position `0..63`.                                          |
| `font`       | `OLED_FONT_SMALL..OLED_FONT_LARGE` (`0..2`).                      |
| `color`      | `OLED_BLACK` or `OLED_WHITE`.                                     |
| `stringaddr` | Address of a `const string` entry, normally produced with `addr`. |

**Returns**

Nothing.

**Example**

```gpc
const string STATUS = "READY";

init {
    printf(0, 0, OLED_FONT_SMALL, OLED_WHITE, addr(STATUS));
}
```

This compiles for compatibility but emits `GPC6011`.

***

#### `dchar`

Deprecated alias for `dint8`; reads one signed byte from the raw `data(...)` section.

**Syntax**

```gpc
result = dchar(index);
```

**Parameters**

| Parameter | Accepted value                         |
| --------- | -------------------------------------- |
| `index`   | Byte offset into the raw data section. |

**Returns**

Signed 8-bit value `-128..127`, promoted to the 32-bit runtime integer.

**Example**

```gpc
data(255);
int value;

main {
    value = dchar(0); // -1; use dint8 in new code
}
```

This compiles for compatibility but emits `GPC9000`.

***

#### `dbyte`

Deprecated alias for `duint8`; reads one unsigned byte from the raw `data(...)` section.

**Syntax**

```gpc
result = dbyte(index);
```

**Parameters**

| Parameter | Accepted value                         |
| --------- | -------------------------------------- |
| `index`   | Byte offset into the raw data section. |

**Returns**

Unsigned 8-bit value `0..255`, promoted to the 32-bit runtime integer.

**Example**

```gpc
data(255);
int value;

main {
    value = dbyte(0); // 255; use duint8 in new code
}
```

This compiles for compatibility but emits `GPC9000`.

***

#### `dword`

Deprecated alias for `dint16`; reads one signed 16-bit value from the raw `data(...)` section.

**Syntax**

```gpc
result = dword(index);
```

**Parameters**

| Parameter | Accepted value                                                        |
| --------- | --------------------------------------------------------------------- |
| `index`   | Byte offset into the raw data section; the reader consumes two bytes. |

**Returns**

Signed 16-bit value `-32768..32767`, promoted to the 32-bit runtime integer.

**Example**

```gpc
data(1, 0);
int value;

main {
    value = dword(0); // use dint16 in new code
}
```

This compiles for compatibility but emits `GPC9000`.

***

### Output-order reminders

* `get_ival` and `get_ipolar` read raw physical input.
* `get_val` and `get_polar` can observe earlier script changes.
* `get_lval` reads the final outgoing value from the previous iteration.
* Later `set_val`, polar, swap, block, deadzone, sensitivity, remap, combo, or menu logic can replace earlier work.
* Treat `set_pvar`, `set_bvar`, and `save_eeprom` as event-driven persistence writes, never base-level `main` work.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://guide.cronuszen.com/gpcscripting/gpc-script-guide/reference/core-built-ins.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
