summaryrefslogtreecommitdiff
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
parent65f1a94a08793ea99386a0cb69cf3151e20cacbe (diff)
downloadrockbox-2f3e0fbcd05c13cf9faffa92773e7e4390ba0ab7.tar.gz
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
-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 @@
26#include "string.h" 26#include "string.h"
27#include "logf.h" 27#include "logf.h"
28 28
29/* Size of the 'dead zone' around each 3x3 button */
30#define BUTTON_MARGIN_X LCD_WIDTH * 0.03
31#define BUTTON_MARGIN_Y LCD_HEIGHT * 0.03
32
29static enum touchscreen_mode current_mode = TOUCHSCREEN_POINT; 33static enum touchscreen_mode current_mode = TOUCHSCREEN_POINT;
30static const int touchscreen_buttons[3][3] = 34static const int touchscreen_buttons[3][3] =
31{ 35{
@@ -121,9 +125,32 @@ int touchscreen_to_pixels(int x, int y, int *data)
121 125
122 map_pixels(&x, &y); 126 map_pixels(&x, &y);
123 127
124 if(current_mode == TOUCHSCREEN_BUTTON) 128 if (current_mode == TOUCHSCREEN_BUTTON)
125 return touchscreen_buttons[y / (LCD_HEIGHT/3)] 129 {
126 [x / (LCD_WIDTH/3) ]; 130 int column = 0, row = 0;
131
132 if (x < LCD_WIDTH/3 - BUTTON_MARGIN_X)
133 column = 0;
134 else if (x > LCD_WIDTH/3 + BUTTON_MARGIN_X &&
135 x < 2*LCD_WIDTH/3 - BUTTON_MARGIN_X)
136 column = 1;
137 else if (x > 2*LCD_WIDTH/3 + BUTTON_MARGIN_X)
138 column = 2;
139 else
140 return BUTTON_NONE;
141
142 if (y < LCD_HEIGHT/3 - BUTTON_MARGIN_Y)
143 row = 0;
144 else if (y > LCD_HEIGHT/3 + BUTTON_MARGIN_Y &&
145 y < 2*LCD_HEIGHT/3 - BUTTON_MARGIN_Y)
146 row = 1;
147 else if (y > 2*LCD_HEIGHT/3 + BUTTON_MARGIN_Y)
148 row = 2;
149 else
150 return BUTTON_NONE;
151
152 return touchscreen_buttons[row][column];
153 }
127 else 154 else
128 { 155 {
129 *data = (x << 16 | y); 156 *data = (x << 16 | y);