Changeset 942


Ignore:
Timestamp:
02/10/07 13:30:06 (6 years ago)
Author:
laforge
Message:
  • only grab the device once rather than trying to grab it all the time
  • un-grab it at exit time
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/oe/packages/tslib/tslib-1.0/tslib-input_raw-grab_events.patch

    r939 r942  
    2020 #include <stdlib.h> 
    2121 #ifdef HAVE_UNISTD_H 
    22 @@ -42,6 +43,7 @@ 
     22@@ -33,6 +34,9 @@ 
     23  
     24 #include "tslib-private.h" 
     25  
     26+#define GRAB_EVENTS_WANTED     1 
     27+#define GRAB_EVENTS_ACTIVE     2 
     28+ 
     29 struct tslib_input { 
     30        struct tslib_module_info module; 
     31  
     32@@ -42,6 +46,7 @@ 
    2333  
    2434        int     sane_fd; 
     
    2838  
    2939 static int check_fd(struct tslib_input *i) 
    30 @@ -64,6 +66,13 @@ 
     40@@ -64,6 +69,14 @@ 
    3141  
    3242        if (bit & (1 << EV_SYN)) 
    3343                i->using_syn = 1; 
    3444+        
    35 +       if (i->grab_events) { 
     45+       if (i->grab_events == GRAB_EVENTS_WANTED) { 
    3646+               if (ioctl(ts->fd, EVIOCGRAB, (void *)1)) { 
    3747+                       fprintf(stderr, "Unable to grab selected input device\n"); 
    3848+                       return -1; 
    3949+               } 
     50+               i->grab_events = GRAB_EVENTS_ACTIVE; 
    4051+       } 
    4152  
    4253        return 0; 
    4354 } 
    44 @@ -231,6 +240,35 @@ 
     55@@ -222,6 +235,15 @@ 
     56  
     57 static int ts_input_fini(struct tslib_module_info *inf) 
     58 { 
     59+       struct tslib_input *i = (struct tslib_input *)inf; 
     60+       struct tsdev *ts = inf->dev; 
     61+ 
     62+       if (i->grab_events == GRAB_EVENTS_ACTIVE) { 
     63+               if (ioctl(ts->fd, EVIOCGRAB, (void *)0)) { 
     64+                       fprintf(stderr, "Unable to un-grab selected input device\n"); 
     65+               } 
     66+       } 
     67+ 
     68        free(inf); 
     69        return 0; 
     70 } 
     71@@ -231,6 +253,36 @@ 
    4572        .fini   = ts_input_fini, 
    4673 }; 
     
    6087+       switch ((int)data) { 
    6188+       case 1: 
    62 +               i->grab_events = v; 
     89+               if (v) 
     90+                       i->grab_events = GRAB_EVENTS_WANTED; 
    6391+               break; 
    6492+       default: 
     
    78106 { 
    79107        struct tslib_input *i; 
    80 @@ -245,5 +283,12 @@ 
     108@@ -245,5 +297,12 @@ 
    81109        i->current_p = 0; 
    82110        i->sane_fd = 0; 
Note: See TracChangeset for help on using the changeset viewer.