From 9b6d2ad786cff7045376ddaac2b20cbc858d355d Mon Sep 17 00:00:00 2001 From: Mathew Mrosko Date: Mon, 1 Feb 2010 16:32:30 -0800 Subject: [PATCH 3/3] Implement forced touch screen pen event proc entry This will require the "sender" to send a pen-down, then a pen-up by simply echoing a x&y coordinates (pen-down) then a set of 0s (pen-up) to the proc entry. Force a pen-down event with coordinates X=1000, Y=2000: echo 1000 2000 > /proc/chumby/touchscreen/coordinates Force a pen-up event: echo 0 0 > /proc/chumby/touchscreen/coordinates Implementation: This simply uses the input system functionality to send input events to whomever must be listening to the touchscreen. --- drivers/mfd/chumby-tsc2100.c | 61 +++++++++++++++++++++++++++++++++++++++++- 1 files changed, 60 insertions(+), 1 deletions(-) diff --git a/drivers/mfd/chumby-tsc2100.c b/drivers/mfd/chumby-tsc2100.c index d92cea4..c13ef09 100755 --- a/drivers/mfd/chumby-tsc2100.c +++ b/drivers/mfd/chumby-tsc2100.c @@ -2211,6 +2211,65 @@ static int proc_set_tson_cb( struct file* file, const char* buf, return count; } +static int proc_set_coords_cb( struct file* file, const char* buf, + unsigned long count, void* data ) +{ +// struct tsc2100_context* d = ( struct tsc2100_context* ) data; + struct tsc2100_context* tsc2100 = ( struct tsc2100_context* ) data; + int x = 0, y = 0, ret = 0; + + int len = count; + char string[32]; + + /* Copy only the amount of data we have on the stack to parse */ + if ( len > sizeof(string)-1 ) + len = sizeof(string)-1; + if ( copy_from_user( string, buf, len ) ) + return -EFAULT; + + string[len] = '\0'; + + /* + * Look for 2 digits... if we don't find 'em, we'll assume the + * data is crap and will end up sending a pen up since x and y + * will both still be set to 0. + */ + ret = sscanf( string, "%d %d", &x, &y ); + + if ( !ret ) + return count; + + if ( x == 0 && y == 0 ) + { + printk("pen up\n"); + input_report_abs(tsc2100->inputdevice, ABS_X, 0); + input_report_abs(tsc2100->inputdevice, ABS_Y, 0); + input_report_abs(tsc2100->inputdevice, ABS_PRESSURE, 0); + input_report_key(tsc2100->inputdevice, BTN_TOUCH, 0); + input_sync(tsc2100->inputdevice); + } + else + { + printk("pen down - set coordinates x=%d, y=%d\n", x, y); + /* + * In 'handle_pendown' the x and y are swapped when calling + * the touchscreen_report function depending on being an + * ironforge 3.8 version hardware. It appears this is not because + * the touchscreen report function requires them in a different + * order, but because the x and y values are reversed when + * calculating them from the scan data. Therefore, it seems we + * do not need to swap the x and y here based on if we are + * running on ironforge 3.7 or 3.8 hardware. + */ + input_report_abs(tsc2100->inputdevice, ABS_X, x); + input_report_abs(tsc2100->inputdevice, ABS_Y, y); + input_report_abs(tsc2100->inputdevice, ABS_PRESSURE, 0); + input_report_key(tsc2100->inputdevice, BTN_TOUCH, 1); + input_sync(tsc2100->inputdevice); + } + + return count; +} static int proc_get_coords_cb( char* buf, char** start, off_t offset, int count, int* eof, void* data ) @@ -3413,7 +3472,7 @@ static struct { } procfile[] = { /*0*/ { "temperature", CHUMBY_DIR, proc_get_temp_cb, NULL, 0 }, /*1*/ { "enable", TOUCHSCREEN_DIR, proc_get_tson_cb, proc_set_tson_cb, 0 }, -/*2*/ { "coordinates", TOUCHSCREEN_DIR, proc_get_coords_cb, NULL, 0 }, +/*2*/ { "coordinates", TOUCHSCREEN_DIR, proc_get_coords_cb, proc_set_coords_cb, 0 }, /*3*/ { "timer-interval", TOUCHSCREEN_DIR, proc_get_timer_interval_cb, proc_set_timer_interval_cb, 0 }, /*4*/ { "touchclick", TOUCHSCREEN_DIR, proc_get_touchclick_cb, proc_set_touchclick_cb, 0 }, /*5*/ { "mute", LEFTSPKR_DIR, proc_get_left_mute_cb, proc_set_left_mute_cb, 0 }, -- 1.6.6.GIT