×
Menu

LEDs

 
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.
 
LEDs
 
Functions related to LEDs
 
 
Function Name
Description
get_led    
Returns the current value of a LED state
set_led    
Set the state of a LED
set_ledx    
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
LED 1 / Xbox 360 Quadrant 1
0
  • LED_2
LED 2 / Xbox 360 Quadrant 2
1
  • LED_3
LED 3 / Xbox 360 Quadrant 3
2
  • LED_4
LED 4 / Xbox 360 Quadrant 4
3
 
1
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) { // If LED 2 is On
        // Do Something
    }
 
}
 

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
2
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:
 
set_led(LED_1, 3);  // Make LED 1 blink slowly
 

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
3
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()) { // If the leds are not blinking...
 
        set_led(LED_1, 10);  // Blink LED 1 10 times
 
    }
 
}
 

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
4
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()) { // If the leds are blinking...
 
        // Do Something
 
    }
 
}
 

Syntax

 
get_ledx (  );
 

Parameters

 
None
 

Returns

 
TRUE is the LEDs are being blinked by the set_ledx function, FALSE if they are not
5
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)) { // If A / Cross is Pressed...
 
        reset_leds();  // Reset Leds
 
    }
 
}
 

Syntax

 
reset_leds (  );
 

Parameters

 
None
6
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;
 
// Dualshock 4 lightbar custom function
//
// Written by the CronusMAX Team
//
// For the CronusMAX PLUS manual www.cronusmax.com/manual/leds.htm#id_6
 
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, // Off
1,0,0,0, // Dim Blue
0,1,0,0, // Dim Red
0,0,1,0, // Dim Green
0,0,0,1, // Dim Pink
1,0,1,0, // Dim SkyBlue
0,1,1,0, // Dim Yellow
1,1,1,1, // Dim White
2,0,0,0, // Blue
0,2,0,0, // Red
0,0,2,0, // Green
0,0,0,2, // Pink
2,0,2,0, // SkyBlue
0,2,2,0, // Yellow
2,2,2,2, // White
3,0,0,0, // Bright Blue
0,3,0,0, // Bright Red
0,0,3,0, // Bright Green
0,0,0,3, // Bright Pink
3,0,3,0, // Bright SkyBlue
0,3,3,0, // Bright Yellow
3,3,3,3  // Bright white
 
);
 
main {
 
    //Examples of usage
    if(event_press(PS4_CROSS)) {  // If Cross is pressed...
   
        set_ds4_led(Green);  // Set the lightbar to Green
   
    }
 
    if(event_press(PS4_CIRCLE)) {  // If Circle is pressed...
   
        set_ds4_led(Red);  // Set the lightbar to Red
 
    }
 
    if(event_press(PS4_OPTIONS)) { // If Options is pressed...
 
        reset_leds():  // Reset the 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));
 
}