LED Functions
Function Name
Description
set_led
Sets the state of the LED on a controller.
get_led
Gets the state of the LED on a controller.
set_ledx
Blinks a LED a certain number of times.
get_ledx
Checks if a LED is being blinked by the set_ledx function.
reset_leds
Reset the LEDs state to what was set by the console.
get_ps4_lbar
Gets PS4 indication bar color.
set_ps4_lbar
Sets Zen indication color.
set_led
set_led sets the state of an LED on the controller. The LEDs range from 0 to 3. Four constants have been created to make it easier to remember which value is assigned to which LED.
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
An LED can be set to one of four states using this function which ranges from 0 to 3, as shown in the table below:
Value
Description
0
LED Off
1
LED On
2
LED Blink Fast
3
LED Blink Slowly
Code-Snippet
Syntax
set_led( <led identifier>, <led state> );
Parameters
<led identifier> : the LED identifier
<led state> : the state identifier of the controller LED
Returns
None
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
Code-Snippet
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_ledx
set_ledx is used to blink an 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
Code-Snippet
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
Code-Snippet
Syntax
get_ledx ( );
Parameters
None
Returns
True if 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
Code-Snippet
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.
get_ps4_lbar
get_ps4_lbar gets the PlayStation 4 lightbar LED state from the console.
get_ps4_lbar(color) There are 3 colors: PS4_RED, PS4_GREEN, and PS4_BLUE. They have a range from 0-255 (lower the number equals less brightness, higher the number equals more brighter).
Example
Code-Snippet
set_ps4_lbar
set_ps4_lbar sets the PlayStation 4 lightbar LED state on the controller and sets the color that will be sent to the controller. There are 3 colors: DS4_RED, DS4_GREEN, and DS4_BLUE. They have a range from 0-255 (lower the number equals less brightness, higher the number equals more brighter).
Example
Code-Snippet
Example using both
Code-Snippet
Last updated

