<div dir="ltr"><div>Hello everyone,<br><br>I am trying out libinput as an input backend for OpenTK[1] when running on a VT terminal. Using weston as a reference, I have managed to get keyboard input working as expected. The API is pleasantly terse, with very little of the X11/XI2 non-sense remaining.<br>
<br></div><div>There is one thing I haven't been able to manage so far is to implement a blocking poll on the input thread. If my understanding is correct (and it probably isn't), I should be able to call libinput_get_fd() and then poll on that for events. However, if I do that, poll invariably returns an error (-1):<br>
<br><br>
<font face="Consolas">
<span style="color:rgb(51,51,51)"> int fd = libinput_get_fd(input_context);<br></span></font></div><div><font face="Consolas"><span style="color:rgb(51,51,51)"> struct poll_fd pfd = {<br></span></font></div><div><font face="Consolas"><span style="color:rgb(51,51,51)"> .fd = fd,<br>
</span></font></div><div><font face="Consolas"><span style="color:rgb(51,51,51)"> .events = POLLIN<br></span></font></div><div><font face="Consolas"><span style="color:rgb(51,51,51)"> };<br><br></span></font></div>
<div><font face="Consolas"><span style="color:rgb(51,51,51)"> while (!exit) {<br></span></font></div><div><font face="Consolas"><span style="color:rgb(51,51,51)"> int ret = poll(&pfd, 1, -1);<br></span></font></div>
<div><font face="Consolas"><span style="color:rgb(51,51,51)"> if (ret < 0) {<br></span></font></div><div><font face="Consolas"><span style="color:rgb(51,51,51)"> // ret is always -1<br></span></font></div>
<div><font face="Consolas"><span style="color:rgb(51,51,51)"> exit = ret;<br></span></font></div><div><font face="Consolas"><span style="color:rgb(51,51,51)"> }<br> else {<br></span></font></div>
<div>
<font face="Consolas"><span style="color:rgb(51,51,51)"> // never gets here<br></span></font></div><div><font face="Consolas"><span style="color:rgb(51,51,51)"> libinput_dispatch(input_context);<br>
</span></font></div>
<div><font face="Consolas"><span style="color:rgb(51,51,51)"> }<br></span></font></div><div><font face="Consolas"><span style="color:rgb(51,51,51)"> }<br></span></font></div><div><br></div><div>If I remove <font face="Consolas"><span style="color:rgb(51,51,51)">'poll'</span></font> then I can retrieve input events without any trouble.<br>
<br></div><div>Is what I am trying to do supported? If so, what could be the problem? Or, if not, then is there a supported way to block on libinput events?<br></div><div><br></div><div>Cheers!<br></div><div><br><br></div>
[1] <a href="http://www.opentk.com">http://www.opentk.com</a><br></div>