Files
archived-hidapi/test_8c-example.html
2025-05-23 01:21:43 +00:00

476 lines
53 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>hidapi: test.c</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">hidapi
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="headertitle"><div class="title">test.c</div></div>
</div><!--header-->
<div class="contents">
<p>contains a basic example usage of the HIDAPI library.</p>
<div class="fragment"><div class="line"><span class="comment">/*******************************************************</span></div>
<div class="line"><span class="comment"> HIDAPI - Multi-Platform library for</span></div>
<div class="line"><span class="comment"> communication with HID devices.</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"><span class="comment"> Alan Ott</span></div>
<div class="line"><span class="comment"> Signal 11 Software</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"><span class="comment"> libusb/hidapi Team</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"><span class="comment"> Copyright 2022.</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"><span class="comment"> This contents of this file may be used by anyone</span></div>
<div class="line"><span class="comment"> for any reason without any conditions and may be</span></div>
<div class="line"><span class="comment"> used as a starting point for your own applications</span></div>
<div class="line"><span class="comment"> which use HIDAPI.</span></div>
<div class="line"><span class="comment">********************************************************/</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;stdio.h&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;wchar.h&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;string.h&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;stdlib.h&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="hidapi_8h.html">hidapi.h</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// Headers needed for sleeping.</span></div>
<div class="line"><span class="preprocessor">#ifdef _WIN32</span></div>
<div class="line"><span class="preprocessor"> #include &lt;windows.h&gt;</span></div>
<div class="line"><span class="preprocessor">#else</span></div>
<div class="line"><span class="preprocessor"> #include &lt;unistd.h&gt;</span></div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// Fallback/example</span></div>
<div class="line"><span class="preprocessor">#ifndef HID_API_MAKE_VERSION</span></div>
<div class="line"><span class="preprocessor">#define HID_API_MAKE_VERSION(mj, mn, p) (((mj) &lt;&lt; 24) | ((mn) &lt;&lt; 8) | (p))</span></div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"><span class="preprocessor">#ifndef HID_API_VERSION</span></div>
<div class="line"><span class="preprocessor">#define HID_API_VERSION HID_API_MAKE_VERSION(HID_API_VERSION_MAJOR, HID_API_VERSION_MINOR, HID_API_VERSION_PATCH)</span></div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">//</span></div>
<div class="line"><span class="comment">// Sample using platform-specific headers</span></div>
<div class="line"><span class="preprocessor">#if defined(__APPLE__) &amp;&amp; HID_API_VERSION &gt;= HID_API_MAKE_VERSION(0, 12, 0)</span></div>
<div class="line"><span class="preprocessor">#include &lt;hidapi_darwin.h&gt;</span></div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#if defined(_WIN32) &amp;&amp; HID_API_VERSION &gt;= HID_API_MAKE_VERSION(0, 12, 0)</span></div>
<div class="line"><span class="preprocessor">#include &lt;hidapi_winapi.h&gt;</span></div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#if defined(USING_HIDAPI_LIBUSB) &amp;&amp; HID_API_VERSION &gt;= HID_API_MAKE_VERSION(0, 12, 0)</span></div>
<div class="line"><span class="preprocessor">#include &lt;hidapi_libusb.h&gt;</span></div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"><span class="comment">//</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *hid_bus_name(<a class="code hl_enumeration" href="group__API.html#ga15cb543842973ca41daa21feaec534ce">hid_bus_type</a> bus_type) {</div>
<div class="line"> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<span class="keyword">const</span> HidBusTypeName[] = {</div>
<div class="line"> <span class="stringliteral">&quot;Unknown&quot;</span>,</div>
<div class="line"> <span class="stringliteral">&quot;USB&quot;</span>,</div>
<div class="line"> <span class="stringliteral">&quot;Bluetooth&quot;</span>,</div>
<div class="line"> <span class="stringliteral">&quot;I2C&quot;</span>,</div>
<div class="line"> <span class="stringliteral">&quot;SPI&quot;</span>,</div>
<div class="line"> };</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">if</span> ((<span class="keywordtype">int</span>)bus_type &lt; 0)</div>
<div class="line"> bus_type = <a id="a0" name="a0"></a><a class="code hl_enumvalue" href="group__API.html#gga15cb543842973ca41daa21feaec534ceacab9ef7570aa48c13a99b28c61ae918e">HID_API_BUS_UNKNOWN</a>;</div>
<div class="line"> <span class="keywordflow">if</span> ((<span class="keywordtype">int</span>)bus_type &gt;= (<span class="keywordtype">int</span>)(<span class="keyword">sizeof</span>(HidBusTypeName) / <span class="keyword">sizeof</span>(HidBusTypeName[0])))</div>
<div class="line"> bus_type = <a class="code hl_enumvalue" href="group__API.html#gga15cb543842973ca41daa21feaec534ceacab9ef7570aa48c13a99b28c61ae918e">HID_API_BUS_UNKNOWN</a>;</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">return</span> HidBusTypeName[bus_type];</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> print_device(<span class="keyword">struct</span> <a id="_a1" name="_a1"></a><a class="code hl_struct" href="structhid__device__info.html">hid_device_info</a> *cur_dev) {</div>
<div class="line"> printf(<span class="stringliteral">&quot;Device Found\n type: %04hx %04hx\n path: %s\n serial_number: %ls&quot;</span>, cur_dev-&gt;<a id="a2" name="a2"></a><a class="code hl_variable" href="structhid__device__info.html#a5037a3914e0bd8a3f821d1be9376c709">vendor_id</a>, cur_dev-&gt;<a id="a3" name="a3"></a><a class="code hl_variable" href="structhid__device__info.html#a04595915457b4374492edb1fdb62d65d">product_id</a>, cur_dev-&gt;<a id="a4" name="a4"></a><a class="code hl_variable" href="structhid__device__info.html#a6384b5bf4d9583598e5f5a889f240921">path</a>, cur_dev-&gt;<a id="a5" name="a5"></a><a class="code hl_variable" href="structhid__device__info.html#a80756cea367e1566f966438984b75faf">serial_number</a>);</div>
<div class="line"> printf(<span class="stringliteral">&quot;\n&quot;</span>);</div>
<div class="line"> printf(<span class="stringliteral">&quot; Manufacturer: %ls\n&quot;</span>, cur_dev-&gt;<a id="a6" name="a6"></a><a class="code hl_variable" href="structhid__device__info.html#a484eebf746220cd2910954cc861759b7">manufacturer_string</a>);</div>
<div class="line"> printf(<span class="stringliteral">&quot; Product: %ls\n&quot;</span>, cur_dev-&gt;<a id="a7" name="a7"></a><a class="code hl_variable" href="structhid__device__info.html#aceee256b4f7cd7fdd9fa5d556f49d221">product_string</a>);</div>
<div class="line"> printf(<span class="stringliteral">&quot; Release: %hx\n&quot;</span>, cur_dev-&gt;<a id="a8" name="a8"></a><a class="code hl_variable" href="structhid__device__info.html#a6a832d25260f7ec17ef008e53e50e1d0">release_number</a>);</div>
<div class="line"> printf(<span class="stringliteral">&quot; Interface: %d\n&quot;</span>, cur_dev-&gt;<a id="a9" name="a9"></a><a class="code hl_variable" href="structhid__device__info.html#a9163d8d5d7db8dc47bddfaf876e17547">interface_number</a>);</div>
<div class="line"> printf(<span class="stringliteral">&quot; Usage (page): 0x%hx (0x%hx)\n&quot;</span>, cur_dev-&gt;<a id="a10" name="a10"></a><a class="code hl_variable" href="structhid__device__info.html#a47f8011d58bcddd67f1403d6d3b4cab6">usage</a>, cur_dev-&gt;<a id="a11" name="a11"></a><a class="code hl_variable" href="structhid__device__info.html#ab811117f8084ce2036815bdd33b16b3b">usage_page</a>);</div>
<div class="line"> printf(<span class="stringliteral">&quot; Bus type: %u (%s)\n&quot;</span>, (<span class="keywordtype">unsigned</span>)cur_dev-&gt;<a id="a12" name="a12"></a><a class="code hl_variable" href="structhid__device__info.html#afa3c7d42a0892d9f1f25976709cf5aa2">bus_type</a>, hid_bus_name(cur_dev-&gt;<a class="code hl_variable" href="structhid__device__info.html#afa3c7d42a0892d9f1f25976709cf5aa2">bus_type</a>));</div>
<div class="line"> printf(<span class="stringliteral">&quot;\n&quot;</span>);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> print_hid_report_descriptor_from_device(<a class="code hl_typedef" href="hidapi_8h.html#aa6da74d5686d198dd3e5440e60088fcc">hid_device</a> *device) {</div>
<div class="line"> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> descriptor[<a id="a13" name="a13"></a><a class="code hl_define" href="group__API.html#ga4e861f585ad041d94b142e1c2ee00b3f">HID_API_MAX_REPORT_DESCRIPTOR_SIZE</a>];</div>
<div class="line"> <span class="keywordtype">int</span> res = 0;</div>
<div class="line"> </div>
<div class="line"> printf(<span class="stringliteral">&quot; Report Descriptor: &quot;</span>);</div>
<div class="line"><span class="preprocessor">#if HID_API_VERSION &gt;= HID_API_MAKE_VERSION(0, 14, 0)</span></div>
<div class="line"> res = <a id="a14" name="a14"></a><a class="code hl_function" href="group__API.html#gaaa8bc561909c1c6b413f1fcdc16333ef">hid_get_report_descriptor</a>(device, descriptor, <span class="keyword">sizeof</span>(descriptor));</div>
<div class="line"><span class="preprocessor">#else</span></div>
<div class="line"> (void)res;</div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"> <span class="keywordflow">if</span> (res &lt; 0) {</div>
<div class="line"> printf(<span class="stringliteral">&quot;error getting: %ls&quot;</span>, <a id="a15" name="a15"></a><a class="code hl_function" href="group__API.html#gabdb1e88a803bab198333a3c5f131b12e">hid_error</a>(device));</div>
<div class="line"> }</div>
<div class="line"> <span class="keywordflow">else</span> {</div>
<div class="line"> printf(<span class="stringliteral">&quot;(%d bytes)&quot;</span>, res);</div>
<div class="line"> }</div>
<div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; res; i++) {</div>
<div class="line"> <span class="keywordflow">if</span> (i % 10 == 0) {</div>
<div class="line"> printf(<span class="stringliteral">&quot;\n&quot;</span>);</div>
<div class="line"> }</div>
<div class="line"> printf(<span class="stringliteral">&quot;0x%02x, &quot;</span>, descriptor[i]);</div>
<div class="line"> }</div>
<div class="line"> printf(<span class="stringliteral">&quot;\n&quot;</span>);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> print_hid_report_descriptor_from_path(<span class="keyword">const</span> <span class="keywordtype">char</span> *path) {</div>
<div class="line"> <a class="code hl_typedef" href="hidapi_8h.html#aa6da74d5686d198dd3e5440e60088fcc">hid_device</a> *device = <a id="a16" name="a16"></a><a class="code hl_function" href="group__API.html#ga954ecb58b5dfb4a6ef6be3dcd520e42f">hid_open_path</a>(path);</div>
<div class="line"> <span class="keywordflow">if</span> (device) {</div>
<div class="line"> print_hid_report_descriptor_from_device(device);</div>
<div class="line"> <a id="a17" name="a17"></a><a class="code hl_function" href="group__API.html#ga8d478a5986439ffb838fb1f1ba6ba5ec">hid_close</a>(device);</div>
<div class="line"> }</div>
<div class="line"> <span class="keywordflow">else</span> {</div>
<div class="line"> printf(<span class="stringliteral">&quot; Report Descriptor: Unable to open device by path\n&quot;</span>);</div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> print_devices(<span class="keyword">struct</span> <a class="code hl_struct" href="structhid__device__info.html">hid_device_info</a> *cur_dev) {</div>
<div class="line"> <span class="keywordflow">for</span> (; cur_dev; cur_dev = cur_dev-&gt;<a id="a18" name="a18"></a><a class="code hl_variable" href="structhid__device__info.html#a2bfebc240baf3bdaf03965816e11f149">next</a>) {</div>
<div class="line"> print_device(cur_dev);</div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> print_devices_with_descriptor(<span class="keyword">struct</span> <a class="code hl_struct" href="structhid__device__info.html">hid_device_info</a> *cur_dev) {</div>
<div class="line"> <span class="keywordflow">for</span> (; cur_dev; cur_dev = cur_dev-&gt;<a class="code hl_variable" href="structhid__device__info.html#a2bfebc240baf3bdaf03965816e11f149">next</a>) {</div>
<div class="line"> print_device(cur_dev);</div>
<div class="line"> print_hid_report_descriptor_from_path(cur_dev-&gt;<a class="code hl_variable" href="structhid__device__info.html#a6384b5bf4d9583598e5f5a889f240921">path</a>);</div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])</div>
<div class="line">{</div>
<div class="line"> (void)argc;</div>
<div class="line"> (void)argv;</div>
<div class="line"> </div>
<div class="line"> <span class="comment">/* --- HIDAPI R&amp;D: this is just to force the compiler to ensure</span></div>
<div class="line"><span class="comment"> each of those functions are implemented (even as a stub)</span></div>
<div class="line"><span class="comment"> by each backend. --- */</span></div>
<div class="line"> (void)&amp;<a id="a19" name="a19"></a><a class="code hl_function" href="group__API.html#ga6946f7e2f5d225d69308611db1e31ede">hid_open</a>;</div>
<div class="line"> (void)&amp;<a class="code hl_function" href="group__API.html#ga954ecb58b5dfb4a6ef6be3dcd520e42f">hid_open_path</a>;</div>
<div class="line"> (void)&amp;<a id="a20" name="a20"></a><a class="code hl_function" href="group__API.html#gaa5c9ed5aa290688ffac03343989ad75a">hid_read_timeout</a>;</div>
<div class="line"> (void)&amp;<a id="a21" name="a21"></a><a class="code hl_function" href="group__API.html#ga27ac7d92ea3a8ac58b1d8d865bd0264b">hid_get_input_report</a>;</div>
<div class="line"><span class="preprocessor">#if HID_API_VERSION &gt;= HID_API_MAKE_VERSION(0, 15, 0)</span></div>
<div class="line"> (void)&amp;<a id="a22" name="a22"></a><a class="code hl_function" href="group__API.html#ga6f18ce9abffb0a9e7b1b5bac0e39376f">hid_send_output_report</a>;</div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"> (void)&amp;<a id="a23" name="a23"></a><a class="code hl_function" href="group__API.html#gaa537a4b3c49d638c6ec9dedc08c44601">hid_get_feature_report</a>;</div>
<div class="line"> (void)&amp;<a id="a24" name="a24"></a><a class="code hl_function" href="group__API.html#gae99a9ddbb5d9b03fddf40fb4a492cbec">hid_send_feature_report</a>;</div>
<div class="line"><span class="preprocessor">#if HID_API_VERSION &gt;= HID_API_MAKE_VERSION(0, 14, 0)</span></div>
<div class="line"> (void)&amp;<a class="code hl_function" href="group__API.html#gaaa8bc561909c1c6b413f1fcdc16333ef">hid_get_report_descriptor</a>;</div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"> <span class="comment">/* --- */</span></div>
<div class="line"> </div>
<div class="line"> <span class="keywordtype">int</span> res;</div>
<div class="line"> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> buf[256];</div>
<div class="line"><span class="preprocessor"> #define MAX_STR 255</span></div>
<div class="line"> <span class="keywordtype">wchar_t</span> wstr[MAX_STR];</div>
<div class="line"> <a class="code hl_typedef" href="hidapi_8h.html#aa6da74d5686d198dd3e5440e60088fcc">hid_device</a> *handle;</div>
<div class="line"> <span class="keywordtype">int</span> i;</div>
<div class="line"> </div>
<div class="line"> <span class="keyword">struct </span><a class="code hl_struct" href="structhid__device__info.html">hid_device_info</a> *devs;</div>
<div class="line"> </div>
<div class="line"> printf(<span class="stringliteral">&quot;hidapi test/example tool. Compiled with hidapi version %s, runtime version %s.\n&quot;</span>, <a id="a25" name="a25"></a><a class="code hl_define" href="group__API.html#gacba3a91088b7e54857626be97c47fdb9">HID_API_VERSION_STR</a>, <a id="a26" name="a26"></a><a class="code hl_function" href="group__API.html#gacbceccb9fd443fd7cb164dee029fbf64">hid_version_str</a>());</div>
<div class="line"> <span class="keywordflow">if</span> (<a id="a27" name="a27"></a><a class="code hl_define" href="group__API.html#gade33c6fcd36510e02004311124ea2093">HID_API_VERSION</a> == <a id="a28" name="a28"></a><a class="code hl_define" href="group__API.html#gaf415391c655f68807580fe3fb8f7ba67">HID_API_MAKE_VERSION</a>(<a id="a29" name="a29"></a><a class="code hl_function" href="group__API.html#gaea589e58403a465361a347c0754a3da2">hid_version</a>()-&gt;major, <a class="code hl_function" href="group__API.html#gaea589e58403a465361a347c0754a3da2">hid_version</a>()-&gt;minor, <a class="code hl_function" href="group__API.html#gaea589e58403a465361a347c0754a3da2">hid_version</a>()-&gt;patch)) {</div>
<div class="line"> printf(<span class="stringliteral">&quot;Compile-time version matches runtime version of hidapi.\n\n&quot;</span>);</div>
<div class="line"> }</div>
<div class="line"> <span class="keywordflow">else</span> {</div>
<div class="line"> printf(<span class="stringliteral">&quot;Compile-time version is different than runtime version of hidapi.\n]n&quot;</span>);</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">if</span> (<a id="a30" name="a30"></a><a class="code hl_function" href="group__API.html#ga142ffc1b0b7a7fa412d3862b2a17164b">hid_init</a>())</div>
<div class="line"> <span class="keywordflow">return</span> -1;</div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#if defined(__APPLE__) &amp;&amp; HID_API_VERSION &gt;= HID_API_MAKE_VERSION(0, 12, 0)</span></div>
<div class="line"> <span class="comment">// To work properly needs to be called before hid_open/hid_open_path after hid_init.</span></div>
<div class="line"> <span class="comment">// Best/recommended option - call it right after hid_init.</span></div>
<div class="line"> hid_darwin_set_open_exclusive(0);</div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"> </div>
<div class="line"> devs = <a id="a31" name="a31"></a><a class="code hl_function" href="group__API.html#gaae7d1c3e90835556ddc73fabe3a9ca9d">hid_enumerate</a>(0x0, 0x0);</div>
<div class="line"> print_devices_with_descriptor(devs);</div>
<div class="line"> <a id="a32" name="a32"></a><a class="code hl_function" href="group__API.html#gafc2d2adf71db3784b783b9a554527aa4">hid_free_enumeration</a>(devs);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Set up the command buffer.</span></div>
<div class="line"> memset(buf,0x00,<span class="keyword">sizeof</span>(buf));</div>
<div class="line"> buf[0] = 0x01;</div>
<div class="line"> buf[1] = 0x81;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Open the device using the VID, PID,</span></div>
<div class="line"> <span class="comment">// and optionally the Serial number.</span></div>
<div class="line"> handle = <a class="code hl_function" href="group__API.html#ga6946f7e2f5d225d69308611db1e31ede">hid_open</a>(0x4d8, 0x3f, NULL);</div>
<div class="line"> <span class="keywordflow">if</span> (!handle) {</div>
<div class="line"> printf(<span class="stringliteral">&quot;unable to open device\n&quot;</span>);</div>
<div class="line"> <a id="a33" name="a33"></a><a class="code hl_function" href="group__API.html#gacf5da9ce37132eba69fc259f17f13023">hid_exit</a>();</div>
<div class="line"> <span class="keywordflow">return</span> 1;</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#if defined(_WIN32) &amp;&amp; HID_API_VERSION &gt;= HID_API_MAKE_VERSION(0, 15, 0)</span></div>
<div class="line"> hid_winapi_set_write_timeout(handle, 5000);</div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Read the Manufacturer String</span></div>
<div class="line"> wstr[0] = 0x0000;</div>
<div class="line"> res = <a id="a34" name="a34"></a><a class="code hl_function" href="group__API.html#ga702f45b42d85599eedd602c05661fde5">hid_get_manufacturer_string</a>(handle, wstr, MAX_STR);</div>
<div class="line"> <span class="keywordflow">if</span> (res &lt; 0)</div>
<div class="line"> printf(<span class="stringliteral">&quot;Unable to read manufacturer string\n&quot;</span>);</div>
<div class="line"> printf(<span class="stringliteral">&quot;Manufacturer String: %ls\n&quot;</span>, wstr);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Read the Product String</span></div>
<div class="line"> wstr[0] = 0x0000;</div>
<div class="line"> res = <a id="a35" name="a35"></a><a class="code hl_function" href="group__API.html#ga648feb765c5e0da3e821ee84aeab9d99">hid_get_product_string</a>(handle, wstr, MAX_STR);</div>
<div class="line"> <span class="keywordflow">if</span> (res &lt; 0)</div>
<div class="line"> printf(<span class="stringliteral">&quot;Unable to read product string\n&quot;</span>);</div>
<div class="line"> printf(<span class="stringliteral">&quot;Product String: %ls\n&quot;</span>, wstr);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Read the Serial Number String</span></div>
<div class="line"> wstr[0] = 0x0000;</div>
<div class="line"> res = <a id="a36" name="a36"></a><a class="code hl_function" href="group__API.html#ga3442db3ece59fe248b0625a4c8fca617">hid_get_serial_number_string</a>(handle, wstr, MAX_STR);</div>
<div class="line"> <span class="keywordflow">if</span> (res &lt; 0)</div>
<div class="line"> printf(<span class="stringliteral">&quot;Unable to read serial number string\n&quot;</span>);</div>
<div class="line"> printf(<span class="stringliteral">&quot;Serial Number String: (%d) %ls\n&quot;</span>, wstr[0], wstr);</div>
<div class="line"> </div>
<div class="line"> print_hid_report_descriptor_from_device(handle);</div>
<div class="line"> </div>
<div class="line"> <span class="keyword">struct </span><a class="code hl_struct" href="structhid__device__info.html">hid_device_info</a>* info = <a id="a37" name="a37"></a><a class="code hl_function" href="group__API.html#ga2d8b34ae8cfdd4f4d132814d5b70c128">hid_get_device_info</a>(handle);</div>
<div class="line"> <span class="keywordflow">if</span> (info == NULL) {</div>
<div class="line"> printf(<span class="stringliteral">&quot;Unable to get device info\n&quot;</span>);</div>
<div class="line"> } <span class="keywordflow">else</span> {</div>
<div class="line"> print_devices(info);</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Read Indexed String 1</span></div>
<div class="line"> wstr[0] = 0x0000;</div>
<div class="line"> res = <a id="a38" name="a38"></a><a class="code hl_function" href="group__API.html#ga18546669554746d0f292ca5e23372e06">hid_get_indexed_string</a>(handle, 1, wstr, MAX_STR);</div>
<div class="line"> <span class="keywordflow">if</span> (res &lt; 0)</div>
<div class="line"> printf(<span class="stringliteral">&quot;Unable to read indexed string 1\n&quot;</span>);</div>
<div class="line"> printf(<span class="stringliteral">&quot;Indexed String 1: %ls\n&quot;</span>, wstr);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Set the hid_read() function to be non-blocking.</span></div>
<div class="line"> <a id="a39" name="a39"></a><a class="code hl_function" href="group__API.html#ga0e9af0d8ed72f5610e9297c90b08e242">hid_set_nonblocking</a>(handle, 1);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Try to read from the device. There should be no</span></div>
<div class="line"> <span class="comment">// data here, but execution should not block.</span></div>
<div class="line"> res = <a id="a40" name="a40"></a><a class="code hl_function" href="group__API.html#ga2224269e8cd7c789f9fd4864a73f8c95">hid_read</a>(handle, buf, 17);</div>
<div class="line"> <span class="keywordflow">if</span> (res &lt; 0) {</div>
<div class="line"><span class="preprocessor">#if HID_API_VERSION &gt;= HID_API_MAKE_VERSION(0, 15, 0)</span></div>
<div class="line"> printf(<span class="stringliteral">&quot;Unable to read from device: %ls\n&quot;</span>, <a id="a41" name="a41"></a><a class="code hl_function" href="group__API.html#ga5d7137c63986df36560e39289e4928e1">hid_read_error</a>(handle));</div>
<div class="line"><span class="preprocessor">#else</span></div>
<div class="line"> printf(<span class="stringliteral">&quot;Unable to read from device: %ls\n&quot;</span>, <a class="code hl_function" href="group__API.html#gabdb1e88a803bab198333a3c5f131b12e">hid_error</a>(handle));</div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Send a Feature Report to the device</span></div>
<div class="line"> buf[0] = 0x2;</div>
<div class="line"> buf[1] = 0xa0;</div>
<div class="line"> buf[2] = 0x0a;</div>
<div class="line"> buf[3] = 0x00;</div>
<div class="line"> buf[4] = 0x00;</div>
<div class="line"> res = <a class="code hl_function" href="group__API.html#gae99a9ddbb5d9b03fddf40fb4a492cbec">hid_send_feature_report</a>(handle, buf, 17);</div>
<div class="line"> <span class="keywordflow">if</span> (res &lt; 0) {</div>
<div class="line"> printf(<span class="stringliteral">&quot;Unable to send a feature report: %ls\n&quot;</span>, <a class="code hl_function" href="group__API.html#gabdb1e88a803bab198333a3c5f131b12e">hid_error</a>(handle));</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> memset(buf,0,<span class="keyword">sizeof</span>(buf));</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Read a Feature Report from the device</span></div>
<div class="line"> buf[0] = 0x2;</div>
<div class="line"> res = <a class="code hl_function" href="group__API.html#gaa537a4b3c49d638c6ec9dedc08c44601">hid_get_feature_report</a>(handle, buf, <span class="keyword">sizeof</span>(buf));</div>
<div class="line"> <span class="keywordflow">if</span> (res &lt; 0) {</div>
<div class="line"> printf(<span class="stringliteral">&quot;Unable to get a feature report: %ls\n&quot;</span>, <a class="code hl_function" href="group__API.html#gabdb1e88a803bab198333a3c5f131b12e">hid_error</a>(handle));</div>
<div class="line"> }</div>
<div class="line"> <span class="keywordflow">else</span> {</div>
<div class="line"> <span class="comment">// Print out the returned buffer.</span></div>
<div class="line"> printf(<span class="stringliteral">&quot;Feature Report\n &quot;</span>);</div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i &lt; res; i++)</div>
<div class="line"> printf(<span class="stringliteral">&quot;%02x &quot;</span>, (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>) buf[i]);</div>
<div class="line"> printf(<span class="stringliteral">&quot;\n&quot;</span>);</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> memset(buf,0,<span class="keyword">sizeof</span>(buf));</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Toggle LED (cmd 0x80). The first byte is the report number (0x1).</span></div>
<div class="line"> buf[0] = 0x1;</div>
<div class="line"> buf[1] = 0x80;</div>
<div class="line"> res = <a id="a42" name="a42"></a><a class="code hl_function" href="group__API.html#gaa691d2c469b9654128196bf7ef8edd9d">hid_write</a>(handle, buf, 17);</div>
<div class="line"> <span class="keywordflow">if</span> (res &lt; 0) {</div>
<div class="line"> printf(<span class="stringliteral">&quot;Unable to write(): %ls\n&quot;</span>, <a class="code hl_function" href="group__API.html#gabdb1e88a803bab198333a3c5f131b12e">hid_error</a>(handle));</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Request state (cmd 0x81). The first byte is the report number (0x1).</span></div>
<div class="line"> buf[0] = 0x1;</div>
<div class="line"> buf[1] = 0x81;</div>
<div class="line"> <a class="code hl_function" href="group__API.html#gaa691d2c469b9654128196bf7ef8edd9d">hid_write</a>(handle, buf, 17);</div>
<div class="line"> <span class="keywordflow">if</span> (res &lt; 0) {</div>
<div class="line"> printf(<span class="stringliteral">&quot;Unable to write()/2: %ls\n&quot;</span>, <a class="code hl_function" href="group__API.html#gabdb1e88a803bab198333a3c5f131b12e">hid_error</a>(handle));</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Read requested state. hid_read() has been set to be</span></div>
<div class="line"> <span class="comment">// non-blocking by the call to hid_set_nonblocking() above.</span></div>
<div class="line"> <span class="comment">// This loop demonstrates the non-blocking nature of hid_read().</span></div>
<div class="line"> res = 0;</div>
<div class="line"> i = 0;</div>
<div class="line"> <span class="keywordflow">while</span> (res == 0) {</div>
<div class="line"> res = <a class="code hl_function" href="group__API.html#ga2224269e8cd7c789f9fd4864a73f8c95">hid_read</a>(handle, buf, <span class="keyword">sizeof</span>(buf));</div>
<div class="line"> <span class="keywordflow">if</span> (res == 0) {</div>
<div class="line"> printf(<span class="stringliteral">&quot;waiting...\n&quot;</span>);</div>
<div class="line"> }</div>
<div class="line"> <span class="keywordflow">if</span> (res &lt; 0) {</div>
<div class="line"> printf(<span class="stringliteral">&quot;Unable to read(): %ls\n&quot;</span>, <a class="code hl_function" href="group__API.html#gabdb1e88a803bab198333a3c5f131b12e">hid_error</a>(handle));</div>
<div class="line"> <span class="keywordflow">break</span>;</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> i++;</div>
<div class="line"> <span class="keywordflow">if</span> (i &gt;= 10) { <span class="comment">/* 10 tries by 500 ms - 5 seconds of waiting*/</span></div>
<div class="line"> printf(<span class="stringliteral">&quot;read() timeout\n&quot;</span>);</div>
<div class="line"> <span class="keywordflow">break</span>;</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#ifdef _WIN32</span></div>
<div class="line"> Sleep(500);</div>
<div class="line"><span class="preprocessor">#else</span></div>
<div class="line"> usleep(500*1000);</div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">if</span> (res &gt; 0) {</div>
<div class="line"> printf(<span class="stringliteral">&quot;Data read:\n &quot;</span>);</div>
<div class="line"> <span class="comment">// Print out the returned buffer.</span></div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i &lt; res; i++)</div>
<div class="line"> printf(<span class="stringliteral">&quot;%02x &quot;</span>, (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>) buf[i]);</div>
<div class="line"> printf(<span class="stringliteral">&quot;\n&quot;</span>);</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> <a class="code hl_function" href="group__API.html#ga8d478a5986439ffb838fb1f1ba6ba5ec">hid_close</a>(handle);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">/* Free static HIDAPI objects. */</span></div>
<div class="line"> <a class="code hl_function" href="group__API.html#gacf5da9ce37132eba69fc259f17f13023">hid_exit</a>();</div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#ifdef _WIN32</span></div>
<div class="line"> system(<span class="stringliteral">&quot;pause&quot;</span>);</div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
<div class="ttc" id="agroup__API_html_ga0e9af0d8ed72f5610e9297c90b08e242"><div class="ttname"><a href="group__API.html#ga0e9af0d8ed72f5610e9297c90b08e242">hid_set_nonblocking</a></div><div class="ttdeci">int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *dev, int nonblock)</div><div class="ttdoc">Set the device handle to be non-blocking.</div></div>
<div class="ttc" id="agroup__API_html_ga142ffc1b0b7a7fa412d3862b2a17164b"><div class="ttname"><a href="group__API.html#ga142ffc1b0b7a7fa412d3862b2a17164b">hid_init</a></div><div class="ttdeci">int HID_API_EXPORT HID_API_CALL hid_init(void)</div><div class="ttdoc">Initialize the HIDAPI library.</div></div>
<div class="ttc" id="agroup__API_html_ga15cb543842973ca41daa21feaec534ce"><div class="ttname"><a href="group__API.html#ga15cb543842973ca41daa21feaec534ce">hid_bus_type</a></div><div class="ttdeci">hid_bus_type</div><div class="ttdoc">HID underlying bus types.</div><div class="ttdef"><b>Definition</b> hidapi.h:122</div></div>
<div class="ttc" id="agroup__API_html_ga18546669554746d0f292ca5e23372e06"><div class="ttname"><a href="group__API.html#ga18546669554746d0f292ca5e23372e06">hid_get_indexed_string</a></div><div class="ttdeci">int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen)</div><div class="ttdoc">Get a string from a HID device, based on its string index.</div></div>
<div class="ttc" id="agroup__API_html_ga2224269e8cd7c789f9fd4864a73f8c95"><div class="ttname"><a href="group__API.html#ga2224269e8cd7c789f9fd4864a73f8c95">hid_read</a></div><div class="ttdeci">int HID_API_EXPORT HID_API_CALL hid_read(hid_device *dev, unsigned char *data, size_t length)</div><div class="ttdoc">Read an Input report from a HID device.</div></div>
<div class="ttc" id="agroup__API_html_ga27ac7d92ea3a8ac58b1d8d865bd0264b"><div class="ttname"><a href="group__API.html#ga27ac7d92ea3a8ac58b1d8d865bd0264b">hid_get_input_report</a></div><div class="ttdeci">int HID_API_EXPORT HID_API_CALL hid_get_input_report(hid_device *dev, unsigned char *data, size_t length)</div><div class="ttdoc">Get a input report from a HID device.</div></div>
<div class="ttc" id="agroup__API_html_ga2d8b34ae8cfdd4f4d132814d5b70c128"><div class="ttname"><a href="group__API.html#ga2d8b34ae8cfdd4f4d132814d5b70c128">hid_get_device_info</a></div><div class="ttdeci">struct hid_device_info HID_API_EXPORT *HID_API_CALL hid_get_device_info(hid_device *dev)</div><div class="ttdoc">Get The struct hid_device_info from a HID device.</div></div>
<div class="ttc" id="agroup__API_html_ga3442db3ece59fe248b0625a4c8fca617"><div class="ttname"><a href="group__API.html#ga3442db3ece59fe248b0625a4c8fca617">hid_get_serial_number_string</a></div><div class="ttdeci">int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen)</div><div class="ttdoc">Get The Serial Number String from a HID device.</div></div>
<div class="ttc" id="agroup__API_html_ga4e861f585ad041d94b142e1c2ee00b3f"><div class="ttname"><a href="group__API.html#ga4e861f585ad041d94b142e1c2ee00b3f">HID_API_MAX_REPORT_DESCRIPTOR_SIZE</a></div><div class="ttdeci">#define HID_API_MAX_REPORT_DESCRIPTOR_SIZE</div><div class="ttdoc">Maximum expected HID Report descriptor size in bytes.</div><div class="ttdef"><b>Definition</b> hidapi.h:103</div></div>
<div class="ttc" id="agroup__API_html_ga5d7137c63986df36560e39289e4928e1"><div class="ttname"><a href="group__API.html#ga5d7137c63986df36560e39289e4928e1">hid_read_error</a></div><div class="ttdeci">HID_API_EXPORT const wchar_t *HID_API_CALL hid_read_error(hid_device *dev)</div><div class="ttdoc">Get a string describing the last error which occurred during hid_read/hid_read_timeout.</div></div>
<div class="ttc" id="agroup__API_html_ga648feb765c5e0da3e821ee84aeab9d99"><div class="ttname"><a href="group__API.html#ga648feb765c5e0da3e821ee84aeab9d99">hid_get_product_string</a></div><div class="ttdeci">int HID_API_EXPORT_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen)</div><div class="ttdoc">Get The Product String from a HID device.</div></div>
<div class="ttc" id="agroup__API_html_ga6946f7e2f5d225d69308611db1e31ede"><div class="ttname"><a href="group__API.html#ga6946f7e2f5d225d69308611db1e31ede">hid_open</a></div><div class="ttdeci">HID_API_EXPORT hid_device *HID_API_CALL hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number)</div><div class="ttdoc">Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number.</div></div>
<div class="ttc" id="agroup__API_html_ga6f18ce9abffb0a9e7b1b5bac0e39376f"><div class="ttname"><a href="group__API.html#ga6f18ce9abffb0a9e7b1b5bac0e39376f">hid_send_output_report</a></div><div class="ttdeci">int HID_API_EXPORT HID_API_CALL hid_send_output_report(hid_device *dev, const unsigned char *data, size_t length)</div><div class="ttdoc">Send a Output report to the device.</div></div>
<div class="ttc" id="agroup__API_html_ga702f45b42d85599eedd602c05661fde5"><div class="ttname"><a href="group__API.html#ga702f45b42d85599eedd602c05661fde5">hid_get_manufacturer_string</a></div><div class="ttdeci">int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen)</div><div class="ttdoc">Get The Manufacturer String from a HID device.</div></div>
<div class="ttc" id="agroup__API_html_ga8d478a5986439ffb838fb1f1ba6ba5ec"><div class="ttname"><a href="group__API.html#ga8d478a5986439ffb838fb1f1ba6ba5ec">hid_close</a></div><div class="ttdeci">void HID_API_EXPORT HID_API_CALL hid_close(hid_device *dev)</div><div class="ttdoc">Close a HID device.</div></div>
<div class="ttc" id="agroup__API_html_ga954ecb58b5dfb4a6ef6be3dcd520e42f"><div class="ttname"><a href="group__API.html#ga954ecb58b5dfb4a6ef6be3dcd520e42f">hid_open_path</a></div><div class="ttdeci">HID_API_EXPORT hid_device *HID_API_CALL hid_open_path(const char *path)</div><div class="ttdoc">Open a HID device by its path name.</div></div>
<div class="ttc" id="agroup__API_html_gaa537a4b3c49d638c6ec9dedc08c44601"><div class="ttname"><a href="group__API.html#gaa537a4b3c49d638c6ec9dedc08c44601">hid_get_feature_report</a></div><div class="ttdeci">int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length)</div><div class="ttdoc">Get a feature report from a HID device.</div></div>
<div class="ttc" id="agroup__API_html_gaa5c9ed5aa290688ffac03343989ad75a"><div class="ttname"><a href="group__API.html#gaa5c9ed5aa290688ffac03343989ad75a">hid_read_timeout</a></div><div class="ttdeci">int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds)</div><div class="ttdoc">Read an Input report from a HID device with timeout.</div></div>
<div class="ttc" id="agroup__API_html_gaa691d2c469b9654128196bf7ef8edd9d"><div class="ttname"><a href="group__API.html#gaa691d2c469b9654128196bf7ef8edd9d">hid_write</a></div><div class="ttdeci">int HID_API_EXPORT HID_API_CALL hid_write(hid_device *dev, const unsigned char *data, size_t length)</div><div class="ttdoc">Write an Output report to a HID device.</div></div>
<div class="ttc" id="agroup__API_html_gaaa8bc561909c1c6b413f1fcdc16333ef"><div class="ttname"><a href="group__API.html#gaaa8bc561909c1c6b413f1fcdc16333ef">hid_get_report_descriptor</a></div><div class="ttdeci">int HID_API_EXPORT_CALL hid_get_report_descriptor(hid_device *dev, unsigned char *buf, size_t buf_size)</div><div class="ttdoc">Get a report descriptor from a HID device.</div></div>
<div class="ttc" id="agroup__API_html_gaae7d1c3e90835556ddc73fabe3a9ca9d"><div class="ttname"><a href="group__API.html#gaae7d1c3e90835556ddc73fabe3a9ca9d">hid_enumerate</a></div><div class="ttdeci">struct hid_device_info HID_API_EXPORT *HID_API_CALL hid_enumerate(unsigned short vendor_id, unsigned short product_id)</div><div class="ttdoc">Enumerate the HID Devices.</div></div>
<div class="ttc" id="agroup__API_html_gabdb1e88a803bab198333a3c5f131b12e"><div class="ttname"><a href="group__API.html#gabdb1e88a803bab198333a3c5f131b12e">hid_error</a></div><div class="ttdeci">HID_API_EXPORT const wchar_t *HID_API_CALL hid_error(hid_device *dev)</div><div class="ttdoc">Get a string describing the last error which occurred.</div></div>
<div class="ttc" id="agroup__API_html_gacba3a91088b7e54857626be97c47fdb9"><div class="ttname"><a href="group__API.html#gacba3a91088b7e54857626be97c47fdb9">HID_API_VERSION_STR</a></div><div class="ttdeci">#define HID_API_VERSION_STR</div><div class="ttdoc">Static/compile-time string version of the library.</div><div class="ttdef"><b>Definition</b> hidapi.h:95</div></div>
<div class="ttc" id="agroup__API_html_gacbceccb9fd443fd7cb164dee029fbf64"><div class="ttname"><a href="group__API.html#gacbceccb9fd443fd7cb164dee029fbf64">hid_version_str</a></div><div class="ttdeci">HID_API_EXPORT const char *HID_API_CALL hid_version_str(void)</div><div class="ttdoc">Get a runtime version string of the library.</div></div>
<div class="ttc" id="agroup__API_html_gacf5da9ce37132eba69fc259f17f13023"><div class="ttname"><a href="group__API.html#gacf5da9ce37132eba69fc259f17f13023">hid_exit</a></div><div class="ttdeci">int HID_API_EXPORT HID_API_CALL hid_exit(void)</div><div class="ttdoc">Finalize the HIDAPI library.</div></div>
<div class="ttc" id="agroup__API_html_gade33c6fcd36510e02004311124ea2093"><div class="ttname"><a href="group__API.html#gade33c6fcd36510e02004311124ea2093">HID_API_VERSION</a></div><div class="ttdeci">#define HID_API_VERSION</div><div class="ttdoc">Static/compile-time version of the library.</div><div class="ttdef"><b>Definition</b> hidapi.h:89</div></div>
<div class="ttc" id="agroup__API_html_gae99a9ddbb5d9b03fddf40fb4a492cbec"><div class="ttname"><a href="group__API.html#gae99a9ddbb5d9b03fddf40fb4a492cbec">hid_send_feature_report</a></div><div class="ttdeci">int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length)</div><div class="ttdoc">Send a Feature report to the device.</div></div>
<div class="ttc" id="agroup__API_html_gaea589e58403a465361a347c0754a3da2"><div class="ttname"><a href="group__API.html#gaea589e58403a465361a347c0754a3da2">hid_version</a></div><div class="ttdeci">HID_API_EXPORT const struct hid_api_version *HID_API_CALL hid_version(void)</div><div class="ttdoc">Get a runtime version of the library.</div></div>
<div class="ttc" id="agroup__API_html_gaf415391c655f68807580fe3fb8f7ba67"><div class="ttname"><a href="group__API.html#gaf415391c655f68807580fe3fb8f7ba67">HID_API_MAKE_VERSION</a></div><div class="ttdeci">#define HID_API_MAKE_VERSION(mj, mn, p)</div><div class="ttdoc">Coverts a version as Major/Minor/Patch into a number: &lt;8 bit major&gt;&lt;16 bit minor&gt;&lt;8 bit patch&gt;.</div><div class="ttdef"><b>Definition</b> hidapi.h:79</div></div>
<div class="ttc" id="agroup__API_html_gafc2d2adf71db3784b783b9a554527aa4"><div class="ttname"><a href="group__API.html#gafc2d2adf71db3784b783b9a554527aa4">hid_free_enumeration</a></div><div class="ttdeci">void HID_API_EXPORT HID_API_CALL hid_free_enumeration(struct hid_device_info *devs)</div><div class="ttdoc">Free an enumeration Linked List.</div></div>
<div class="ttc" id="agroup__API_html_gga15cb543842973ca41daa21feaec534ceacab9ef7570aa48c13a99b28c61ae918e"><div class="ttname"><a href="group__API.html#gga15cb543842973ca41daa21feaec534ceacab9ef7570aa48c13a99b28c61ae918e">HID_API_BUS_UNKNOWN</a></div><div class="ttdeci">@ HID_API_BUS_UNKNOWN</div><div class="ttdef"><b>Definition</b> hidapi.h:124</div></div>
<div class="ttc" id="ahidapi_8h_html"><div class="ttname"><a href="hidapi_8h.html">hidapi.h</a></div></div>
<div class="ttc" id="ahidapi_8h_html_aa6da74d5686d198dd3e5440e60088fcc"><div class="ttname"><a href="hidapi_8h.html#aa6da74d5686d198dd3e5440e60088fcc">hid_device</a></div><div class="ttdeci">struct hid_device_ hid_device</div><div class="ttdef"><b>Definition</b> hidapi.h:116</div></div>
<div class="ttc" id="astructhid__device__info_html"><div class="ttname"><a href="structhid__device__info.html">hid_device_info</a></div><div class="ttdef"><b>Definition</b> hidapi.h:150</div></div>
<div class="ttc" id="astructhid__device__info_html_a04595915457b4374492edb1fdb62d65d"><div class="ttname"><a href="structhid__device__info.html#a04595915457b4374492edb1fdb62d65d">hid_device_info::product_id</a></div><div class="ttdeci">unsigned short product_id</div><div class="ttdef"><b>Definition</b> hidapi.h:156</div></div>
<div class="ttc" id="astructhid__device__info_html_a2bfebc240baf3bdaf03965816e11f149"><div class="ttname"><a href="structhid__device__info.html#a2bfebc240baf3bdaf03965816e11f149">hid_device_info::next</a></div><div class="ttdeci">struct hid_device_info * next</div><div class="ttdef"><b>Definition</b> hidapi.h:181</div></div>
<div class="ttc" id="astructhid__device__info_html_a47f8011d58bcddd67f1403d6d3b4cab6"><div class="ttname"><a href="structhid__device__info.html#a47f8011d58bcddd67f1403d6d3b4cab6">hid_device_info::usage</a></div><div class="ttdeci">unsigned short usage</div><div class="ttdef"><b>Definition</b> hidapi.h:171</div></div>
<div class="ttc" id="astructhid__device__info_html_a484eebf746220cd2910954cc861759b7"><div class="ttname"><a href="structhid__device__info.html#a484eebf746220cd2910954cc861759b7">hid_device_info::manufacturer_string</a></div><div class="ttdeci">wchar_t * manufacturer_string</div><div class="ttdef"><b>Definition</b> hidapi.h:163</div></div>
<div class="ttc" id="astructhid__device__info_html_a5037a3914e0bd8a3f821d1be9376c709"><div class="ttname"><a href="structhid__device__info.html#a5037a3914e0bd8a3f821d1be9376c709">hid_device_info::vendor_id</a></div><div class="ttdeci">unsigned short vendor_id</div><div class="ttdef"><b>Definition</b> hidapi.h:154</div></div>
<div class="ttc" id="astructhid__device__info_html_a6384b5bf4d9583598e5f5a889f240921"><div class="ttname"><a href="structhid__device__info.html#a6384b5bf4d9583598e5f5a889f240921">hid_device_info::path</a></div><div class="ttdeci">char * path</div><div class="ttdef"><b>Definition</b> hidapi.h:152</div></div>
<div class="ttc" id="astructhid__device__info_html_a6a832d25260f7ec17ef008e53e50e1d0"><div class="ttname"><a href="structhid__device__info.html#a6a832d25260f7ec17ef008e53e50e1d0">hid_device_info::release_number</a></div><div class="ttdeci">unsigned short release_number</div><div class="ttdef"><b>Definition</b> hidapi.h:161</div></div>
<div class="ttc" id="astructhid__device__info_html_a80756cea367e1566f966438984b75faf"><div class="ttname"><a href="structhid__device__info.html#a80756cea367e1566f966438984b75faf">hid_device_info::serial_number</a></div><div class="ttdeci">wchar_t * serial_number</div><div class="ttdef"><b>Definition</b> hidapi.h:158</div></div>
<div class="ttc" id="astructhid__device__info_html_a9163d8d5d7db8dc47bddfaf876e17547"><div class="ttname"><a href="structhid__device__info.html#a9163d8d5d7db8dc47bddfaf876e17547">hid_device_info::interface_number</a></div><div class="ttdeci">int interface_number</div><div class="ttdef"><b>Definition</b> hidapi.h:178</div></div>
<div class="ttc" id="astructhid__device__info_html_ab811117f8084ce2036815bdd33b16b3b"><div class="ttname"><a href="structhid__device__info.html#ab811117f8084ce2036815bdd33b16b3b">hid_device_info::usage_page</a></div><div class="ttdeci">unsigned short usage_page</div><div class="ttdef"><b>Definition</b> hidapi.h:168</div></div>
<div class="ttc" id="astructhid__device__info_html_aceee256b4f7cd7fdd9fa5d556f49d221"><div class="ttname"><a href="structhid__device__info.html#aceee256b4f7cd7fdd9fa5d556f49d221">hid_device_info::product_string</a></div><div class="ttdeci">wchar_t * product_string</div><div class="ttdef"><b>Definition</b> hidapi.h:165</div></div>
<div class="ttc" id="astructhid__device__info_html_afa3c7d42a0892d9f1f25976709cf5aa2"><div class="ttname"><a href="structhid__device__info.html#afa3c7d42a0892d9f1f25976709cf5aa2">hid_device_info::bus_type</a></div><div class="ttdeci">hid_bus_type bus_type</div><div class="ttdef"><b>Definition</b> hidapi.h:186</div></div>
</div><!-- fragment --> </div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri May 23 2025 01:21:33 for hidapi by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>