changeset 7:6aa40a25de22

Remove debug and add an assert on the size of the received struct.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 18 Aug 2015 02:08:29 +0100
parents eafcd170dc6d
children dec5fe6cd0d0
files ds.c uinput.c
diffstat 2 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ds.c
+++ b/ds.c
@@ -1,5 +1,6 @@
 #include "ds.h"
 #include "uinput.h"
+#include <assert.h>
 #include <stdint.h>
 #include <string.h>
 
@@ -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);
--- 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;
     }