Core Controller Functions

Function Name

Description

Zen

Plus

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_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. For example:

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 or value range². For example:

if(get_val(PS4_R2) > 50)

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

Since get_val returns an int, the returned value can be stored in a variable, like so:

int myvar;
main {
myvar = get_val(XB1_LT);
}

🔴 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.

Notes:

¹A conditional statement is a set of rules performed if a certain condition is met. It is sometimes referred to as an If-Then statement, because IF a condition is met, THEN an action is performed.

²Buttons/Bumpers, Triggers and Sticks each have their own range of returned values. Buttons/Bumpers will return either 0 (not pressed) or 100 (pressed). Triggers will return a value range of 0 to 100, depending on whether a trigger is not pressed at all (0) or a percentage of how far the trigger is pulled. Sticks return a value that represents it’s position along an axis (X/Y). As such, the return range of a stick is -100 to 100.

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. This value is also returned as a int and represents a percentage %.

However, get_lval gets its data from the input report so, unlike get_val, is not affected by any code before it. For example, if you were to use the set_valcommand to overwrite the output of an identifier, get_lval would still return the previous value of the identifier. You can see this in action by running the following command on your Cronus Zen and pressing the right trigger:

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 in the form of a int. What this means is when an identifiers value changes from FALSE to TRUE or vice versa, the counter for get_ptimeon that identifier is reset to 0.

Therefore the clock is always running for this function so it should be used with another command, such as get_val.

For example, using get_ptime in an if statement on its own like the example below would give an undesired result as the statement would be TRUE if the button was pressed or not for greater than 200 milliseconds.

if (get_ptime(XB360_A) > 200)

Using get_ptime in combination with the command get_val would modify the statement to only return TRUE if the button had been pressed for longer than 200 milliseconds, as shown below;

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 entries state change. Value returned is in milliseconds with a range of 0 to 32 767

get_controller

get_controllerreturns a value in the form of a int which represents the controller type currently connected to the input port of the Cronus.

To save you from having to remember which value relates to the type of controller, the constants have been created.

Cronus Zen
CronusMax Plus
Cronus Zen

Constants

NAME

Description

VALUE

PIO_NONE

No Controller Connected

0

PIO_PS3

Playstation 3 Controller

1

PIO_XB360

XBOX 360 Controller

2

PIO_WII

WII Controller

3

PIO_PS4

Playstation 4 Controller

4

PIO_XB1

XBOX One Controller

5

CronusMax Plus

Constants

Name

Description

Value

PIO_PS3

Playstation 3 Controller

1

PIO_XB360

XBOX 360 Controller

2

PIO_WII

WII Controller

3

PIO_PS4

Playstation 4 Controller

4

PIO_XB1

XBOX One Controller

5

main {
if(get_controller() == PIO_XB1) { // if the connected device is an XB1
// controller, this will evaluate to TRUE
// and code inside will execute.
}
}

🔴 Syntax

get_controller();

Parameters

None

🔵 Returns

A value representing which type of controller is currently connected

get_battery

get_batteryreturns the battery level, if applicable, of the connected controller in the form on an int ranging from 0 to 11. With 0 being discharged, 10 being fully charged and 11 being charging.

If no battery is connected, for example a wired controller is connected, then it returns 10.

main {
if(get_battery() <= 2) {
}
}

🔴 Syntax

get_battery();

Parameters

None

🔵 Returns

A value ranging from 0 (Discharged) to 10 (Fully Charged) or 11 if charging

event_press

event_press returns TRUE in the main iteration when a control changes from FALSE to TRUE. Therefore, even if a button is pressed and held down, event_press would only return TRUE at the moment it is pressed and not while the button was held. This makes it perfect for combos you only wish to run once when a button is pressed.

For example, if you were playing a first person shooter, using a sniper rifle and you wanted the Cronus to automatically scope when you aimed down you sights. You could do this:

main {
if(event_press(XB1_LT)){
combo_run(scope_in);
}
}
combo scope_in {
wait(400);
set_val(XB1_RS, 100);
wait(200);
}

🔴 Syntax

event_press ( <identifier>);

Parameters

<identifier> : the identifier of a controller entry

🔵 Returns

Returns TRUE in the main iteration when a control value changes from FALSE to TRUE.

event_release

event_release is the opposite of event_press, it returns TRUE in the main iteration when a control changes from TRUE to FALSE. This makes it ideally suited to run code which you only want run once when a button is released.

For example, if you were playing a shooter game and wanted the gun to be automatically reloaded whenever you stopped shooting, you could do this;

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