From 064fa902c56f7cb421fa8071e58096248ea9c5ae Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Sat, 16 Sep 2017 23:51:25 +0200 Subject: [PATCH] zenxfi2: fix touchscreen bug Due to some undocumented behavior, the touchscreen was almost unusable in point mode. Now it's much better but still not very nice to use, probably it needs some filtering. Change-Id: Idc8a0214b09f268e6be907ee6ec3126cc0d88773 --- .../arm/imx233/creative-zenxfi2/button-zenxfi2.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/firmware/target/arm/imx233/creative-zenxfi2/button-zenxfi2.c b/firmware/target/arm/imx233/creative-zenxfi2/button-zenxfi2.c index bfefe2c13f..1021884d54 100644 --- a/firmware/target/arm/imx233/creative-zenxfi2/button-zenxfi2.c +++ b/firmware/target/arm/imx233/creative-zenxfi2/button-zenxfi2.c @@ -82,7 +82,7 @@ void button_init_device(void) imx233_button_init(); } -static int touch_to_pixels(int *val_x, int *val_y) +static void fix_pixels(int *val_x, int *val_y) { short x,y; @@ -101,9 +101,7 @@ static int touch_to_pixels(int *val_x, int *val_y) y = MAX(0, MIN(y, LCD_HEIGHT - 1)); *val_x = x; - *val_y = y; - - return (x<<16)|y; + *val_y = y;; } void touchscreen_enable_device(bool en) @@ -114,11 +112,10 @@ void touchscreen_enable_device(bool en) static int touchscreen_read_device(int *data) { int x, y; - if(!imx233_touchscreen_get_touch(&x, &y)) - return 0; - if(data) - *data = touch_to_pixels(&x, &y); - return touchscreen_to_pixels(x, y, data); + bool touch = imx233_touchscreen_get_touch(&x, &y); + fix_pixels(&x, &y); + int btns = touchscreen_to_pixels(x, y, data); + return touch ? btns : 0; } int button_read_device(int *data)