# HG changeset patch # User Emmanuel Gil Peyrot # Date 1439860109 -3600 # Node ID 6aa40a25de223503428be83887ca0aa0208f22be # Parent eafcd170dc6daf3e72cfd2755f5c300f0492b810 Remove debug and add an assert on the size of the received struct. diff --git a/ds.c b/ds.c --- a/ds.c +++ b/ds.c @@ -1,5 +1,6 @@ #include "ds.h" #include "uinput.h" +#include #include #include @@ -9,13 +10,10 @@ #define maybe_do_uinput(button, uinput_button) \ do { \ - if (!previous.button && ds->button) { \ - printf("Button " #uinput_button " pressed.\n"); \ + if (!previous.button && ds->button) \ do_uinput(uinput_fd, uinput_button, 1, EV_KEY); \ - } else if (previous.button && !ds->button) { \ - printf("Button " #uinput_button " released.\n"); \ + else if (previous.button && !ds->button) \ do_uinput(uinput_fd, uinput_button, 0, EV_KEY); \ - } \ } while(0) @@ -26,6 +24,8 @@ void ds_process_evt(ds_t* ds, int uinput static ds_t previous; + assert(8 == sizeof(ds_t)); + /* BUTTONS: */ maybe_do_uinput(a, BTN_A); maybe_do_uinput(b, BTN_B); diff --git a/uinput.c b/uinput.c --- a/uinput.c +++ b/uinput.c @@ -39,6 +39,7 @@ int init_uinput_device(void){ else fd = open(uinput_dev, O_RDWR); //from xml if(fd < 0){ + perror("open"); fprintf(stderr, " [%d] Unable to open uinput device ; hint: 'modprobe uinput' ?!\n", curdev); return -1; }