The
CronusMAX PLUS allows you to control the LEDs on your controller if the controller supports it.
Setting the LEDs is useful when you wish to create a visual indicator of an active function in your
scripts.
On a PS3,
Wii and Xbox 360 controller, you have 4 leds which can be controlled independently although note
that Xbox 360 controllers only allow one led to be lit at any time. The PS4's native
controller, the DS4, has one lightbar which supports and array of colors. The Xbox One
official controller does not support LED functions at this time.
|
Functions related to LEDs
|
|
|
|
|
Function Name
|
Description
|
|
|
Returns the current value of a LED state
|
|
|
Set the state of a LED
|
|
|
Blinks a LED a certain number of times
|
|
|
Checks if a LED is being blinked by the set_ledx function
|
|
|
Reset the LEDs state to what was set by the console
|
|
|
|
|
Additional Instructions in this section
|
|
|
|
|
|
LED Constants
Controllable LEDs range from 0 ~ 3. To make it easier to remember which value relates to which
LED, the following Constants are available;
|
Name
|
Description
|
Value
|
|
|
LED 1 / Xbox 360 Quadrant 1
|
0
|
|
|
LED 2 / Xbox 360 Quadrant 2
|
1
|
|
|
LED 3 / Xbox 360 Quadrant 3
|
2
|
|
|
LED 4 / Xbox 360 Quadrant 4
|
3
|
get_led
get_led returns a value in the form of an int which represents the
current state of the chosen LED.
The return value from this function informs you of the current state of the
selected LED. The function returns a value ranging from 0 ~ 3;
|
Return Value
|
Description
|
|
0
|
LED Off
|
|
1
|
LED On
|
|
2
|
LED Blinking Fast
|
|
3
|
LED Blinking Slowly
|
Example of usage:
|
main {
if(get_led(LED_2) == 1) {
}
}
|
Syntax
get_led ( <Led_Identifier> );
Parameters
<Led_Identifier> : The identifier of an LED
Returns
An int ranging from 0 ~ 3 which represents the current state
|
set_led
set_led sets the state of an LED on the controller.
When an led state is set, it remains set until such time as the LEDs are reset, it is set again in your GPC script
or the script is unloaded.
An LED can be set to one of four states using this function which range from
0 ~ 3, as shown
in the table below;
|
Value
|
Description
|
|
0
|
LED Off
|
|
1
|
LED On
|
|
2
|
LED Blink Fast
|
|
3
|
LED Blink Slowly
|
Example of usage:
Syntax
set_led ( <led_identifier> , <state> );
Parameters
<led_identifier> : the identifier of an LED
<state> : Numeric value which represents the state, as shown in the table above
|
set_ledx
set_ledx is used to Blink and LED a set amount of
times. You can blink an led from 0 to
255 times. 0 sets the LED to on.
Example of usage:
|
main {
if(!get_ledx()) {
set_led(LED_1, 10);
}
}
|
Syntax
set_ledx ( <led_identifier> , <no_of_blinks> );
Parameters
<led_identifier> : the identifier of an LED
<no_of_blinks> : The number of times to blink the LED
|
get_ledx
get_ledx checks to see if an LED is currently being
blinked by the set_ledx function.
Example of usage:
|
main {
if(get_ledx()) {
}
}
|
Syntax
get_ledx ( );
Parameters
None
Returns
TRUE is the LEDs are being blinked by the set_ledx function, FALSE if they are not
|
reset_leds
reset_leds returns control of the LEDs to the console
and disables any current LED states which are being set by the Virtual Machine.
Example of usage:
|
main {
if(event_press(XB1_A)) {
reset_leds();
}
}
|
Syntax
reset_leds ( );
Parameters
None
|
Setting DS4 lightbar
The Dualshock 4 controller has one lightbar instead of four LEDs. The
color of the lightbar can be controlled by setting all four led states
simultaneously.
For example, the following code will set the lightbar to green;
|
main {
if(event_press(PS4_CROSS)) {
set_led(LED_1, 0);
set_led(LED_2, 0);
set_led(LED_3, 2);
set_led(LED_4, 0);
}
}
|
To save you from remembering all the different combinations, we have created
this script which simplifies the task of setting the color with a custom
function. You can add your own code to this and use the function to create
visual notifications in your GPC script;
|
define Off = 0;
define Dim_Blue = 1;
define Dim_Red = 2;
define Dim_Green = 3;
define Dim_Pink = 4;
define Dim_SkyBlue = 5;
define Dim_Yellow = 6;
define Dim_White = 7;
define Blue = 8;
define Red = 9;
define Green = 10;
define Pink = 11;
define SkyBlue = 12;
define Yellow = 13;
define White = 14;
define Bright_Blue = 15;
define Bright_Red = 16;
define Bright_Green = 17;
define Bright_Pink = 18;
define Bright_SkyBlue = 19;
define Bright_Yellow = 20;
define Bright_White = 21;
data (
0,0,0,0,
1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1,
1,0,1,0,
0,1,1,0,
1,1,1,1,
2,0,0,0,
0,2,0,0,
0,0,2,0,
0,0,0,2,
2,0,2,0,
0,2,2,0,
2,2,2,2,
3,0,0,0,
0,3,0,0,
0,0,3,0,
0,0,0,3,
3,0,3,0,
0,3,3,0,
3,3,3,3
);
main {
if(event_press(PS4_CROSS)) {
set_ds4_led(Green);
}
if(event_press(PS4_CIRCLE)) {
set_ds4_led(Red);
}
if(event_press(PS4_OPTIONS)) {
reset_leds():
}
}
function set_ds4_led(colour) {
set_led(LED_1, dbyte(colour * 4));
set_led(LED_2, dbyte((colour * 4) + 1));
set_led(LED_3, dbyte((colour * 4) + 2));
set_led(LED_4, dbyte((colour * 4) + 3));
}
|
|
|