#include <cafe/kbd.h>

KBDEc KBDSetLedsEx (KBDChannel ch, KBDLedState leds);


ch Keyboard channel to set.
leds New KBDLedState to send to the keyboard.

Return Values

KBDEc Keyboard error code.
KBD_SUCCESS if the call was successful.
KBD_ERR_NOT_INITIALIZED if the library was not initialized.
KBD_ERR_BAD_VALUE if ch or leds is out of range.
KBD_ERR_BUSY if unable to send an LED command to the keyboard.


Sends an LED command to the keyboard on channel ch. The command instructs the keyboard to turn on the LEDs specified by leds.

KBDSetLedsEx is a blocking call, and it cannot be used from within a callback or whenever interrupts are disabled. To set the LEDs when interrupts are disabled, use KBDSetLedsAsyncEx or KBDSetLedsRetryEx instead.

Because this function sends a message over the USB bus, avoid calling it too frequently; this will prevent flooding of the USB bus. Avoid sending more than 12 LED commands (total for all keyboards) per 1/60 second. Even this amount is excessive and should be avoided.

This function call may fail due to other traffic on the USB bus. If it returns KBD_ERR_BUSY, the LED command was not sent. In this case, it is necessary to call it again. Because the want is for the traffic to die down before trying again, have a delay between attempts.

This function will always attempt to send the LED command. Any "lazy" setting of the LED state must be performed at a higher level.

We recommend KBDSetLedsAsyncEx, because KBDSetLedsEx will block if the keyboard's ACK fails on the USB bus.

Do Not Call From

Background Do not call this function from the background.

See Also


Revision History

2013/06/20 Initial version 0.1.