[PATCH/neod] make neod more relexable about keycode returned from the touchscreen

Neil Brown neilb at suse.de
Fri Aug 22 09:45:50 CEST 2008


Hi,
 I would like to change the keycode returned by finger up/down events
 on the Neo Touchscreen from BTN_TOUCH to BTN_STYLUS. (0x14a to
 0x14b).

 Most users of the touchscreen don't really care what the event is. 
 tslib, which is the main user, is happy with the ABS_PRESSURE
 events.  odeviced in the FSO framework just notices any event from
 the device and doesn't care what it is.

 neod is the exception (or the only one I can find.  I'd be
 interested to hear if there are any more.  i.e other users of
 /dev/input/event1 which check the keycode on 'key' events).

 So I would like neod changed to be less specific about what it tests
 for.  A reasonable option is to test for any tool-like button. i.e.
 those in the set.

#define BTN_DIGI		0x140
#define BTN_TOOL_PEN		0x140
#define BTN_TOOL_RUBBER		0x141
#define BTN_TOOL_BRUSH		0x142
#define BTN_TOOL_PENCIL		0x143
#define BTN_TOOL_AIRBRUSH	0x144
#define BTN_TOOL_FINGER		0x145
#define BTN_TOOL_MOUSE		0x146
#define BTN_TOOL_LENS		0x147
#define BTN_TOUCH		0x14a
#define BTN_STYLUS		0x14b
#define BTN_STYLUS2		0x14c
#define BTN_TOOL_DOUBLETAP	0x14d
#define BTN_TOOL_TRIPLETAP	0x14e

 We can easily do that with a range test.  The patch below makes this
 change to neod.


 The reason that I want to change the keycode is slightly complex.

 The "input" layer in Linux has a special device called
 /dev/input/mice.  Any device that it sees that looks at all like a
 mouse is connected to this device and the events from all mice appear
 on this device.  The X server reads this device to get mouse events.

 We don't want events from the touch screen to appear on
 /dev/input/mice as that would confuse the X server which already gets
 the events separately from /dev/input/event1.

 There are currently two 'fixes' in place to stop the events from the
 touch screen going to /dev/input/mice.
 
 1 - a patch in tslib which causes it to use EVIOCGRAB on the
     touchscreen to stop events going anywhere else.  This is
     overly heavy handed and needs another patch in the kernel
     stop the GRAB from breaking things.  This patch breaks other
     users of EVIOCGRAB
 2 - a patch in the kernel which changes the way that the input layer
     detects mice, so that the touch screen does not look like a
     mouse.

 Bother of these 'fixes' are bad, if only because they require patches
 which will never go upstream.

 An alternate way to 'fix' the problem is to change the touch screen
 driver to return something other than BTN_TOUCH.  BTN_STYLUS seems
 like a suitable choice.  This is a 'good' fix because it is
 completely local the device in question and so cannot break anything
 that doesn't use the device.  Of the few things that do use the
 device, most (as mentioned above) don't care about the particular
 BTN_ number.  Only neod.  Hence this patch.

If this patch (or something like it) could be committed to neod, I
would really appreciate it.  Then I can continue working with the
kernel people to remove the problematic patches, and change the touch
screen driver to use BTN_STYLUS.

Thanks for your time,
NeilBrown


Be more relax in keycode used for detecting activity on touch screen.

Different drivers may report different key code.  We don't really
need to care which keycode is used, just if there was a key press
at all.  So use a range test to look for any 'tool' like button press.

Signed-off-by: NeilBrown <neilb at suse.de>

---
 src/buttonactions.c |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

--- neod.orig/src/buttonactions.c
+++ neod/src/buttonactions.c
@@ -53,7 +53,12 @@ static int backlight_max_brightness = 1;
 #ifdef NEOD_PLATFORM_FIC_NEO1973
     #define AUX_BUTTON_KEYCODE 169    /* aux */
     #define POWER_BUTTON_KEYCODE 116  /* power */
-    #define TOUCHSCREEN_BUTTON_KEYCODE 0x14a
+    /* Touch screen might return BTN_TOUCH or BTN_STYLUS
+     * No need to be over-precise in testing for it, just look
+     * for any 'tool' related button
+     */
+    #define TOUCHSCREEN_BUTTON_KEYCODE_MIN	0x140 /* BTN_DIGI */
+    #define TOUCHSCREEN_BUTTON_KEYCODE_MAX	0x14E /* BTN_TOOL_TRIPLETAP */
 #endif
 
 #ifdef NEOD_PLATFORM_MOTOROLA_EZX
@@ -74,6 +79,11 @@ static int backlight_max_brightness = 1;
     #define TOUCHSCREEN_BUTTON_KEYCODE 0x14a
 #endif
 
+#ifndef TOUCHSCREEN_BUTTON_KEYCODE_MIN
+    #define TOUCHSCREEN_BUTTON_KEYCODE_MIN TOUCHSCREEN_BUTTON_KEYCODE
+    #define TOUCHSCREEN_BUTTON_KEYCODE_MAX TOUCHSCREEN_BUTTON_KEYCODE
+endif
+
 #define HEADPHONE_INSERTION_SWITCHCODE 0x02
 #define CHARGER_INSERTION_BUTTON 0x164
 
@@ -387,7 +397,9 @@ gboolean neod_buttonactions_input_dispat
                 }
             }
             else
-            if ( event.type == 1 && event.code == TOUCHSCREEN_BUTTON_KEYCODE )
+            if ( event.type == 1
+		 && event.code >= TOUCHSCREEN_BUTTON_KEYCODE_MIN
+		 && event.code <= TOUCHSCREEN_BUTTON_KEYCODE_MAX )
             {
                 if ( event.value == 1 ) /* pressed */
                 {



More information about the devel mailing list