mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-24 11:34:32 +00:00
Update joystick example with new failure mode
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
412f04f413
commit
5929295c37
2 files changed
+19
No files matched your search
@@ -238,8 +238,20 @@ struct js_event {
|
||||
uint8_t number; /* axis/button number */
|
||||
} e;
|
||||
|
||||
/*
|
||||
* Called on any joystick event
|
||||
*
|
||||
* Note: We handle errors here by exiting, for a background daemon with
|
||||
* multiple watchers you may want another approach.
|
||||
*/
|
||||
static void joystick_cb(uev_t *w, void *arg, int events)
|
||||
{
|
||||
if (UEV_ERROR == events) {
|
||||
/* Possibly joystick was unplugged */
|
||||
warn("Unrecoverable error, exiting");
|
||||
uev_exit(w->ctx);
|
||||
}
|
||||
|
||||
read(w->fd, &e, sizeof(e));
|
||||
|
||||
switch (e.type) {
|
||||
|
||||
Reference in new issue
Block a user