1c0abf9e6Sopenharmony_ci<!-- HTML header for doxygen 1.8.8-->
2c0abf9e6Sopenharmony_ci<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3c0abf9e6Sopenharmony_ci<html xmlns="http://www.w3.org/1999/xhtml">
4c0abf9e6Sopenharmony_ci    <head>
5c0abf9e6Sopenharmony_ci        <meta http-equiv="X-UA-Compatible" content="IE=edge">
6c0abf9e6Sopenharmony_ci        <!-- For Mobile Devices -->
7c0abf9e6Sopenharmony_ci        <meta name="viewport" content="width=device-width, initial-scale=1">
8c0abf9e6Sopenharmony_ci        <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
9c0abf9e6Sopenharmony_ci        <meta name="generator" content="Doxygen 1.9.1"/>
10c0abf9e6Sopenharmony_ci        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
11c0abf9e6Sopenharmony_ci        <title>libevdev: Initialization and setup</title>
12c0abf9e6Sopenharmony_ci        <!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
13c0abf9e6Sopenharmony_ci        <script type="text/javascript" src="dynsections.js"></script>
14c0abf9e6Sopenharmony_ci        <link href="search/search.css" rel="stylesheet" type="text/css"/>
15c0abf9e6Sopenharmony_ci<script type="text/javascript" src="search/searchdata.js"></script>
16c0abf9e6Sopenharmony_ci<script type="text/javascript" src="search/search.js"></script>
17c0abf9e6Sopenharmony_ci        <link href="doxygen.css" rel="stylesheet" type="text/css" />
18c0abf9e6Sopenharmony_ci        <link href="bootstrap.css" rel="stylesheet" type="text/css"/>
19c0abf9e6Sopenharmony_ci<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
20c0abf9e6Sopenharmony_ci<link href="libevdevdoxygen.css" rel="stylesheet" type="text/css"/>
21c0abf9e6Sopenharmony_ci        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
22c0abf9e6Sopenharmony_ci        <script type="text/javascript" src="doxy-boot.js"></script>
23c0abf9e6Sopenharmony_ci    </head>
24c0abf9e6Sopenharmony_ci    <body>
25c0abf9e6Sopenharmony_ci        <nav class="navbar navbar-default" role="navigation">
26c0abf9e6Sopenharmony_ci            <div class="container">
27c0abf9e6Sopenharmony_ci                <div class="navbar-header">
28c0abf9e6Sopenharmony_ci                    <a class="navbar-brand">libevdev 1.13.0</a>
29c0abf9e6Sopenharmony_ci                </div>
30c0abf9e6Sopenharmony_ci            </div>
31c0abf9e6Sopenharmony_ci        </nav>
32c0abf9e6Sopenharmony_ci        <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
33c0abf9e6Sopenharmony_ci            <div class="content" id="content">
34c0abf9e6Sopenharmony_ci                <div class="container">
35c0abf9e6Sopenharmony_ci                    <div class="row">
36c0abf9e6Sopenharmony_ci                        <div class="col-sm-12 panel panel-default" style="padding-bottom: 15px;">
37c0abf9e6Sopenharmony_ci                            <div style="margin-bottom: 15px;">
38c0abf9e6Sopenharmony_ci<!-- end header part -->
39c0abf9e6Sopenharmony_ci<!-- Generated by Doxygen 1.9.1 -->
40c0abf9e6Sopenharmony_ci<script type="text/javascript">
41c0abf9e6Sopenharmony_ci/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
42c0abf9e6Sopenharmony_civar searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
43c0abf9e6Sopenharmony_ci/* @license-end */
44c0abf9e6Sopenharmony_ci</script>
45c0abf9e6Sopenharmony_ci<script type="text/javascript" src="menudata.js"></script>
46c0abf9e6Sopenharmony_ci<script type="text/javascript" src="menu.js"></script>
47c0abf9e6Sopenharmony_ci<script type="text/javascript">
48c0abf9e6Sopenharmony_ci/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
49c0abf9e6Sopenharmony_ci$(function() {
50c0abf9e6Sopenharmony_ci  initMenu('',true,false,'search.php','Search');
51c0abf9e6Sopenharmony_ci  $(document).ready(function() { init_search(); });
52c0abf9e6Sopenharmony_ci});
53c0abf9e6Sopenharmony_ci/* @license-end */</script>
54c0abf9e6Sopenharmony_ci<div id="main-nav"></div>
55c0abf9e6Sopenharmony_ci</div><!-- top -->
56c0abf9e6Sopenharmony_ci<!-- window showing the filter options -->
57c0abf9e6Sopenharmony_ci<div id="MSearchSelectWindow"
58c0abf9e6Sopenharmony_ci     onmouseover="return searchBox.OnSearchSelectShow()"
59c0abf9e6Sopenharmony_ci     onmouseout="return searchBox.OnSearchSelectHide()"
60c0abf9e6Sopenharmony_ci     onkeydown="return searchBox.OnSearchSelectKey(event)">
61c0abf9e6Sopenharmony_ci</div>
62c0abf9e6Sopenharmony_ci
63c0abf9e6Sopenharmony_ci<!-- iframe showing the search results (closed by default) -->
64c0abf9e6Sopenharmony_ci<div id="MSearchResultsWindow">
65c0abf9e6Sopenharmony_ci<iframe src="javascript:void(0)" frameborder="0" 
66c0abf9e6Sopenharmony_ci        name="MSearchResults" id="MSearchResults">
67c0abf9e6Sopenharmony_ci</iframe>
68c0abf9e6Sopenharmony_ci</div>
69c0abf9e6Sopenharmony_ci
70c0abf9e6Sopenharmony_ci<div class="header">
71c0abf9e6Sopenharmony_ci  <div class="summary">
72c0abf9e6Sopenharmony_ci<a href="#enum-members">Enumerations</a> &#124;
73c0abf9e6Sopenharmony_ci<a href="#func-members">Functions</a>  </div>
74c0abf9e6Sopenharmony_ci  <div class="headertitle">
75c0abf9e6Sopenharmony_ci<div class="title">Initialization and setup</div>  </div>
76c0abf9e6Sopenharmony_ci</div><!--header-->
77c0abf9e6Sopenharmony_ci<div class="contents">
78c0abf9e6Sopenharmony_ci
79c0abf9e6Sopenharmony_ci<p>Initialization, initial setup and file descriptor handling.  
80c0abf9e6Sopenharmony_ci<a href="#details">More...</a></p>
81c0abf9e6Sopenharmony_ci<table class="memberdecls">
82c0abf9e6Sopenharmony_ci<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
83c0abf9e6Sopenharmony_ciEnumerations</h2></td></tr>
84c0abf9e6Sopenharmony_ci<tr class="memitem:gaa282ec9badaa6bc11b1dc5bb124dbd5b"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__init.html#gaa282ec9badaa6bc11b1dc5bb124dbd5b">libevdev_grab_mode</a> { <a class="el" href="group__init.html#ggaa282ec9badaa6bc11b1dc5bb124dbd5bad3ac6f5f3ebf7d38a6aad74a88396c88">LIBEVDEV_GRAB</a>
85c0abf9e6Sopenharmony_ci, <a class="el" href="group__init.html#ggaa282ec9badaa6bc11b1dc5bb124dbd5ba6c0930d0c280753504cd05ebdcda09eb">LIBEVDEV_UNGRAB</a>
86c0abf9e6Sopenharmony_ci }</td></tr>
87c0abf9e6Sopenharmony_ci<tr class="separator:gaa282ec9badaa6bc11b1dc5bb124dbd5b"><td class="memSeparator" colspan="2">&#160;</td></tr>
88c0abf9e6Sopenharmony_ci</table><table class="memberdecls">
89c0abf9e6Sopenharmony_ci<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
90c0abf9e6Sopenharmony_ciFunctions</h2></td></tr>
91c0abf9e6Sopenharmony_ci<tr class="memitem:ga332c8ee260b4ef864345abe5d04e820c"><td class="memItemLeft" align="right" valign="top">struct libevdev *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c">libevdev_new</a> (void)</td></tr>
92c0abf9e6Sopenharmony_ci<tr class="memdesc:ga332c8ee260b4ef864345abe5d04e820c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize a new libevdev device.  <a href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c">More...</a><br /></td></tr>
93c0abf9e6Sopenharmony_ci<tr class="separator:ga332c8ee260b4ef864345abe5d04e820c"><td class="memSeparator" colspan="2">&#160;</td></tr>
94c0abf9e6Sopenharmony_ci<tr class="memitem:ga89bb5bce1c23e293293484b05b12aaf4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__init.html#ga89bb5bce1c23e293293484b05b12aaf4">libevdev_new_from_fd</a> (int fd, struct libevdev **dev)</td></tr>
95c0abf9e6Sopenharmony_ci<tr class="memdesc:ga89bb5bce1c23e293293484b05b12aaf4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize a new libevdev device from the given fd.  <a href="group__init.html#ga89bb5bce1c23e293293484b05b12aaf4">More...</a><br /></td></tr>
96c0abf9e6Sopenharmony_ci<tr class="separator:ga89bb5bce1c23e293293484b05b12aaf4"><td class="memSeparator" colspan="2">&#160;</td></tr>
97c0abf9e6Sopenharmony_ci<tr class="memitem:gacd9fe760d15be25fc99ce469034bd78c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c">libevdev_free</a> (struct libevdev *dev)</td></tr>
98c0abf9e6Sopenharmony_ci<tr class="memdesc:gacd9fe760d15be25fc99ce469034bd78c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Clean up and free the libevdev struct.  <a href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c">More...</a><br /></td></tr>
99c0abf9e6Sopenharmony_ci<tr class="separator:gacd9fe760d15be25fc99ce469034bd78c"><td class="memSeparator" colspan="2">&#160;</td></tr>
100c0abf9e6Sopenharmony_ci<tr class="memitem:ga5d434af74fee20f273db568e2cbbd13f"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__init.html#ga5d434af74fee20f273db568e2cbbd13f">libevdev_grab</a> (struct libevdev *dev, enum <a class="el" href="group__init.html#gaa282ec9badaa6bc11b1dc5bb124dbd5b">libevdev_grab_mode</a> grab)</td></tr>
101c0abf9e6Sopenharmony_ci<tr class="memdesc:ga5d434af74fee20f273db568e2cbbd13f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Grab or ungrab the device through a kernel EVIOCGRAB.  <a href="group__init.html#ga5d434af74fee20f273db568e2cbbd13f">More...</a><br /></td></tr>
102c0abf9e6Sopenharmony_ci<tr class="separator:ga5d434af74fee20f273db568e2cbbd13f"><td class="memSeparator" colspan="2">&#160;</td></tr>
103c0abf9e6Sopenharmony_ci<tr class="memitem:ga6658ac490d68c307ff8b8d1536c12b44"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44">libevdev_set_fd</a> (struct libevdev *dev, int fd)</td></tr>
104c0abf9e6Sopenharmony_ci<tr class="memdesc:ga6658ac490d68c307ff8b8d1536c12b44"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the fd for this struct and initialize internal data.  <a href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44">More...</a><br /></td></tr>
105c0abf9e6Sopenharmony_ci<tr class="separator:ga6658ac490d68c307ff8b8d1536c12b44"><td class="memSeparator" colspan="2">&#160;</td></tr>
106c0abf9e6Sopenharmony_ci<tr class="memitem:gac71c9cca4c572ed1b1a8c233be70a17c"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__init.html#gac71c9cca4c572ed1b1a8c233be70a17c">libevdev_change_fd</a> (struct libevdev *dev, int fd)</td></tr>
107c0abf9e6Sopenharmony_ci<tr class="memdesc:gac71c9cca4c572ed1b1a8c233be70a17c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Change the fd for this device, without re-reading the actual device.  <a href="group__init.html#gac71c9cca4c572ed1b1a8c233be70a17c">More...</a><br /></td></tr>
108c0abf9e6Sopenharmony_ci<tr class="separator:gac71c9cca4c572ed1b1a8c233be70a17c"><td class="memSeparator" colspan="2">&#160;</td></tr>
109c0abf9e6Sopenharmony_ci<tr class="memitem:gab9bfc800859ac3aa63f41d58ec4b616c"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__init.html#gab9bfc800859ac3aa63f41d58ec4b616c">libevdev_get_fd</a> (const struct libevdev *dev)</td></tr>
110c0abf9e6Sopenharmony_ci<tr class="separator:gab9bfc800859ac3aa63f41d58ec4b616c"><td class="memSeparator" colspan="2">&#160;</td></tr>
111c0abf9e6Sopenharmony_ci</table>
112c0abf9e6Sopenharmony_ci<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
113c0abf9e6Sopenharmony_ci<p>Initialization, initial setup and file descriptor handling. </p>
114c0abf9e6Sopenharmony_ci<p>These functions are the main entry points for users of libevdev, usually a caller will use this series of calls:</p>
115c0abf9e6Sopenharmony_ci<div class="fragment"><div class="line"><span class="keyword">struct </span>libevdev *dev;</div>
116c0abf9e6Sopenharmony_ci<div class="line"><span class="keywordtype">int</span> err;</div>
117c0abf9e6Sopenharmony_ci<div class="line"> </div>
118c0abf9e6Sopenharmony_ci<div class="line">dev = <a class="code" href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c">libevdev_new</a>();</div>
119c0abf9e6Sopenharmony_ci<div class="line"><span class="keywordflow">if</span> (!dev)</div>
120c0abf9e6Sopenharmony_ci<div class="line">        <span class="keywordflow">return</span> ENOMEM;</div>
121c0abf9e6Sopenharmony_ci<div class="line"> </div>
122c0abf9e6Sopenharmony_ci<div class="line">err = <a class="code" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44">libevdev_set_fd</a>(dev, fd);</div>
123c0abf9e6Sopenharmony_ci<div class="line"><span class="keywordflow">if</span> (err &lt; 0)</div>
124c0abf9e6Sopenharmony_ci<div class="line">        printf(<span class="stringliteral">&quot;Failed (errno %d): %s\n&quot;</span>, -err, strerror(-err));</div>
125c0abf9e6Sopenharmony_ci<div class="line"> </div>
126c0abf9e6Sopenharmony_ci<div class="line"><a class="code" href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c">libevdev_free</a>(dev);</div>
127c0abf9e6Sopenharmony_ci<div class="ttc" id="agroup__init_html_ga332c8ee260b4ef864345abe5d04e820c"><div class="ttname"><a href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c">libevdev_new</a></div><div class="ttdeci">struct libevdev * libevdev_new(void)</div><div class="ttdoc">Initialize a new libevdev device.</div></div>
128c0abf9e6Sopenharmony_ci<div class="ttc" id="agroup__init_html_ga6658ac490d68c307ff8b8d1536c12b44"><div class="ttname"><a href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44">libevdev_set_fd</a></div><div class="ttdeci">int libevdev_set_fd(struct libevdev *dev, int fd)</div><div class="ttdoc">Set the fd for this struct and initialize internal data.</div></div>
129c0abf9e6Sopenharmony_ci<div class="ttc" id="agroup__init_html_gacd9fe760d15be25fc99ce469034bd78c"><div class="ttname"><a href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c">libevdev_free</a></div><div class="ttdeci">void libevdev_free(struct libevdev *dev)</div><div class="ttdoc">Clean up and free the libevdev struct.</div></div>
130c0abf9e6Sopenharmony_ci</div><!-- fragment --><p><a class="el" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44" title="Set the fd for this struct and initialize internal data.">libevdev_set_fd()</a> is the central call and initializes the internal structs for the device at the given fd. libevdev functions will fail if called before <a class="el" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44" title="Set the fd for this struct and initialize internal data.">libevdev_set_fd()</a> unless documented otherwise. </p>
131c0abf9e6Sopenharmony_ci<h2 class="groupheader">Enumeration Type Documentation</h2>
132c0abf9e6Sopenharmony_ci<a id="gaa282ec9badaa6bc11b1dc5bb124dbd5b"></a>
133c0abf9e6Sopenharmony_ci<h2 class="memtitle"><span class="permalink"><a href="#gaa282ec9badaa6bc11b1dc5bb124dbd5b">&#9670;&nbsp;</a></span>libevdev_grab_mode</h2>
134c0abf9e6Sopenharmony_ci
135c0abf9e6Sopenharmony_ci<div class="memitem">
136c0abf9e6Sopenharmony_ci<div class="memproto">
137c0abf9e6Sopenharmony_ci      <table class="memname">
138c0abf9e6Sopenharmony_ci        <tr>
139c0abf9e6Sopenharmony_ci          <td class="memname">enum <a class="el" href="group__init.html#gaa282ec9badaa6bc11b1dc5bb124dbd5b">libevdev_grab_mode</a></td>
140c0abf9e6Sopenharmony_ci        </tr>
141c0abf9e6Sopenharmony_ci      </table>
142c0abf9e6Sopenharmony_ci</div><div class="memdoc">
143c0abf9e6Sopenharmony_ci<table class="fieldtable">
144c0abf9e6Sopenharmony_ci<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="ggaa282ec9badaa6bc11b1dc5bb124dbd5bad3ac6f5f3ebf7d38a6aad74a88396c88"></a>LIBEVDEV_GRAB&#160;</td><td class="fielddoc"><p>Grab the device if not currently grabbed. </p>
145c0abf9e6Sopenharmony_ci</td></tr>
146c0abf9e6Sopenharmony_ci<tr><td class="fieldname"><a id="ggaa282ec9badaa6bc11b1dc5bb124dbd5ba6c0930d0c280753504cd05ebdcda09eb"></a>LIBEVDEV_UNGRAB&#160;</td><td class="fielddoc"><p>Ungrab the device if currently grabbed. </p>
147c0abf9e6Sopenharmony_ci</td></tr>
148c0abf9e6Sopenharmony_ci</table>
149c0abf9e6Sopenharmony_ci
150c0abf9e6Sopenharmony_ci</div>
151c0abf9e6Sopenharmony_ci</div>
152c0abf9e6Sopenharmony_ci<h2 class="groupheader">Function Documentation</h2>
153c0abf9e6Sopenharmony_ci<a id="gac71c9cca4c572ed1b1a8c233be70a17c"></a>
154c0abf9e6Sopenharmony_ci<h2 class="memtitle"><span class="permalink"><a href="#gac71c9cca4c572ed1b1a8c233be70a17c">&#9670;&nbsp;</a></span>libevdev_change_fd()</h2>
155c0abf9e6Sopenharmony_ci
156c0abf9e6Sopenharmony_ci<div class="memitem">
157c0abf9e6Sopenharmony_ci<div class="memproto">
158c0abf9e6Sopenharmony_ci      <table class="memname">
159c0abf9e6Sopenharmony_ci        <tr>
160c0abf9e6Sopenharmony_ci          <td class="memname">int libevdev_change_fd </td>
161c0abf9e6Sopenharmony_ci          <td>(</td>
162c0abf9e6Sopenharmony_ci          <td class="paramtype">struct libevdev *&#160;</td>
163c0abf9e6Sopenharmony_ci          <td class="paramname"><em>dev</em>, </td>
164c0abf9e6Sopenharmony_ci        </tr>
165c0abf9e6Sopenharmony_ci        <tr>
166c0abf9e6Sopenharmony_ci          <td class="paramkey"></td>
167c0abf9e6Sopenharmony_ci          <td></td>
168c0abf9e6Sopenharmony_ci          <td class="paramtype">int&#160;</td>
169c0abf9e6Sopenharmony_ci          <td class="paramname"><em>fd</em>&#160;</td>
170c0abf9e6Sopenharmony_ci        </tr>
171c0abf9e6Sopenharmony_ci        <tr>
172c0abf9e6Sopenharmony_ci          <td></td>
173c0abf9e6Sopenharmony_ci          <td>)</td>
174c0abf9e6Sopenharmony_ci          <td></td><td></td>
175c0abf9e6Sopenharmony_ci        </tr>
176c0abf9e6Sopenharmony_ci      </table>
177c0abf9e6Sopenharmony_ci</div><div class="memdoc">
178c0abf9e6Sopenharmony_ci
179c0abf9e6Sopenharmony_ci<p>Change the fd for this device, without re-reading the actual device. </p>
180c0abf9e6Sopenharmony_ci<p>If the fd changes after initializing the device, for example after a VT-switch in the X.org X server, this function updates the internal fd to the newly opened. No check is made that new fd points to the same device. If the device has changed, libevdev's behavior is undefined.</p>
181c0abf9e6Sopenharmony_ci<p>libevdev does not sync itself after changing the fd and keeps the current device state. Use libevdev_next_event with the <a class="el" href="group__events.html#gga56c288d9f2e4c1632986c4e218c494e9a5198e5c9cc98b75f73f61b104d6a674c">LIBEVDEV_READ_FLAG_FORCE_SYNC</a> flag to force a re-sync.</p>
182c0abf9e6Sopenharmony_ci<p>The example code below illustrates how to force a re-sync of the library-internal state. Note that this code doesn't handle the events in the caller, it merely forces an update of the internal library state. </p><div class="fragment"><div class="line"><span class="keyword">struct </span>input_event ev;</div>
183c0abf9e6Sopenharmony_ci<div class="line"><a class="code" href="group__init.html#gac71c9cca4c572ed1b1a8c233be70a17c">libevdev_change_fd</a>(dev, new_fd);</div>
184c0abf9e6Sopenharmony_ci<div class="line"><a class="code" href="group__events.html#gabb96c864e836c0b98788f4ab771c3a76">libevdev_next_event</a>(dev, <a class="code" href="group__events.html#gga56c288d9f2e4c1632986c4e218c494e9a5198e5c9cc98b75f73f61b104d6a674c">LIBEVDEV_READ_FLAG_FORCE_SYNC</a>, &amp;ev);</div>
185c0abf9e6Sopenharmony_ci<div class="line"><span class="keywordflow">while</span> (<a class="code" href="group__events.html#gabb96c864e836c0b98788f4ab771c3a76">libevdev_next_event</a>(dev, <a class="code" href="group__events.html#gga56c288d9f2e4c1632986c4e218c494e9a1f13a19641d6dafcf01a86a6389800f8">LIBEVDEV_READ_FLAG_SYNC</a>, &amp;ev) == <a class="code" href="group__events.html#gga4a96221b3c7f54dfb86035d952154e3aa8d70b14a38204fde4ad433023baa545a">LIBEVDEV_READ_STATUS_SYNC</a>)</div>
186c0abf9e6Sopenharmony_ci<div class="line">                        ; <span class="comment">// noop</span></div>
187c0abf9e6Sopenharmony_ci<div class="ttc" id="agroup__events_html_gabb96c864e836c0b98788f4ab771c3a76"><div class="ttname"><a href="group__events.html#gabb96c864e836c0b98788f4ab771c3a76">libevdev_next_event</a></div><div class="ttdeci">int libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event *ev)</div><div class="ttdoc">Get the next event from the device.</div></div>
188c0abf9e6Sopenharmony_ci<div class="ttc" id="agroup__events_html_gga4a96221b3c7f54dfb86035d952154e3aa8d70b14a38204fde4ad433023baa545a"><div class="ttname"><a href="group__events.html#gga4a96221b3c7f54dfb86035d952154e3aa8d70b14a38204fde4ad433023baa545a">LIBEVDEV_READ_STATUS_SYNC</a></div><div class="ttdeci">@ LIBEVDEV_READ_STATUS_SYNC</div><div class="ttdoc">Depending on the libevdev_next_event() read flag:</div><div class="ttdef"><b>Definition:</b> libevdev.h:1090</div></div>
189c0abf9e6Sopenharmony_ci<div class="ttc" id="agroup__events_html_gga56c288d9f2e4c1632986c4e218c494e9a1f13a19641d6dafcf01a86a6389800f8"><div class="ttname"><a href="group__events.html#gga56c288d9f2e4c1632986c4e218c494e9a1f13a19641d6dafcf01a86a6389800f8">LIBEVDEV_READ_FLAG_SYNC</a></div><div class="ttdeci">@ LIBEVDEV_READ_FLAG_SYNC</div><div class="ttdoc">Process data in sync mode.</div><div class="ttdef"><b>Definition:</b> libevdev.h:761</div></div>
190c0abf9e6Sopenharmony_ci<div class="ttc" id="agroup__events_html_gga56c288d9f2e4c1632986c4e218c494e9a5198e5c9cc98b75f73f61b104d6a674c"><div class="ttname"><a href="group__events.html#gga56c288d9f2e4c1632986c4e218c494e9a5198e5c9cc98b75f73f61b104d6a674c">LIBEVDEV_READ_FLAG_FORCE_SYNC</a></div><div class="ttdeci">@ LIBEVDEV_READ_FLAG_FORCE_SYNC</div><div class="ttdoc">Pretend the next event is a SYN_DROPPED and require the caller to sync.</div><div class="ttdef"><b>Definition:</b> libevdev.h:763</div></div>
191c0abf9e6Sopenharmony_ci<div class="ttc" id="agroup__init_html_gac71c9cca4c572ed1b1a8c233be70a17c"><div class="ttname"><a href="group__init.html#gac71c9cca4c572ed1b1a8c233be70a17c">libevdev_change_fd</a></div><div class="ttdeci">int libevdev_change_fd(struct libevdev *dev, int fd)</div><div class="ttdoc">Change the fd for this device, without re-reading the actual device.</div></div>
192c0abf9e6Sopenharmony_ci</div><!-- fragment --><p>The fd may be open in O_RDONLY or O_RDWR.</p>
193c0abf9e6Sopenharmony_ci<p>After changing the fd, the device is assumed ungrabbed and a caller must call <a class="el" href="group__init.html#ga5d434af74fee20f273db568e2cbbd13f" title="Grab or ungrab the device through a kernel EVIOCGRAB.">libevdev_grab()</a> again.</p>
194c0abf9e6Sopenharmony_ci<p>It is an error to call this function before calling <a class="el" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44" title="Set the fd for this struct and initialize internal data.">libevdev_set_fd()</a>.</p>
195c0abf9e6Sopenharmony_ci<dl class="params"><dt>Parameters</dt><dd>
196c0abf9e6Sopenharmony_ci  <table class="params">
197c0abf9e6Sopenharmony_ci    <tr><td class="paramname">dev</td><td>The evdev device, already initialized with <a class="el" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44" title="Set the fd for this struct and initialize internal data.">libevdev_set_fd()</a> </td></tr>
198c0abf9e6Sopenharmony_ci    <tr><td class="paramname">fd</td><td>The new fd</td></tr>
199c0abf9e6Sopenharmony_ci  </table>
200c0abf9e6Sopenharmony_ci  </dd>
201c0abf9e6Sopenharmony_ci</dl>
202c0abf9e6Sopenharmony_ci<dl class="section return"><dt>Returns</dt><dd>0 on success, or -1 on failure.</dd></dl>
203c0abf9e6Sopenharmony_ci<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44" title="Set the fd for this struct and initialize internal data.">libevdev_set_fd</a> </dd></dl>
204c0abf9e6Sopenharmony_ci
205c0abf9e6Sopenharmony_ci</div>
206c0abf9e6Sopenharmony_ci</div>
207c0abf9e6Sopenharmony_ci<a id="gacd9fe760d15be25fc99ce469034bd78c"></a>
208c0abf9e6Sopenharmony_ci<h2 class="memtitle"><span class="permalink"><a href="#gacd9fe760d15be25fc99ce469034bd78c">&#9670;&nbsp;</a></span>libevdev_free()</h2>
209c0abf9e6Sopenharmony_ci
210c0abf9e6Sopenharmony_ci<div class="memitem">
211c0abf9e6Sopenharmony_ci<div class="memproto">
212c0abf9e6Sopenharmony_ci      <table class="memname">
213c0abf9e6Sopenharmony_ci        <tr>
214c0abf9e6Sopenharmony_ci          <td class="memname">void libevdev_free </td>
215c0abf9e6Sopenharmony_ci          <td>(</td>
216c0abf9e6Sopenharmony_ci          <td class="paramtype">struct libevdev *&#160;</td>
217c0abf9e6Sopenharmony_ci          <td class="paramname"><em>dev</em></td><td>)</td>
218c0abf9e6Sopenharmony_ci          <td></td>
219c0abf9e6Sopenharmony_ci        </tr>
220c0abf9e6Sopenharmony_ci      </table>
221c0abf9e6Sopenharmony_ci</div><div class="memdoc">
222c0abf9e6Sopenharmony_ci
223c0abf9e6Sopenharmony_ci<p>Clean up and free the libevdev struct. </p>
224c0abf9e6Sopenharmony_ci<p>After completion, the <code>struct libevdev</code> is invalid and must not be used.</p>
225c0abf9e6Sopenharmony_ci<p>Note that calling <a class="el" href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c" title="Clean up and free the libevdev struct.">libevdev_free()</a> does not close the file descriptor currently associated with this instance.</p>
226c0abf9e6Sopenharmony_ci<dl class="params"><dt>Parameters</dt><dd>
227c0abf9e6Sopenharmony_ci  <table class="params">
228c0abf9e6Sopenharmony_ci    <tr><td class="paramname">dev</td><td>The evdev device</td></tr>
229c0abf9e6Sopenharmony_ci  </table>
230c0abf9e6Sopenharmony_ci  </dd>
231c0abf9e6Sopenharmony_ci</dl>
232c0abf9e6Sopenharmony_ci<dl class="section note"><dt>Note</dt><dd>This function may be called before <a class="el" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44" title="Set the fd for this struct and initialize internal data.">libevdev_set_fd()</a>. </dd></dl>
233c0abf9e6Sopenharmony_ci
234c0abf9e6Sopenharmony_ci</div>
235c0abf9e6Sopenharmony_ci</div>
236c0abf9e6Sopenharmony_ci<a id="gab9bfc800859ac3aa63f41d58ec4b616c"></a>
237c0abf9e6Sopenharmony_ci<h2 class="memtitle"><span class="permalink"><a href="#gab9bfc800859ac3aa63f41d58ec4b616c">&#9670;&nbsp;</a></span>libevdev_get_fd()</h2>
238c0abf9e6Sopenharmony_ci
239c0abf9e6Sopenharmony_ci<div class="memitem">
240c0abf9e6Sopenharmony_ci<div class="memproto">
241c0abf9e6Sopenharmony_ci      <table class="memname">
242c0abf9e6Sopenharmony_ci        <tr>
243c0abf9e6Sopenharmony_ci          <td class="memname">int libevdev_get_fd </td>
244c0abf9e6Sopenharmony_ci          <td>(</td>
245c0abf9e6Sopenharmony_ci          <td class="paramtype">const struct libevdev *&#160;</td>
246c0abf9e6Sopenharmony_ci          <td class="paramname"><em>dev</em></td><td>)</td>
247c0abf9e6Sopenharmony_ci          <td></td>
248c0abf9e6Sopenharmony_ci        </tr>
249c0abf9e6Sopenharmony_ci      </table>
250c0abf9e6Sopenharmony_ci</div><div class="memdoc">
251c0abf9e6Sopenharmony_ci<dl class="params"><dt>Parameters</dt><dd>
252c0abf9e6Sopenharmony_ci  <table class="params">
253c0abf9e6Sopenharmony_ci    <tr><td class="paramname">dev</td><td>The evdev device</td></tr>
254c0abf9e6Sopenharmony_ci  </table>
255c0abf9e6Sopenharmony_ci  </dd>
256c0abf9e6Sopenharmony_ci</dl>
257c0abf9e6Sopenharmony_ci<dl class="section return"><dt>Returns</dt><dd>The previously set fd, or -1 if none had been set previously. </dd></dl>
258c0abf9e6Sopenharmony_ci<dl class="section note"><dt>Note</dt><dd>This function may be called before <a class="el" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44" title="Set the fd for this struct and initialize internal data.">libevdev_set_fd()</a>. </dd></dl>
259c0abf9e6Sopenharmony_ci
260c0abf9e6Sopenharmony_ci</div>
261c0abf9e6Sopenharmony_ci</div>
262c0abf9e6Sopenharmony_ci<a id="ga5d434af74fee20f273db568e2cbbd13f"></a>
263c0abf9e6Sopenharmony_ci<h2 class="memtitle"><span class="permalink"><a href="#ga5d434af74fee20f273db568e2cbbd13f">&#9670;&nbsp;</a></span>libevdev_grab()</h2>
264c0abf9e6Sopenharmony_ci
265c0abf9e6Sopenharmony_ci<div class="memitem">
266c0abf9e6Sopenharmony_ci<div class="memproto">
267c0abf9e6Sopenharmony_ci      <table class="memname">
268c0abf9e6Sopenharmony_ci        <tr>
269c0abf9e6Sopenharmony_ci          <td class="memname">int libevdev_grab </td>
270c0abf9e6Sopenharmony_ci          <td>(</td>
271c0abf9e6Sopenharmony_ci          <td class="paramtype">struct libevdev *&#160;</td>
272c0abf9e6Sopenharmony_ci          <td class="paramname"><em>dev</em>, </td>
273c0abf9e6Sopenharmony_ci        </tr>
274c0abf9e6Sopenharmony_ci        <tr>
275c0abf9e6Sopenharmony_ci          <td class="paramkey"></td>
276c0abf9e6Sopenharmony_ci          <td></td>
277c0abf9e6Sopenharmony_ci          <td class="paramtype">enum <a class="el" href="group__init.html#gaa282ec9badaa6bc11b1dc5bb124dbd5b">libevdev_grab_mode</a>&#160;</td>
278c0abf9e6Sopenharmony_ci          <td class="paramname"><em>grab</em>&#160;</td>
279c0abf9e6Sopenharmony_ci        </tr>
280c0abf9e6Sopenharmony_ci        <tr>
281c0abf9e6Sopenharmony_ci          <td></td>
282c0abf9e6Sopenharmony_ci          <td>)</td>
283c0abf9e6Sopenharmony_ci          <td></td><td></td>
284c0abf9e6Sopenharmony_ci        </tr>
285c0abf9e6Sopenharmony_ci      </table>
286c0abf9e6Sopenharmony_ci</div><div class="memdoc">
287c0abf9e6Sopenharmony_ci
288c0abf9e6Sopenharmony_ci<p>Grab or ungrab the device through a kernel EVIOCGRAB. </p>
289c0abf9e6Sopenharmony_ci<p>This prevents other clients (including kernel-internal ones such as rfkill) from receiving events from this device.</p>
290c0abf9e6Sopenharmony_ci<p>This is generally a bad idea. Don't do this.</p>
291c0abf9e6Sopenharmony_ci<p>Grabbing an already grabbed device, or ungrabbing an ungrabbed device is a noop and always succeeds.</p>
292c0abf9e6Sopenharmony_ci<p>A grab is an operation tied to a file descriptor, not a device. If a client changes the file descriptor with <a class="el" href="group__init.html#gac71c9cca4c572ed1b1a8c233be70a17c" title="Change the fd for this device, without re-reading the actual device.">libevdev_change_fd()</a>, it must also re-issue a grab with <a class="el" href="group__init.html#ga5d434af74fee20f273db568e2cbbd13f" title="Grab or ungrab the device through a kernel EVIOCGRAB.">libevdev_grab()</a>.</p>
293c0abf9e6Sopenharmony_ci<dl class="params"><dt>Parameters</dt><dd>
294c0abf9e6Sopenharmony_ci  <table class="params">
295c0abf9e6Sopenharmony_ci    <tr><td class="paramname">dev</td><td>The evdev device, already initialized with <a class="el" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44" title="Set the fd for this struct and initialize internal data.">libevdev_set_fd()</a> </td></tr>
296c0abf9e6Sopenharmony_ci    <tr><td class="paramname">grab</td><td>If true, grab the device. Otherwise ungrab the device.</td></tr>
297c0abf9e6Sopenharmony_ci  </table>
298c0abf9e6Sopenharmony_ci  </dd>
299c0abf9e6Sopenharmony_ci</dl>
300c0abf9e6Sopenharmony_ci<dl class="section return"><dt>Returns</dt><dd>0 if the device was successfully grabbed or ungrabbed, or a negative errno in case of failure. </dd></dl>
301c0abf9e6Sopenharmony_ci
302c0abf9e6Sopenharmony_ci</div>
303c0abf9e6Sopenharmony_ci</div>
304c0abf9e6Sopenharmony_ci<a id="ga332c8ee260b4ef864345abe5d04e820c"></a>
305c0abf9e6Sopenharmony_ci<h2 class="memtitle"><span class="permalink"><a href="#ga332c8ee260b4ef864345abe5d04e820c">&#9670;&nbsp;</a></span>libevdev_new()</h2>
306c0abf9e6Sopenharmony_ci
307c0abf9e6Sopenharmony_ci<div class="memitem">
308c0abf9e6Sopenharmony_ci<div class="memproto">
309c0abf9e6Sopenharmony_ci      <table class="memname">
310c0abf9e6Sopenharmony_ci        <tr>
311c0abf9e6Sopenharmony_ci          <td class="memname">struct libevdev* libevdev_new </td>
312c0abf9e6Sopenharmony_ci          <td>(</td>
313c0abf9e6Sopenharmony_ci          <td class="paramtype">void&#160;</td>
314c0abf9e6Sopenharmony_ci          <td class="paramname"></td><td>)</td>
315c0abf9e6Sopenharmony_ci          <td></td>
316c0abf9e6Sopenharmony_ci        </tr>
317c0abf9e6Sopenharmony_ci      </table>
318c0abf9e6Sopenharmony_ci</div><div class="memdoc">
319c0abf9e6Sopenharmony_ci
320c0abf9e6Sopenharmony_ci<p>Initialize a new libevdev device. </p>
321c0abf9e6Sopenharmony_ci<p>This function only allocates the required memory and initializes the struct to sane default values. To actually hook up the device to a kernel device, use <a class="el" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44" title="Set the fd for this struct and initialize internal data.">libevdev_set_fd()</a>.</p>
322c0abf9e6Sopenharmony_ci<p>Memory allocated through <a class="el" href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c" title="Initialize a new libevdev device.">libevdev_new()</a> must be released by the caller with <a class="el" href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c" title="Clean up and free the libevdev struct.">libevdev_free()</a>.</p>
323c0abf9e6Sopenharmony_ci<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44" title="Set the fd for this struct and initialize internal data.">libevdev_set_fd</a> </dd>
324c0abf9e6Sopenharmony_ci<dd>
325c0abf9e6Sopenharmony_ci<a class="el" href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c" title="Clean up and free the libevdev struct.">libevdev_free</a> </dd></dl>
326c0abf9e6Sopenharmony_ci
327c0abf9e6Sopenharmony_ci</div>
328c0abf9e6Sopenharmony_ci</div>
329c0abf9e6Sopenharmony_ci<a id="ga89bb5bce1c23e293293484b05b12aaf4"></a>
330c0abf9e6Sopenharmony_ci<h2 class="memtitle"><span class="permalink"><a href="#ga89bb5bce1c23e293293484b05b12aaf4">&#9670;&nbsp;</a></span>libevdev_new_from_fd()</h2>
331c0abf9e6Sopenharmony_ci
332c0abf9e6Sopenharmony_ci<div class="memitem">
333c0abf9e6Sopenharmony_ci<div class="memproto">
334c0abf9e6Sopenharmony_ci      <table class="memname">
335c0abf9e6Sopenharmony_ci        <tr>
336c0abf9e6Sopenharmony_ci          <td class="memname">int libevdev_new_from_fd </td>
337c0abf9e6Sopenharmony_ci          <td>(</td>
338c0abf9e6Sopenharmony_ci          <td class="paramtype">int&#160;</td>
339c0abf9e6Sopenharmony_ci          <td class="paramname"><em>fd</em>, </td>
340c0abf9e6Sopenharmony_ci        </tr>
341c0abf9e6Sopenharmony_ci        <tr>
342c0abf9e6Sopenharmony_ci          <td class="paramkey"></td>
343c0abf9e6Sopenharmony_ci          <td></td>
344c0abf9e6Sopenharmony_ci          <td class="paramtype">struct libevdev **&#160;</td>
345c0abf9e6Sopenharmony_ci          <td class="paramname"><em>dev</em>&#160;</td>
346c0abf9e6Sopenharmony_ci        </tr>
347c0abf9e6Sopenharmony_ci        <tr>
348c0abf9e6Sopenharmony_ci          <td></td>
349c0abf9e6Sopenharmony_ci          <td>)</td>
350c0abf9e6Sopenharmony_ci          <td></td><td></td>
351c0abf9e6Sopenharmony_ci        </tr>
352c0abf9e6Sopenharmony_ci      </table>
353c0abf9e6Sopenharmony_ci</div><div class="memdoc">
354c0abf9e6Sopenharmony_ci
355c0abf9e6Sopenharmony_ci<p>Initialize a new libevdev device from the given fd. </p>
356c0abf9e6Sopenharmony_ci<p>This is a shortcut for</p>
357c0abf9e6Sopenharmony_ci<div class="fragment"><div class="line"><span class="keywordtype">int</span> err;</div>
358c0abf9e6Sopenharmony_ci<div class="line"><span class="keyword">struct </span>libevdev *dev = <a class="code" href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c">libevdev_new</a>();</div>
359c0abf9e6Sopenharmony_ci<div class="line">err = <a class="code" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44">libevdev_set_fd</a>(dev, fd);</div>
360c0abf9e6Sopenharmony_ci</div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
361c0abf9e6Sopenharmony_ci  <table class="params">
362c0abf9e6Sopenharmony_ci    <tr><td class="paramdir"></td><td class="paramname">fd</td><td>A file descriptor to the device in O_RDWR or O_RDONLY mode. </td></tr>
363c0abf9e6Sopenharmony_ci    <tr><td class="paramdir">[out]</td><td class="paramname">dev</td><td>The newly initialized evdev device.</td></tr>
364c0abf9e6Sopenharmony_ci  </table>
365c0abf9e6Sopenharmony_ci  </dd>
366c0abf9e6Sopenharmony_ci</dl>
367c0abf9e6Sopenharmony_ci<dl class="section return"><dt>Returns</dt><dd>On success, 0 is returned and dev is set to the newly allocated struct. On failure, a negative errno is returned and the value of dev is undefined.</dd></dl>
368c0abf9e6Sopenharmony_ci<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c" title="Clean up and free the libevdev struct.">libevdev_free</a> </dd></dl>
369c0abf9e6Sopenharmony_ci
370c0abf9e6Sopenharmony_ci</div>
371c0abf9e6Sopenharmony_ci</div>
372c0abf9e6Sopenharmony_ci<a id="ga6658ac490d68c307ff8b8d1536c12b44"></a>
373c0abf9e6Sopenharmony_ci<h2 class="memtitle"><span class="permalink"><a href="#ga6658ac490d68c307ff8b8d1536c12b44">&#9670;&nbsp;</a></span>libevdev_set_fd()</h2>
374c0abf9e6Sopenharmony_ci
375c0abf9e6Sopenharmony_ci<div class="memitem">
376c0abf9e6Sopenharmony_ci<div class="memproto">
377c0abf9e6Sopenharmony_ci      <table class="memname">
378c0abf9e6Sopenharmony_ci        <tr>
379c0abf9e6Sopenharmony_ci          <td class="memname">int libevdev_set_fd </td>
380c0abf9e6Sopenharmony_ci          <td>(</td>
381c0abf9e6Sopenharmony_ci          <td class="paramtype">struct libevdev *&#160;</td>
382c0abf9e6Sopenharmony_ci          <td class="paramname"><em>dev</em>, </td>
383c0abf9e6Sopenharmony_ci        </tr>
384c0abf9e6Sopenharmony_ci        <tr>
385c0abf9e6Sopenharmony_ci          <td class="paramkey"></td>
386c0abf9e6Sopenharmony_ci          <td></td>
387c0abf9e6Sopenharmony_ci          <td class="paramtype">int&#160;</td>
388c0abf9e6Sopenharmony_ci          <td class="paramname"><em>fd</em>&#160;</td>
389c0abf9e6Sopenharmony_ci        </tr>
390c0abf9e6Sopenharmony_ci        <tr>
391c0abf9e6Sopenharmony_ci          <td></td>
392c0abf9e6Sopenharmony_ci          <td>)</td>
393c0abf9e6Sopenharmony_ci          <td></td><td></td>
394c0abf9e6Sopenharmony_ci        </tr>
395c0abf9e6Sopenharmony_ci      </table>
396c0abf9e6Sopenharmony_ci</div><div class="memdoc">
397c0abf9e6Sopenharmony_ci
398c0abf9e6Sopenharmony_ci<p>Set the fd for this struct and initialize internal data. </p>
399c0abf9e6Sopenharmony_ci<p>The fd must be in O_RDONLY or O_RDWR mode.</p>
400c0abf9e6Sopenharmony_ci<p>This function may only be called once per device. If the device changed and you need to re-read a device, use <a class="el" href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c" title="Clean up and free the libevdev struct.">libevdev_free()</a> and <a class="el" href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c" title="Initialize a new libevdev device.">libevdev_new()</a>. If you need to change the fd after closing and re-opening the same device, use <a class="el" href="group__init.html#gac71c9cca4c572ed1b1a8c233be70a17c" title="Change the fd for this device, without re-reading the actual device.">libevdev_change_fd()</a>.</p>
401c0abf9e6Sopenharmony_ci<p>A caller should ensure that any events currently pending on the fd are drained before the file descriptor is passed to libevdev for initialization. Due to how the kernel's ioctl handling works, the initial device state will reflect the current device state <em>after</em> applying all events currently pending on the fd. Thus, if the fd is not drained, the state visible to the caller will be inconsistent with the events immediately available on the device. This does not affect state-less events like EV_REL.</p>
402c0abf9e6Sopenharmony_ci<p>Unless otherwise specified, libevdev function behavior is undefined until a successful call to <a class="el" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44" title="Set the fd for this struct and initialize internal data.">libevdev_set_fd()</a>.</p>
403c0abf9e6Sopenharmony_ci<dl class="params"><dt>Parameters</dt><dd>
404c0abf9e6Sopenharmony_ci  <table class="params">
405c0abf9e6Sopenharmony_ci    <tr><td class="paramname">dev</td><td>The evdev device </td></tr>
406c0abf9e6Sopenharmony_ci    <tr><td class="paramname">fd</td><td>The file descriptor for the device</td></tr>
407c0abf9e6Sopenharmony_ci  </table>
408c0abf9e6Sopenharmony_ci  </dd>
409c0abf9e6Sopenharmony_ci</dl>
410c0abf9e6Sopenharmony_ci<dl class="section return"><dt>Returns</dt><dd>0 on success, or a negative errno on failure</dd></dl>
411c0abf9e6Sopenharmony_ci<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__init.html#gac71c9cca4c572ed1b1a8c233be70a17c" title="Change the fd for this device, without re-reading the actual device.">libevdev_change_fd</a> </dd>
412c0abf9e6Sopenharmony_ci<dd>
413c0abf9e6Sopenharmony_ci<a class="el" href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c" title="Initialize a new libevdev device.">libevdev_new</a> </dd>
414c0abf9e6Sopenharmony_ci<dd>
415c0abf9e6Sopenharmony_ci<a class="el" href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c" title="Clean up and free the libevdev struct.">libevdev_free</a> </dd></dl>
416c0abf9e6Sopenharmony_ci
417c0abf9e6Sopenharmony_ci</div>
418c0abf9e6Sopenharmony_ci</div>
419c0abf9e6Sopenharmony_ci</div><!-- contents -->
420c0abf9e6Sopenharmony_ci<!-- HTML footer for doxygen 1.8.8-->
421c0abf9e6Sopenharmony_ci<!-- start footer part -->
422c0abf9e6Sopenharmony_ci</div>
423c0abf9e6Sopenharmony_ci</div>
424c0abf9e6Sopenharmony_ci</div>
425c0abf9e6Sopenharmony_ci</div>
426c0abf9e6Sopenharmony_ci</div>
427c0abf9e6Sopenharmony_ci<hr class="footer"/><address class="footer"><small>
428c0abf9e6Sopenharmony_ciGenerated by &#160;<a href="http://www.doxygen.org/index.html">
429c0abf9e6Sopenharmony_ci<img class="footer" src="doxygen.png" alt="doxygen"/>
430c0abf9e6Sopenharmony_ci</a> 1.9.1
431c0abf9e6Sopenharmony_ci</small></address>
432c0abf9e6Sopenharmony_ci</body>
433c0abf9e6Sopenharmony_ci</html>
434