• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!-- HTML header for doxygen 1.8.8-->
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4    <head>
5        <meta http-equiv="X-UA-Compatible" content="IE=edge">
6        <!-- For Mobile Devices -->
7        <meta name="viewport" content="width=device-width, initial-scale=1">
8        <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
9        <meta name="generator" content="Doxygen 1.9.1"/>
10        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
11        <title>libevdev: uinput device creation</title>
12        <!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
13        <script type="text/javascript" src="dynsections.js"></script>
14        <link href="search/search.css" rel="stylesheet" type="text/css"/>
15<script type="text/javascript" src="search/searchdata.js"></script>
16<script type="text/javascript" src="search/search.js"></script>
17        <link href="doxygen.css" rel="stylesheet" type="text/css" />
18        <link href="bootstrap.css" rel="stylesheet" type="text/css"/>
19<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
20<link href="libevdevdoxygen.css" rel="stylesheet" type="text/css"/>
21        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
22        <script type="text/javascript" src="doxy-boot.js"></script>
23    </head>
24    <body>
25        <nav class="navbar navbar-default" role="navigation">
26            <div class="container">
27                <div class="navbar-header">
28                    <a class="navbar-brand">libevdev 1.12.1</a>
29                </div>
30            </div>
31        </nav>
32        <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
33            <div class="content" id="content">
34                <div class="container">
35                    <div class="row">
36                        <div class="col-sm-12 panel panel-default" style="padding-bottom: 15px;">
37                            <div style="margin-bottom: 15px;">
38<!-- end header part -->
39<!-- Generated by Doxygen 1.9.1 -->
40<script type="text/javascript">
41/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
42var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
43/* @license-end */
44</script>
45<script type="text/javascript" src="menudata.js"></script>
46<script type="text/javascript" src="menu.js"></script>
47<script type="text/javascript">
48/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
49$(function() {
50  initMenu('',true,false,'search.php','Search');
51  $(document).ready(function() { init_search(); });
52});
53/* @license-end */</script>
54<div id="main-nav"></div>
55</div><!-- top -->
56<!-- window showing the filter options -->
57<div id="MSearchSelectWindow"
58     onmouseover="return searchBox.OnSearchSelectShow()"
59     onmouseout="return searchBox.OnSearchSelectHide()"
60     onkeydown="return searchBox.OnSearchSelectKey(event)">
61</div>
62
63<!-- iframe showing the search results (closed by default) -->
64<div id="MSearchResultsWindow">
65<iframe src="javascript:void(0)" frameborder="0"
66        name="MSearchResults" id="MSearchResults">
67</iframe>
68</div>
69
70<div class="header">
71  <div class="summary">
72<a href="#func-members">Functions</a>  </div>
73  <div class="headertitle">
74<div class="title">uinput device creation</div>  </div>
75</div><!--header-->
76<div class="contents">
77
78<p>Creation of uinput devices based on existing libevdev devices.
79<a href="#details">More...</a></p>
80<table class="memberdecls">
81<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
82Functions</h2></td></tr>
83<tr class="memitem:gaf14b21301bac9d79c20e890172873b96"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uinput.html#gaf14b21301bac9d79c20e890172873b96">libevdev_uinput_create_from_device</a> (const struct libevdev *dev, int uinput_fd, struct libevdev_uinput **uinput_dev)</td></tr>
84<tr class="memdesc:gaf14b21301bac9d79c20e890172873b96"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a uinput device based on the given libevdev device.  <a href="group__uinput.html#gaf14b21301bac9d79c20e890172873b96">More...</a><br /></td></tr>
85<tr class="separator:gaf14b21301bac9d79c20e890172873b96"><td class="memSeparator" colspan="2">&#160;</td></tr>
86<tr class="memitem:ga9dfa58a84eb4c6b97107dcf3fa621329"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329">libevdev_uinput_destroy</a> (struct libevdev_uinput *uinput_dev)</td></tr>
87<tr class="memdesc:ga9dfa58a84eb4c6b97107dcf3fa621329"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destroy a previously created uinput device and free associated memory.  <a href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329">More...</a><br /></td></tr>
88<tr class="separator:ga9dfa58a84eb4c6b97107dcf3fa621329"><td class="memSeparator" colspan="2">&#160;</td></tr>
89<tr class="memitem:ga9cd7fb14a96d4cc14d3dffdcead84c5d"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uinput.html#ga9cd7fb14a96d4cc14d3dffdcead84c5d">libevdev_uinput_get_fd</a> (const struct libevdev_uinput *uinput_dev)</td></tr>
90<tr class="memdesc:ga9cd7fb14a96d4cc14d3dffdcead84c5d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the file descriptor used to create this uinput device.  <a href="group__uinput.html#ga9cd7fb14a96d4cc14d3dffdcead84c5d">More...</a><br /></td></tr>
91<tr class="separator:ga9cd7fb14a96d4cc14d3dffdcead84c5d"><td class="memSeparator" colspan="2">&#160;</td></tr>
92<tr class="memitem:gaacca93061fce57cec0ce3c52e443a427"><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uinput.html#gaacca93061fce57cec0ce3c52e443a427">libevdev_uinput_get_syspath</a> (struct libevdev_uinput *uinput_dev)</td></tr>
93<tr class="memdesc:gaacca93061fce57cec0ce3c52e443a427"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the syspath representing this uinput device.  <a href="group__uinput.html#gaacca93061fce57cec0ce3c52e443a427">More...</a><br /></td></tr>
94<tr class="separator:gaacca93061fce57cec0ce3c52e443a427"><td class="memSeparator" colspan="2">&#160;</td></tr>
95<tr class="memitem:ga4c595bcda748b08561e2819fe9b7c2d2"><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uinput.html#ga4c595bcda748b08561e2819fe9b7c2d2">libevdev_uinput_get_devnode</a> (struct libevdev_uinput *uinput_dev)</td></tr>
96<tr class="memdesc:ga4c595bcda748b08561e2819fe9b7c2d2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the device node representing this uinput device.  <a href="group__uinput.html#ga4c595bcda748b08561e2819fe9b7c2d2">More...</a><br /></td></tr>
97<tr class="separator:ga4c595bcda748b08561e2819fe9b7c2d2"><td class="memSeparator" colspan="2">&#160;</td></tr>
98<tr class="memitem:ga4c3c2f5fcd315a28a067f53b9f855fe7"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uinput.html#ga4c3c2f5fcd315a28a067f53b9f855fe7">libevdev_uinput_write_event</a> (const struct libevdev_uinput *uinput_dev, unsigned int type, unsigned int code, int value)</td></tr>
99<tr class="memdesc:ga4c3c2f5fcd315a28a067f53b9f855fe7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Post an event through the uinput device.  <a href="group__uinput.html#ga4c3c2f5fcd315a28a067f53b9f855fe7">More...</a><br /></td></tr>
100<tr class="separator:ga4c3c2f5fcd315a28a067f53b9f855fe7"><td class="memSeparator" colspan="2">&#160;</td></tr>
101</table>
102<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
103<p>Creation of uinput devices based on existing libevdev devices. </p>
104<p>These functions help to create uinput devices that emulate libevdev devices. In the simplest form it serves to duplicate an existing device:</p>
105<div class="fragment"><div class="line"><span class="keywordtype">int</span> err;</div>
106<div class="line"><span class="keywordtype">int</span> fd, uifd;</div>
107<div class="line"><span class="keyword">struct </span>libevdev *dev;</div>
108<div class="line"><span class="keyword">struct </span>libevdev_uinput *uidev;</div>
109<div class="line"> </div>
110<div class="line">fd = open(<span class="stringliteral">&quot;/dev/input/event0&quot;</span>, O_RDONLY);</div>
111<div class="line"><span class="keywordflow">if</span> (fd &lt; 0)</div>
112<div class="line">    <span class="keywordflow">return</span> -errno;</div>
113<div class="line"> </div>
114<div class="line">err = <a class="code" href="group__init.html#ga89bb5bce1c23e293293484b05b12aaf4">libevdev_new_from_fd</a>(fd, &amp;dev);</div>
115<div class="line"><span class="keywordflow">if</span> (err != 0)</div>
116<div class="line">    <span class="keywordflow">return</span> err;</div>
117<div class="line"> </div>
118<div class="line">uifd = open(<span class="stringliteral">&quot;/dev/uinput&quot;</span>, O_RDWR);</div>
119<div class="line"><span class="keywordflow">if</span> (uifd &lt; 0)</div>
120<div class="line">    <span class="keywordflow">return</span> -errno;</div>
121<div class="line"> </div>
122<div class="line">err = <a class="code" href="group__uinput.html#gaf14b21301bac9d79c20e890172873b96">libevdev_uinput_create_from_device</a>(dev, uifd, &amp;uidev);</div>
123<div class="line"><span class="keywordflow">if</span> (err != 0)</div>
124<div class="line">    <span class="keywordflow">return</span> err;</div>
125<div class="line"> </div>
126<div class="line"><span class="comment">// post a REL_X event</span></div>
127<div class="line">err = <a class="code" href="group__uinput.html#ga4c3c2f5fcd315a28a067f53b9f855fe7">libevdev_uinput_write_event</a>(uidev, EV_REL, REL_X, -1);</div>
128<div class="line"><span class="keywordflow">if</span> (err != 0)</div>
129<div class="line">    <span class="keywordflow">return</span> err;</div>
130<div class="line">err = <a class="code" href="group__uinput.html#ga4c3c2f5fcd315a28a067f53b9f855fe7">libevdev_uinput_write_event</a>(uidev, EV_SYN, SYN_REPORT, 0);</div>
131<div class="line"><span class="keywordflow">if</span> (err != 0)</div>
132<div class="line">    <span class="keywordflow">return</span> err;</div>
133<div class="line"> </div>
134<div class="line"><a class="code" href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329">libevdev_uinput_destroy</a>(uidev);</div>
135<div class="line"><a class="code" href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c">libevdev_free</a>(dev);</div>
136<div class="line">close(uifd);</div>
137<div class="line">close(fd);</div>
138<div class="ttc" id="agroup__init_html_ga89bb5bce1c23e293293484b05b12aaf4"><div class="ttname"><a href="group__init.html#ga89bb5bce1c23e293293484b05b12aaf4">libevdev_new_from_fd</a></div><div class="ttdeci">int libevdev_new_from_fd(int fd, struct libevdev **dev)</div><div class="ttdoc">Initialize a new libevdev device from the given fd.</div></div>
139<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>
140<div class="ttc" id="agroup__uinput_html_ga4c3c2f5fcd315a28a067f53b9f855fe7"><div class="ttname"><a href="group__uinput.html#ga4c3c2f5fcd315a28a067f53b9f855fe7">libevdev_uinput_write_event</a></div><div class="ttdeci">int libevdev_uinput_write_event(const struct libevdev_uinput *uinput_dev, unsigned int type, unsigned int code, int value)</div><div class="ttdoc">Post an event through the uinput device.</div></div>
141<div class="ttc" id="agroup__uinput_html_ga9dfa58a84eb4c6b97107dcf3fa621329"><div class="ttname"><a href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329">libevdev_uinput_destroy</a></div><div class="ttdeci">void libevdev_uinput_destroy(struct libevdev_uinput *uinput_dev)</div><div class="ttdoc">Destroy a previously created uinput device and free associated memory.</div></div>
142<div class="ttc" id="agroup__uinput_html_gaf14b21301bac9d79c20e890172873b96"><div class="ttname"><a href="group__uinput.html#gaf14b21301bac9d79c20e890172873b96">libevdev_uinput_create_from_device</a></div><div class="ttdeci">int libevdev_uinput_create_from_device(const struct libevdev *dev, int uinput_fd, struct libevdev_uinput **uinput_dev)</div><div class="ttdoc">Create a uinput device based on the given libevdev device.</div></div>
143</div><!-- fragment --><p>Alternatively, a device can be constructed from scratch:</p>
144<div class="fragment"><div class="line"><span class="keywordtype">int</span> err;</div>
145<div class="line"><span class="keyword">struct </span>libevdev *dev;</div>
146<div class="line"><span class="keyword">struct </span>libevdev_uinput *uidev;</div>
147<div class="line"> </div>
148<div class="line">dev = <a class="code" href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c">libevdev_new</a>();</div>
149<div class="line"><a class="code" href="group__kernel.html#gae5dcdb7678cdc9be4ab1989725b4ed32">libevdev_set_name</a>(dev, <span class="stringliteral">&quot;test device&quot;</span>);</div>
150<div class="line"><a class="code" href="group__kernel.html#ga59ef78b1557f9543d0060ab25b0167ca">libevdev_enable_event_type</a>(dev, EV_REL);</div>
151<div class="line"><a class="code" href="group__kernel.html#ga51cfda33fd526549046399aadd764fca">libevdev_enable_event_code</a>(dev, EV_REL, REL_X, NULL);</div>
152<div class="line"><a class="code" href="group__kernel.html#ga51cfda33fd526549046399aadd764fca">libevdev_enable_event_code</a>(dev, EV_REL, REL_Y, NULL);</div>
153<div class="line"><a class="code" href="group__kernel.html#ga59ef78b1557f9543d0060ab25b0167ca">libevdev_enable_event_type</a>(dev, EV_KEY);</div>
154<div class="line"><a class="code" href="group__kernel.html#ga51cfda33fd526549046399aadd764fca">libevdev_enable_event_code</a>(dev, EV_KEY, BTN_LEFT, NULL);</div>
155<div class="line"><a class="code" href="group__kernel.html#ga51cfda33fd526549046399aadd764fca">libevdev_enable_event_code</a>(dev, EV_KEY, BTN_MIDDLE, NULL);</div>
156<div class="line"><a class="code" href="group__kernel.html#ga51cfda33fd526549046399aadd764fca">libevdev_enable_event_code</a>(dev, EV_KEY, BTN_RIGHT, NULL);</div>
157<div class="line"> </div>
158<div class="line">err = <a class="code" href="group__uinput.html#gaf14b21301bac9d79c20e890172873b96">libevdev_uinput_create_from_device</a>(dev,</div>
159<div class="line">                                         <a class="code" href="libevdev-uinput_8h.html#a6546acd3e4fe75a74d91eebf9bbd3d03adcf2d4de38844ee3a8c830bc3285afad">LIBEVDEV_UINPUT_OPEN_MANAGED</a>,</div>
160<div class="line">                                         &amp;uidev);</div>
161<div class="line"><span class="keywordflow">if</span> (err != 0)</div>
162<div class="line">    <span class="keywordflow">return</span> err;</div>
163<div class="line"> </div>
164<div class="line"><span class="comment">// ... do something ...</span></div>
165<div class="line"> </div>
166<div class="line"><a class="code" href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329">libevdev_uinput_destroy</a>(uidev);</div>
167<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>
168<div class="ttc" id="agroup__kernel_html_ga51cfda33fd526549046399aadd764fca"><div class="ttname"><a href="group__kernel.html#ga51cfda33fd526549046399aadd764fca">libevdev_enable_event_code</a></div><div class="ttdeci">int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data)</div><div class="ttdoc">Forcibly enable an event code on this device, even if the underlying device does not support it.</div></div>
169<div class="ttc" id="agroup__kernel_html_ga59ef78b1557f9543d0060ab25b0167ca"><div class="ttname"><a href="group__kernel.html#ga59ef78b1557f9543d0060ab25b0167ca">libevdev_enable_event_type</a></div><div class="ttdeci">int libevdev_enable_event_type(struct libevdev *dev, unsigned int type)</div><div class="ttdoc">Forcibly enable an event type on this device, even if the underlying device does not support it.</div></div>
170<div class="ttc" id="agroup__kernel_html_gae5dcdb7678cdc9be4ab1989725b4ed32"><div class="ttname"><a href="group__kernel.html#gae5dcdb7678cdc9be4ab1989725b4ed32">libevdev_set_name</a></div><div class="ttdeci">void libevdev_set_name(struct libevdev *dev, const char *name)</div><div class="ttdoc">Change the device's name as returned by libevdev_get_name().</div></div>
171<div class="ttc" id="alibevdev-uinput_8h_html_a6546acd3e4fe75a74d91eebf9bbd3d03adcf2d4de38844ee3a8c830bc3285afad"><div class="ttname"><a href="libevdev-uinput_8h.html#a6546acd3e4fe75a74d91eebf9bbd3d03adcf2d4de38844ee3a8c830bc3285afad">LIBEVDEV_UINPUT_OPEN_MANAGED</a></div><div class="ttdeci">@ LIBEVDEV_UINPUT_OPEN_MANAGED</div><div class="ttdoc">let libevdev open and close /dev/uinput</div><div class="ttdef"><b>Definition:</b> libevdev-uinput.h:114</div></div>
172</div><!-- fragment --> <h2 class="groupheader">Function Documentation</h2>
173<a id="gaf14b21301bac9d79c20e890172873b96"></a>
174<h2 class="memtitle"><span class="permalink"><a href="#gaf14b21301bac9d79c20e890172873b96">&#9670;&nbsp;</a></span>libevdev_uinput_create_from_device()</h2>
175
176<div class="memitem">
177<div class="memproto">
178      <table class="memname">
179        <tr>
180          <td class="memname">int libevdev_uinput_create_from_device </td>
181          <td>(</td>
182          <td class="paramtype">const struct libevdev *&#160;</td>
183          <td class="paramname"><em>dev</em>, </td>
184        </tr>
185        <tr>
186          <td class="paramkey"></td>
187          <td></td>
188          <td class="paramtype">int&#160;</td>
189          <td class="paramname"><em>uinput_fd</em>, </td>
190        </tr>
191        <tr>
192          <td class="paramkey"></td>
193          <td></td>
194          <td class="paramtype">struct libevdev_uinput **&#160;</td>
195          <td class="paramname"><em>uinput_dev</em>&#160;</td>
196        </tr>
197        <tr>
198          <td></td>
199          <td>)</td>
200          <td></td><td></td>
201        </tr>
202      </table>
203</div><div class="memdoc">
204
205<p>Create a uinput device based on the given libevdev device. </p>
206<p>The uinput device will be an exact copy of the libevdev device, minus the bits that uinput doesn't allow to be set.</p>
207<p>If uinput_fd is <a class="el" href="libevdev-uinput_8h.html#a6546acd3e4fe75a74d91eebf9bbd3d03adcf2d4de38844ee3a8c830bc3285afad">LIBEVDEV_UINPUT_OPEN_MANAGED</a>, <a class="el" href="group__uinput.html#gaf14b21301bac9d79c20e890172873b96" title="Create a uinput device based on the given libevdev device.">libevdev_uinput_create_from_device()</a> will open <code>/dev/uinput</code> in read/write mode and manage the file descriptor. Otherwise, uinput_fd must be opened by the caller and opened with the appropriate permissions.</p>
208<p>The device's lifetime is tied to the uinput file descriptor, closing it will destroy the uinput device. You should call <a class="el" href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329" title="Destroy a previously created uinput device and free associated memory.">libevdev_uinput_destroy()</a> before closing the file descriptor to free allocated resources. A file descriptor can only create one uinput device at a time; the second device will fail with -EINVAL.</p>
209<p>You don't need to keep the file descriptor variable around, <a class="el" href="group__uinput.html#ga9cd7fb14a96d4cc14d3dffdcead84c5d" title="Return the file descriptor used to create this uinput device.">libevdev_uinput_get_fd()</a> will return it when needed.</p>
210<dl class="section note"><dt>Note</dt><dd>Due to limitations in the uinput kernel module, REP_DELAY and REP_PERIOD will default to the kernel defaults, not to the ones set in the source device.</dd>
211<dd>
212On FreeBSD, if the UI_GET_SYSNAME ioctl() fails, there is no other way to get a device, and the function call will fail.</dd></dl>
213<dl class="params"><dt>Parameters</dt><dd>
214  <table class="params">
215    <tr><td class="paramdir"></td><td class="paramname">dev</td><td>The device to duplicate </td></tr>
216    <tr><td class="paramdir"></td><td class="paramname">uinput_fd</td><td><a class="el" href="libevdev-uinput_8h.html#a6546acd3e4fe75a74d91eebf9bbd3d03adcf2d4de38844ee3a8c830bc3285afad">LIBEVDEV_UINPUT_OPEN_MANAGED</a> or a file descriptor to <code>/dev/uinput</code>, </td></tr>
217    <tr><td class="paramdir">[out]</td><td class="paramname">uinput_dev</td><td>The newly created libevdev device.</td></tr>
218  </table>
219  </dd>
220</dl>
221<dl class="section return"><dt>Returns</dt><dd>0 on success or a negative errno on failure. On failure, the value of uinput_dev is unmodified.</dd></dl>
222<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329" title="Destroy a previously created uinput device and free associated memory.">libevdev_uinput_destroy</a> </dd></dl>
223
224</div>
225</div>
226<a id="ga9dfa58a84eb4c6b97107dcf3fa621329"></a>
227<h2 class="memtitle"><span class="permalink"><a href="#ga9dfa58a84eb4c6b97107dcf3fa621329">&#9670;&nbsp;</a></span>libevdev_uinput_destroy()</h2>
228
229<div class="memitem">
230<div class="memproto">
231      <table class="memname">
232        <tr>
233          <td class="memname">void libevdev_uinput_destroy </td>
234          <td>(</td>
235          <td class="paramtype">struct libevdev_uinput *&#160;</td>
236          <td class="paramname"><em>uinput_dev</em></td><td>)</td>
237          <td></td>
238        </tr>
239      </table>
240</div><div class="memdoc">
241
242<p>Destroy a previously created uinput device and free associated memory. </p>
243<p>If the device was opened with <a class="el" href="libevdev-uinput_8h.html#a6546acd3e4fe75a74d91eebf9bbd3d03adcf2d4de38844ee3a8c830bc3285afad">LIBEVDEV_UINPUT_OPEN_MANAGED</a>, <a class="el" href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329" title="Destroy a previously created uinput device and free associated memory.">libevdev_uinput_destroy()</a> also closes the file descriptor. Otherwise, the fd is left as-is and must be closed by the caller.</p>
244<dl class="params"><dt>Parameters</dt><dd>
245  <table class="params">
246    <tr><td class="paramname">uinput_dev</td><td>A previously created uinput device. </td></tr>
247  </table>
248  </dd>
249</dl>
250
251</div>
252</div>
253<a id="ga4c595bcda748b08561e2819fe9b7c2d2"></a>
254<h2 class="memtitle"><span class="permalink"><a href="#ga4c595bcda748b08561e2819fe9b7c2d2">&#9670;&nbsp;</a></span>libevdev_uinput_get_devnode()</h2>
255
256<div class="memitem">
257<div class="memproto">
258      <table class="memname">
259        <tr>
260          <td class="memname">const char* libevdev_uinput_get_devnode </td>
261          <td>(</td>
262          <td class="paramtype">struct libevdev_uinput *&#160;</td>
263          <td class="paramname"><em>uinput_dev</em></td><td>)</td>
264          <td></td>
265        </tr>
266      </table>
267</div><div class="memdoc">
268
269<p>Return the device node representing this uinput device. </p>
270<p>This relies on <a class="el" href="group__uinput.html#gaacca93061fce57cec0ce3c52e443a427" title="Return the syspath representing this uinput device.">libevdev_uinput_get_syspath()</a> to provide a valid syspath. See <a class="el" href="group__uinput.html#gaacca93061fce57cec0ce3c52e443a427" title="Return the syspath representing this uinput device.">libevdev_uinput_get_syspath()</a> for more details.</p>
271<dl class="section note"><dt>Note</dt><dd>This function may return NULL. libevdev may have to guess the syspath and the device node. See <a class="el" href="group__uinput.html#gaacca93061fce57cec0ce3c52e443a427" title="Return the syspath representing this uinput device.">libevdev_uinput_get_syspath()</a> for details.</dd>
272<dd>
273On FreeBSD, this function can not return NULL. libudev uses the UI_GET_SYSNAME ioctl to get the device node on this platform and if that fails, the call to <a class="el" href="group__uinput.html#gaf14b21301bac9d79c20e890172873b96" title="Create a uinput device based on the given libevdev device.">libevdev_uinput_create_from_device()</a> fails.</dd></dl>
274<dl class="params"><dt>Parameters</dt><dd>
275  <table class="params">
276    <tr><td class="paramname">uinput_dev</td><td>A previously created uinput device. </td></tr>
277  </table>
278  </dd>
279</dl>
280<dl class="section return"><dt>Returns</dt><dd>The device node for this device, in the form of /dev/input/eventN</dd></dl>
281<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__uinput.html#gaacca93061fce57cec0ce3c52e443a427" title="Return the syspath representing this uinput device.">libevdev_uinput_get_syspath</a> </dd></dl>
282
283</div>
284</div>
285<a id="ga9cd7fb14a96d4cc14d3dffdcead84c5d"></a>
286<h2 class="memtitle"><span class="permalink"><a href="#ga9cd7fb14a96d4cc14d3dffdcead84c5d">&#9670;&nbsp;</a></span>libevdev_uinput_get_fd()</h2>
287
288<div class="memitem">
289<div class="memproto">
290      <table class="memname">
291        <tr>
292          <td class="memname">int libevdev_uinput_get_fd </td>
293          <td>(</td>
294          <td class="paramtype">const struct libevdev_uinput *&#160;</td>
295          <td class="paramname"><em>uinput_dev</em></td><td>)</td>
296          <td></td>
297        </tr>
298      </table>
299</div><div class="memdoc">
300
301<p>Return the file descriptor used to create this uinput device. </p>
302<p>This is the fd pointing to <b>/dev/uinput</b>. This file descriptor may be used to write events that are emitted by the uinput device. Closing this file descriptor will destroy the uinput device, you should call <a class="el" href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329" title="Destroy a previously created uinput device and free associated memory.">libevdev_uinput_destroy()</a> first to free allocated resources.</p>
303<dl class="params"><dt>Parameters</dt><dd>
304  <table class="params">
305    <tr><td class="paramname">uinput_dev</td><td>A previously created uinput device.</td></tr>
306  </table>
307  </dd>
308</dl>
309<dl class="section return"><dt>Returns</dt><dd>The file descriptor used to create this device </dd></dl>
310
311</div>
312</div>
313<a id="gaacca93061fce57cec0ce3c52e443a427"></a>
314<h2 class="memtitle"><span class="permalink"><a href="#gaacca93061fce57cec0ce3c52e443a427">&#9670;&nbsp;</a></span>libevdev_uinput_get_syspath()</h2>
315
316<div class="memitem">
317<div class="memproto">
318      <table class="memname">
319        <tr>
320          <td class="memname">const char* libevdev_uinput_get_syspath </td>
321          <td>(</td>
322          <td class="paramtype">struct libevdev_uinput *&#160;</td>
323          <td class="paramname"><em>uinput_dev</em></td><td>)</td>
324          <td></td>
325        </tr>
326      </table>
327</div><div class="memdoc">
328
329<p>Return the syspath representing this uinput device. </p>
330<p>If the UI_GET_SYSNAME ioctl is not available, libevdev makes an educated guess. The UI_GET_SYSNAME ioctl is available since Linux 3.15.</p>
331<p>The syspath returned is the one of the input node itself (e.g. /sys/devices/virtual/input/input123), not the syspath of the device node returned with <a class="el" href="group__uinput.html#ga4c595bcda748b08561e2819fe9b7c2d2" title="Return the device node representing this uinput device.">libevdev_uinput_get_devnode()</a>.</p>
332<dl class="section note"><dt>Note</dt><dd>This function may return NULL if UI_GET_SYSNAME is not available. In that case, libevdev uses ctime and the device name to guess devices. To avoid false positives, wait at least 1.5s between creating devices that have the same name.</dd>
333<dd>
334FreeBSD does not have sysfs, on FreeBSD this function always returns NULL.</dd></dl>
335<dl class="params"><dt>Parameters</dt><dd>
336  <table class="params">
337    <tr><td class="paramname">uinput_dev</td><td>A previously created uinput device. </td></tr>
338  </table>
339  </dd>
340</dl>
341<dl class="section return"><dt>Returns</dt><dd>The syspath for this device, including the preceding /sys</dd></dl>
342<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__uinput.html#ga4c595bcda748b08561e2819fe9b7c2d2" title="Return the device node representing this uinput device.">libevdev_uinput_get_devnode</a> </dd></dl>
343
344</div>
345</div>
346<a id="ga4c3c2f5fcd315a28a067f53b9f855fe7"></a>
347<h2 class="memtitle"><span class="permalink"><a href="#ga4c3c2f5fcd315a28a067f53b9f855fe7">&#9670;&nbsp;</a></span>libevdev_uinput_write_event()</h2>
348
349<div class="memitem">
350<div class="memproto">
351      <table class="memname">
352        <tr>
353          <td class="memname">int libevdev_uinput_write_event </td>
354          <td>(</td>
355          <td class="paramtype">const struct libevdev_uinput *&#160;</td>
356          <td class="paramname"><em>uinput_dev</em>, </td>
357        </tr>
358        <tr>
359          <td class="paramkey"></td>
360          <td></td>
361          <td class="paramtype">unsigned int&#160;</td>
362          <td class="paramname"><em>type</em>, </td>
363        </tr>
364        <tr>
365          <td class="paramkey"></td>
366          <td></td>
367          <td class="paramtype">unsigned int&#160;</td>
368          <td class="paramname"><em>code</em>, </td>
369        </tr>
370        <tr>
371          <td class="paramkey"></td>
372          <td></td>
373          <td class="paramtype">int&#160;</td>
374          <td class="paramname"><em>value</em>&#160;</td>
375        </tr>
376        <tr>
377          <td></td>
378          <td>)</td>
379          <td></td><td></td>
380        </tr>
381      </table>
382</div><div class="memdoc">
383
384<p>Post an event through the uinput device. </p>
385<p>It is the caller's responsibility that any event sequence is terminated with an EV_SYN/SYN_REPORT/0 event. Otherwise, listeners on the device node will not see the events until the next EV_SYN event is posted.</p>
386<dl class="params"><dt>Parameters</dt><dd>
387  <table class="params">
388    <tr><td class="paramname">uinput_dev</td><td>A previously created uinput device. </td></tr>
389    <tr><td class="paramname">type</td><td>Event type (EV_ABS, EV_REL, etc.) </td></tr>
390    <tr><td class="paramname">code</td><td>Event code (ABS_X, REL_Y, etc.) </td></tr>
391    <tr><td class="paramname">value</td><td>The event value </td></tr>
392  </table>
393  </dd>
394</dl>
395<dl class="section return"><dt>Returns</dt><dd>0 on success or a negative errno on error </dd></dl>
396
397</div>
398</div>
399</div><!-- contents -->
400<!-- HTML footer for doxygen 1.8.8-->
401<!-- start footer part -->
402</div>
403</div>
404</div>
405</div>
406</div>
407<hr class="footer"/><address class="footer"><small>
408Generated by &#160;<a href="http://www.doxygen.org/index.html">
409<img class="footer" src="doxygen.png" alt="doxygen"/>
410</a> 1.9.1
411</small></address>
412</body>
413</html>
414