summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorRob Purchase <shotofadds@rockbox.org>2009-09-26 17:33:36 +0000
committerRob Purchase <shotofadds@rockbox.org>2009-09-26 17:33:36 +0000
commit2f3e0fbcd05c13cf9faffa92773e7e4390ba0ab7 (patch)
treeb8622d436778a9d6ef9e17d41f00b731188ad04e /firmware
parent65f1a94a08793ea99386a0cb69cf3151e20cacbe (diff)
downloadrockbox-2f3e0fbcd05c13cf9faffa92773e7e4390ba0ab7.tar.gz
rockbox-2f3e0fbcd05c13cf9faffa92773e7e4390ba0ab7.tar.bz2
rockbox-2f3e0fbcd05c13cf9faffa92773e7e4390ba0ab7.zip
Add a few pixels "dead zone" between the touchscreen grid "buttons", to avoid jitter.
Flyspray: FS#10615 Author: Carsten Schreiter git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22843 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rwxr-xr-xfirmware/drivers/touchscreen.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/firmware/drivers/touchscreen.c b/firmware/drivers/touchscreen.c
index 002acf1236..bf63e488ec 100755
--- a/firmware/drivers/touchscreen.c
+++ b/firmware/drivers/touchscreen.c
@@ -26,6 +26,10 @@
#include "string.h"
#include "logf.h"
+/* Size of the 'dead zone' around each 3x3 button */
+#define BUTTON_MARGIN_X LCD_WIDTH * 0.03
+#define BUTTON_MARGIN_Y LCD_HEIGHT * 0.03
+
static enum touchscreen_mode current_mode = TOUCHSCREEN_POINT;
static const int touchscreen_buttons[3][3] =
{
@@ -121,9 +125,32 @@ int touchscreen_to_pixels(int x, int y, int *data)
map_pixels(&x, &y);
- if(current_mode == TOUCHSCREEN_BUTTON)
- return touchscreen_buttons[y / (LCD_HEIGHT/3)]
- [x / (LCD_WIDTH/3) ];
+ if (current_mode == TOUCHSCREEN_BUTTON)
+ {
+ int column = 0, row = 0;
+
+ if (x < LCD_WIDTH/3 - BUTTON_MARGIN_X)
+ column = 0;
+ else if (x > LCD_WIDTH/3 + BUTTON_MARGIN_X &&
+ x < 2*LCD_WIDTH/3 - BUTTON_MARGIN_X)
+ column = 1;
+ else if (x > 2*LCD_WIDTH/3 + BUTTON_MARGIN_X)
+ column = 2;
+ else
+ return BUTTON_NONE;
+
+ if (y < LCD_HEIGHT/3 - BUTTON_MARGIN_Y)
+ row = 0;
+ else if (y > LCD_HEIGHT/3 + BUTTON_MARGIN_Y &&
+ y < 2*LCD_HEIGHT/3 - BUTTON_MARGIN_Y)
+ row = 1;
+ else if (y > 2*LCD_HEIGHT/3 + BUTTON_MARGIN_Y)
+ row = 2;
+ else
+ return BUTTON_NONE;
+
+ return touchscreen_buttons[row][column];
+ }
else
{
*data = (x << 16 | y);