/usr/share/doc/libevdev-dev/html/group__init.html is in libevdev-doc 1.5.8+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libevdev: Initialization and setup</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" />
<link href="libevdev.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 style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">libevdev
 <span id="projectnumber">1.5.8</span>
</div>
<div id="projectbrief">A wrapper library for evdev devices</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</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">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#enum-members">Enumerations</a> |
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">Initialization and setup</div> </div>
</div><!--header-->
<div class="contents">
<p>Initialization, initial setup and file descriptor handling.
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:gaa282ec9badaa6bc11b1dc5bb124dbd5b"><td class="memItemLeft" align="right" valign="top">enum  </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>,
<a class="el" href="group__init.html#ggaa282ec9badaa6bc11b1dc5bb124dbd5ba6c0930d0c280753504cd05ebdcda09eb">LIBEVDEV_UNGRAB</a>
}</td></tr>
<tr class="separator:gaa282ec9badaa6bc11b1dc5bb124dbd5b"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga332c8ee260b4ef864345abe5d04e820c"><td class="memItemLeft" align="right" valign="top">struct libevdev * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c">libevdev_new</a> (void)</td></tr>
<tr class="memdesc:ga332c8ee260b4ef864345abe5d04e820c"><td class="mdescLeft"> </td><td class="mdescRight">Initialize a new libevdev device. <a href="#ga332c8ee260b4ef864345abe5d04e820c">More...</a><br /></td></tr>
<tr class="separator:ga332c8ee260b4ef864345abe5d04e820c"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga89bb5bce1c23e293293484b05b12aaf4"><td class="memItemLeft" align="right" valign="top">int </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>
<tr class="memdesc:ga89bb5bce1c23e293293484b05b12aaf4"><td class="mdescLeft"> </td><td class="mdescRight">Initialize a new libevdev device from the given fd. <a href="#ga89bb5bce1c23e293293484b05b12aaf4">More...</a><br /></td></tr>
<tr class="separator:ga89bb5bce1c23e293293484b05b12aaf4"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gacd9fe760d15be25fc99ce469034bd78c"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c">libevdev_free</a> (struct libevdev *dev)</td></tr>
<tr class="memdesc:gacd9fe760d15be25fc99ce469034bd78c"><td class="mdescLeft"> </td><td class="mdescRight">Clean up and free the libevdev struct. <a href="#gacd9fe760d15be25fc99ce469034bd78c">More...</a><br /></td></tr>
<tr class="separator:gacd9fe760d15be25fc99ce469034bd78c"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga5d434af74fee20f273db568e2cbbd13f"><td class="memItemLeft" align="right" valign="top">int </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>
<tr class="memdesc:ga5d434af74fee20f273db568e2cbbd13f"><td class="mdescLeft"> </td><td class="mdescRight">Grab or ungrab the device through a kernel EVIOCGRAB. <a href="#ga5d434af74fee20f273db568e2cbbd13f">More...</a><br /></td></tr>
<tr class="separator:ga5d434af74fee20f273db568e2cbbd13f"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga6658ac490d68c307ff8b8d1536c12b44"><td class="memItemLeft" align="right" valign="top">int </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>
<tr class="memdesc:ga6658ac490d68c307ff8b8d1536c12b44"><td class="mdescLeft"> </td><td class="mdescRight">Set the fd for this struct and initialize internal data. <a href="#ga6658ac490d68c307ff8b8d1536c12b44">More...</a><br /></td></tr>
<tr class="separator:ga6658ac490d68c307ff8b8d1536c12b44"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gac71c9cca4c572ed1b1a8c233be70a17c"><td class="memItemLeft" align="right" valign="top">int </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>
<tr class="memdesc:gac71c9cca4c572ed1b1a8c233be70a17c"><td class="mdescLeft"> </td><td class="mdescRight">Change the fd for this device, without re-reading the actual device. <a href="#gac71c9cca4c572ed1b1a8c233be70a17c">More...</a><br /></td></tr>
<tr class="separator:gac71c9cca4c572ed1b1a8c233be70a17c"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gab9bfc800859ac3aa63f41d58ec4b616c"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__init.html#gab9bfc800859ac3aa63f41d58ec4b616c">libevdev_get_fd</a> (const struct libevdev *dev)</td></tr>
<tr class="separator:gab9bfc800859ac3aa63f41d58ec4b616c"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Initialization, initial setup and file descriptor handling. </p>
<p>These functions are the main entry points for users of libevdev, usually a caller will use this series of calls:</p>
<div class="fragment"><div class="line"><span class="keyword">struct </span>libevdev *dev;</div><div class="line"><span class="keywordtype">int</span> err;</div><div class="line"></div><div class="line">dev = <a class="code" href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c">libevdev_new</a>();</div><div class="line"><span class="keywordflow">if</span> (!dev)</div><div class="line"> <span class="keywordflow">return</span> ENOMEM;</div><div class="line"></div><div class="line">err = <a class="code" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44">libevdev_set_fd</a>(dev, fd);</div><div class="line"><span class="keywordflow">if</span> (err < 0) {</div><div class="line"> printf(<span class="stringliteral">"Failed (errno %d): %s\n"</span>, -err, strerror(-err));</div><div class="line"></div><div class="line"><a class="code" href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c">libevdev_free</a>(dev);</div></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>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a id="gaa282ec9badaa6bc11b1dc5bb124dbd5b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa282ec9badaa6bc11b1dc5bb124dbd5b">◆ </a></span>libevdev_grab_mode</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">enum <a class="el" href="group__init.html#gaa282ec9badaa6bc11b1dc5bb124dbd5b">libevdev_grab_mode</a></td>
</tr>
</table>
</div><div class="memdoc">
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="ggaa282ec9badaa6bc11b1dc5bb124dbd5bad3ac6f5f3ebf7d38a6aad74a88396c88"></a>LIBEVDEV_GRAB </td><td class="fielddoc"><p>Grab the device if not currently grabbed. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggaa282ec9badaa6bc11b1dc5bb124dbd5ba6c0930d0c280753504cd05ebdcda09eb"></a>LIBEVDEV_UNGRAB </td><td class="fielddoc"><p>Ungrab the device if currently grabbed. </p>
</td></tr>
</table>
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="gac71c9cca4c572ed1b1a8c233be70a17c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac71c9cca4c572ed1b1a8c233be70a17c">◆ </a></span>libevdev_change_fd()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int libevdev_change_fd </td>
<td>(</td>
<td class="paramtype">struct libevdev * </td>
<td class="paramname"><em>dev</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>fd</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Change the fd for this device, without re-reading the actual device. </p>
<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>
<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>
<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><div class="line"><a class="code" href="group__init.html#gac71c9cca4c572ed1b1a8c233be70a17c">libevdev_change_fd</a>(dev, new_fd);</div><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>, &ev);</div><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>, &ev) == <a class="code" href="group__events.html#gga4a96221b3c7f54dfb86035d952154e3aa8d70b14a38204fde4ad433023baa545a">LIBEVDEV_READ_STATUS_SYNC</a>)</div><div class="line"> ; <span class="comment">// noop</span></div></div><!-- fragment --><p>The fd may be open in O_RDONLY or O_RDWR.</p>
<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>
<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>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<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>
<tr><td class="paramname">fd</td><td>The new fd</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 on success, or -1 on failure.</dd></dl>
<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>
</div>
</div>
<a id="gacd9fe760d15be25fc99ce469034bd78c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacd9fe760d15be25fc99ce469034bd78c">◆ </a></span>libevdev_free()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void libevdev_free </td>
<td>(</td>
<td class="paramtype">struct libevdev * </td>
<td class="paramname"><em>dev</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Clean up and free the libevdev struct. </p>
<p>After completion, the <code>struct libevdev</code> is invalid and must not be used.</p>
<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 asssociated with this instance.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">dev</td><td>The evdev device</td></tr>
</table>
</dd>
</dl>
<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>
</div>
</div>
<a id="gab9bfc800859ac3aa63f41d58ec4b616c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab9bfc800859ac3aa63f41d58ec4b616c">◆ </a></span>libevdev_get_fd()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int libevdev_get_fd </td>
<td>(</td>
<td class="paramtype">const struct libevdev * </td>
<td class="paramname"><em>dev</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">dev</td><td>The evdev device</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The previously set fd, or -1 if none had been set previously. </dd></dl>
<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>
</div>
</div>
<a id="ga5d434af74fee20f273db568e2cbbd13f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5d434af74fee20f273db568e2cbbd13f">◆ </a></span>libevdev_grab()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int libevdev_grab </td>
<td>(</td>
<td class="paramtype">struct libevdev * </td>
<td class="paramname"><em>dev</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">enum <a class="el" href="group__init.html#gaa282ec9badaa6bc11b1dc5bb124dbd5b">libevdev_grab_mode</a> </td>
<td class="paramname"><em>grab</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Grab or ungrab the device through a kernel EVIOCGRAB. </p>
<p>This prevents other clients (including kernel-internal ones such as rfkill) from receiving events from this device.</p>
<p>This is generally a bad idea. Don't do this.</p>
<p>Grabbing an already grabbed device, or ungrabbing an ungrabbed device is a noop and always succeeds.</p>
<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>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<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>
<tr><td class="paramname">grab</td><td>If true, grab the device. Otherwise ungrab the device.</td></tr>
</table>
</dd>
</dl>
<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>
</div>
</div>
<a id="ga332c8ee260b4ef864345abe5d04e820c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga332c8ee260b4ef864345abe5d04e820c">◆ </a></span>libevdev_new()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct libevdev* libevdev_new </td>
<td>(</td>
<td class="paramtype">void </td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initialize a new libevdev device. </p>
<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>
<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>
<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>
<dd>
<a class="el" href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c" title="Clean up and free the libevdev struct. ">libevdev_free</a> </dd></dl>
</div>
</div>
<a id="ga89bb5bce1c23e293293484b05b12aaf4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga89bb5bce1c23e293293484b05b12aaf4">◆ </a></span>libevdev_new_from_fd()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int libevdev_new_from_fd </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"><em>fd</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct libevdev ** </td>
<td class="paramname"><em>dev</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initialize a new libevdev device from the given fd. </p>
<p>This is a shortcut for</p>
<div class="fragment"><div class="line"><span class="keywordtype">int</span> err;</div><div class="line"><span class="keyword">struct </span>libevdev *dev = <a class="code" href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c">libevdev_new</a>();</div><div class="line">err = <a class="code" href="group__init.html#ga6658ac490d68c307ff8b8d1536c12b44">libevdev_set_fd</a>(dev, fd);</div></div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<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>
<tr><td class="paramdir">[out]</td><td class="paramname">dev</td><td>The newly initialized evdev device.</td></tr>
</table>
</dd>
</dl>
<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>
<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>
</div>
</div>
<a id="ga6658ac490d68c307ff8b8d1536c12b44"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga6658ac490d68c307ff8b8d1536c12b44">◆ </a></span>libevdev_set_fd()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int libevdev_set_fd </td>
<td>(</td>
<td class="paramtype">struct libevdev * </td>
<td class="paramname"><em>dev</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>fd</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Set the fd for this struct and initialize internal data. </p>
<p>The fd must be in O_RDONLY or O_RDWR mode.</p>
<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>
<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>
<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>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">dev</td><td>The evdev device </td></tr>
<tr><td class="paramname">fd</td><td>The file descriptor for the device</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 on success, or a negative errno on failure</dd></dl>
<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>
<dd>
<a class="el" href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c" title="Initialize a new libevdev device. ">libevdev_new</a> </dd>
<dd>
<a class="el" href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c" title="Clean up and free the libevdev struct. ">libevdev_free</a> </dd></dl>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
|