1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html> 3 4<head> 5<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 6<META name="GENERATOR" content="Microsoft FrontPage 5.0"> 7<META http-equiv="Content-Style-Type" content="text/css"> 8<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css"> 9<title>KBDSetLedsAsync</title> 10</head> 11 12<body> 13 14<h1>KBDSetLedsAsync</h1> 15 16 17<h2>C Specification</h2> 18 19<dl> 20<dd><pre><code>#include <revolution/kbd.h></code></pre> 21 </dd> 22<dd><pre><code>typedef void (*KBDLedCallbackF) (KBDLedEvent* lev, void *cbArg);</pre></code></dd> 23<dd><pre><code>KBDEc KBDSetLedsAsync (KBDChannel ch, KBDLedState leds, KBDLedCallbackF fn, void *cbArg);</code></pre> 24 </dd> 25</dl> 26 27<h2>Arguments</h2> 28 29<TABLE border="1" cellpadding="3" cellspacing="0.1"> 30 <tr> 31<TD width="120" bgcolor="#ffffe8"><code><em><strong>ch</strong></em></code></TD> 32<TD width="520">Keyboard channel to set.</TD> 33 </tr> 34 <tr> 35<TD width="120" bgcolor="#ffffe8"><code><em><strong>leds</strong></em></code></TD> 36<TD width="520">New <code>KBDLedState</code> to send to the keyboard.</TD> 37 </tr> 38 <tr> 39<TD width="120" bgcolor="#ffffe8"><code><em><strong>fn</strong></em></code></TD> 40<TD width="520">Callback function pointer to call when command completes.</TD> 41 </tr> 42 <tr> 43<TD width="120" bgcolor="#ffffe8"><code><em><strong>cbArg</strong></em></code></TD> 44<TD width="520">Argument for callback function called when command completes.</TD> 45 </tr> 46</TABLE> 47 48<h2>Return Values</h2> 49 50<TABLE border="1" cellpadding="3" cellspacing="0.1"> 51 <tr> 52<TD width="120" bgcolor="#ffffe8"><code><em><strong>KBDEc</strong></em></code></TD> 53<TD width="520">Keyboard error code.<br> <code>KBD_SUCCESS</code> if the call was successful.<br> <code>KBD_ERR_NOT_INITIALIZED</code> if the library was not initialized.<br><code>KBD_ERR_BAD_VALUE</code> if <code>ch</code> or <code>leds</code> is out of range.<br> <code>KBD_ERR_BUSY</code> if unable to send an LED command to the keyboard. 54</TD> 55 </tr> 56</TABLE> 57 58<h2>Description</h2> 59 60<p>Sends an LED command to the keyboard on channel <code>ch</code>. The command tells the keyboard to turn on the LEDs specified by <code>leds</code>.</p> 61<p><code>KBDSetLedsAsync</code> is a non-blocking call, and it may be used from within a callback or whenever interrupts are disabled. This is in contrast to the blocking version of this function, <a href="KBDSetLeds.html"><code>KBDSetLeds</code></a>.</p> 62<p><code>KBDSetLedsAsync</code> sends a message to a lower-level driver to send the USB command. Once the lower-level driver responds that it has tried to send the command, an interrupt callback occurs and the user-provided callback function is called with a return code and a user-provided argument. The <code>rc</code> returned in the callback is either <code>KBD_SUCCESS</code> or <code>KBD_BUSY</code>. This code must be checked to confirm that the LED command was successfully sent via the USB bus. The return code of this function, <code>KBDSetLedsAsync</code>, must be checked to know whether the request was sent to the lower-level driver at all.</p> 63<p>Also, since this function sends a message over the USB bus, you must avoid calling it too frequently (to avoid flooding the USB bus). You should avoid sending more than 12 LED commands (total for all keyboards) per 1/60 second. Even this amount is excessive and should be avoided.</p> 64<p>This call may fail due to other traffic on the USB bus. If it returns <code>KBD_ERR_BUSY</code> or if the callback returns <code>KBD_ERR_BUSY</code>, it means the LED command was not sent. In this case you must call it again. Because you want the traffic to die down before trying again, you should insert a delay between attempts. You may also use <a href="KBDSetLedsRetry.html"><code>KBDSetLedsRetry</code></a> instead.</p> 65<p>This function will always attempt to send the LED command. Any "lazy (delay)" setting of LED state must be done at a higher level.</p> 66<h2>See Also</h2> 67 68<p><a href="list.html">Keyboard Functions</a>, <a href="KBDSetLeds.html"><code>KBDSetLeds</code></a>, <a href="KBDSetLedsRetry.html"><code>KBDSetLedsRetry</code></a></p> 69 70<h2>Revision History</h2><p></p> 71 72<P>2007/03/19 Initial version.</p> 73 74</BODY> 75</HTML>