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<h2>Syntax</h2>
17<dl><dd><pre class="construction">#include &lt;revolution/kbd.h&gt;
18
19typedef void (*KBDLedCallbackF) (KBDLedEvent* lev, void *cbArg);
20
21KBDEc KBDSetLedsAsync (KBDChannel ch, KBDLedState leds, KBDLedCallbackF fn, void *cbArg);
22</pre></dd></dl>
23
24<h2>Arguments</h2>
25<TABLE class="arguments" border="1" >
26  <tr>
27<TH>ch</TH>
28<TD>Keyboard channel to set.</TD>
29  </tr>
30  <tr>
31<TH>leds</TH>
32<TD>New <code>KBDLedState</code> to send to the keyboard.</TD>
33  </tr>
34  <tr>
35<TH>fn</TH>
36<TD>Callback function pointer to call when command completes.</TD>
37  </tr>
38  <tr>
39<TH>cbArg</TH>
40<TD>Argument for callback function called when command completes.</TD>
41  </tr>
42</TABLE>
43
44<h2>Return Values</h2>
45<TABLE class="arguments" border="1" >
46  <tr>
47<TH>KBDEc</TH>
48<TD>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 <SPAN class="argument">ch</SPAN> or <SPAN class="argument">leds</SPAN> is out of range.<br><code>KBD_ERR_BUSY</code> if unable to send an LED command to the keyboard.
49    </TD>
50  </tr>
51</TABLE>
52
53<h2>Description</h2>
54<p>Sends an LED command to the keyboard on channel <SPAN class="argument">ch</SPAN>. The command tells the keyboard to turn on the LEDs specified by <SPAN class="argument">leds</SPAN>.</p>
55<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>
56<p>The <code>KBDSetLedsAsync</code> function 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 <SPAN class="argument">rc</SPAN> returned in the callback is either <code>KBD_SUCCESS</code> or <code>KBD_ERR_BUSY</code>. This code must be checked to confirm that the LED command was successfully sent through the USB bus. The return code of the <code>KBDSetLedsAsync</code> function must be checked to know if the request was sent to the lower-level driver at all.</p>
57<p>Also, because 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>
58<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>, this 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 the <a href="KBDSetLedsRetry.html"><code>KBDSetLedsRetry</code></a> function instead.</p>
59<p>This function will always attempt to send the LED command. Any &quot;lazy (delay)&quot; setting of LED state must be made at a higher level.</p>
60
61<h2>See Also</h2>
62<P class="reference">
63<a href="list.html">Keyboard Functions</a>,
64<a href="KBDSetLeds.html">KBDSetLeds</a>,
65<a href="KBDSetLedsRetry.html">KBDSetLedsRetry</a>
66</p>
67
68<h2>Revision History</h2>
69<P>
702007/03/19 Initial version.<br>
71</p>
72
73<hr><p>CONFIDENTIAL</p></body>
74</HTML>