> 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/gpc-developer-guide/functions/controller-functions/core-controller-functions.md).

# Core Controller Functions

| **Function Name**  | **Description**                                                                                                                             |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| get\_val           | Returns the current value of a controller entry.                                                                                            |
| get\_lval          | Returns the previous value of a controller entry.                                                                                           |
| get\_ptime         | Returns the elapsed time of a controller entries state change.                                                                              |
| get\_controller    | Returns the type of controller currently connected to the input port.                                                                       |
| get\_battery       | Returns the current status of the battery for a wireless controller.                                                                        |
| event\_press       | Returns TRUE when a controller entry has been pressed.                                                                                      |
| event\_release     | Returns TRUE when a controller entry has been released.                                                                                     |
| get\_ival          | Gets the input value of a button to check if it has been modified by the script.                                                            |
| get\_brtime        | Gets the time the input value has been 0.                                                                                                   |
| swap               | Swaps the input values to be sent to the console temporarily.                                                                               |
| block              | Locks the input from being sent to the console for the specified time.                                                                      |
| sensitivity        | Changes the input sensitivity.                                                                                                              |
| deadzone           | Modifies the inner "deadzone", and essentially pushes the starting value (when not 0) from the center by deadzone\_x/deadzone\_y or radius. |
| stickize           | Modifies outer deadzone, essentially forces the stick to not be further out than the radius from the inner point.                           |
| ps4\_touchpad      | Returns detailed information on the DualShock 4 touchpad state.                                                                             |
| ps4\_set\_touchpad | Touches the DualShock 4 touchpad in a specific (X, Y) position.                                                                             |
| turn\_off          | Turns off a wireless controller connected to the input port.                                                                                |
| wiir\_offscreen    | Returns TRUE if the IR sensor on a Wiimote is off screen.                                                                                   |
| get\_adt           | Returns the current value of an adaptive trigger entry.                                                                                     |
| set\_adt           | Sets the value of an adaptive trigger entry.                                                                                                |
| adt\_off           | Turns off an adaptive trigger. This will also reset any modifications done using set\_adt.                                                  |
| adt\_cmp           | Compares raw ADT data with an array that is used with addr.                                                                                 |
| addr               | Returns an offset rather than value.                                                                                                        |

***

### get\_val

get\_val returns the current value of a controller entry in the form of an int. This value represents a percentage %. GPC supports treating an int as a boolean value. This means get\_val can be used to test whether a controller button, trigger, or stick is being pressed or not.

Code-Snippet

```
if(get_val(PS4_R1))
```

This conditional statement would return TRUE if R1/RB has a value other than 0 (zero). It can also be used to check for a specific value range:

Code-Snippet

```
if(get_val(PS4_R2) > 50)
```

Would return TRUE if R2/RT was being pressed more than 50% of its total range.

Syntax

get\_val ( \<identifier> );

Parameters

\<identifier> : the identifier of a controller entry.

Returns

The current value of the specified identifier. Can range from -100 to +100 depending on the entry type.

***

### get\_lval

get\_lval is similar to get\_val with the exception that it returns the value of the specified identifier in the previous iteration (run) of the main loop. Unlike get\_val, it is not affected by any code before it.

Code-Snippet

```
main {
    set_val(XB1_RT, 0);
    set_val(TRACE_1, get_lval(XB1_RT));
    set_val(TRACE_2, get_val(XB1_RT));
}
```

Syntax

get\_lval ( \<identifier> );

Parameters

\<identifier> : the identifier of a controller entry.

Returns

The previous value of the specified identifier. Can range from -100 to +100 depending on the entry type.

***

### get\_ptime

get\_ptime returns the value in milliseconds of an identifiers state change. When an identifiers value changes from FALSE to TRUE or vice versa, the counter is reset to 0.

Code-Snippet

```
if (get_val(XB360_A) && get_ptime(XB360_A) > 200)
```

Syntax

get\_ptime ( \<identifier> );

Parameters

\<identifier> : the identifier of a controller entry.

Returns

The elapsed time of a controller entry state changes in milliseconds (0 to 32767).

***

### get\_controller

get\_controller returns an int which represents the controller type currently connected.

Code-Snippet

```
main {
    if(get_controller() == PIO_XB1) { 
        // connected device is an XB1 controller
    }
}
```

Syntax

get\_controller();

Parameters

None

Returns

A value representing which type of controller is currently connected.

***

### get\_battery

get\_battery returns the battery level ranging from 0 to 11. 0 is discharged, 10 is fully charged, and 11 is charging.

Code-Snippet

```
main {
    if(get_battery() <= 2) {
        // Battery low
    }
}
```

Syntax

get\_battery();

Parameters

None

Returns

0 (Discharged) to 10 (Fully Charged) or 11 (Charging).

***

### event\_press

event\_press returns TRUE in the main iteration when a control changes from FALSE to TRUE.

Code-Snippet

```
main {
    if(event_press(XB1_LT)){
        combo_run(scope_in);
    }
}

combo scope_in {
    wait(400);
    set_val(XB1_LS, 100);
    wait(200);
}
```

Syntax

event\_press ( \<identifier> );

Parameters

\<identifier> : the identifier of a controller entry.

Returns

TRUE at the moment of pressing.

***

### event\_release

event\_release returns TRUE when a control changes from TRUE to FALSE.

Code-Snippet

```
main {
    if(event_release(XB1_RT)){
        combo_run(reload);
    }
}

combo reload {
    wait(200);
    set_val(XB1_X, 100);
    wait(200);
}
```

Syntax

event\_release ( \<identifier> );

Parameters

\<identifier> : the identifier of a controller entry.

***

### get\_ival

get\_ival gets the input value of a button to check if it has been modified by the script.

Code-Snippet

```
main {
    if(get_ival(XB1_A) && get_ptime(XB1_A) < 500){
        set_val(XB1_UP, 100);
    }
}
```

***

### get\_brtime

get\_brtime checks how long it has been since the button was last released.

Code-Snippet

```
main {
    if (event_press(XB1_A) && get_brtime(XB1_A) < 300) {
        // Double press detected
    }
}
```

***

### swap

swap swaps the values of two controller entries.

Code-Snippet

```
main {
    if(get_val(XB1_LT)) {
        swap(XB1_RS, XB1_RB);
    }
}
```

Syntax

swap ( \<identifier1> , \<identifier2> );

***

### block

block prevents forwarding for a set time (20 to 4000 ms).

Code-Snippet

```
main {
    if(get_val(XB1_A)){
        if(event_press(XB1_A)){
            combo_run(single_jump);
        }
        block(XB1_A, 500);
    }
}
```

Syntax

block ( \<identifier> , \<milliseconds> );

***

### get\_adt (Adaptive Triggers)

get\_adt returns values for PS5 adaptive triggers.

Code-Snippet

```
main {
    if(get_adt(PS5_R2, PS5_ADT_MODE) == 0x25){
        set_val(TRACE_1, 1);
    }
}
```

Syntax

get\_adt ( \<trigger>, \<identifier> );

***

### set\_adt

set\_adt sets values (0-255) for adaptive trigger identifiers.

Code-Snippet

```
main {
    set_adt(PS5_R2, PS5_ADT_MODE, 0x00);
}
```

Syntax

set\_adt ( \<trigger>, \<identifier>, \<value> );


---

# 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:

```
GET https://guide.cronuszen.com/gpcscripting/gpc-script-guide/gpc-developer-guide/functions/controller-functions/core-controller-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
