diff options
Diffstat (limited to 'firmware/target/arm/tcc780x/cowond2')
-rw-r--r-- | firmware/target/arm/tcc780x/cowond2/button-cowond2.c | 37 |
1 files changed, 4 insertions, 33 deletions
diff --git a/firmware/target/arm/tcc780x/cowond2/button-cowond2.c b/firmware/target/arm/tcc780x/cowond2/button-cowond2.c index 9449bcdf30..12eb88907a 100644 --- a/firmware/target/arm/tcc780x/cowond2/button-cowond2.c +++ b/firmware/target/arm/tcc780x/cowond2/button-cowond2.c | |||
@@ -25,31 +25,13 @@ | |||
25 | #include "adc.h" | 25 | #include "adc.h" |
26 | #include "pcf50606.h" | 26 | #include "pcf50606.h" |
27 | #include "backlight.h" | 27 | #include "backlight.h" |
28 | #include "touchscreen.h" | ||
28 | 29 | ||
29 | #define TOUCH_MARGIN 8 | 30 | #define TOUCH_MARGIN 8 |
30 | 31 | ||
31 | static enum touchscreen_mode current_mode = TOUCHSCREEN_POINT; | ||
32 | |||
33 | static short last_x, last_y; | 32 | static short last_x, last_y; |
34 | static bool touch_available = false; | 33 | static bool touch_available = false; |
35 | 34 | ||
36 | static int touchscreen_buttons[3][3] = | ||
37 | { | ||
38 | {BUTTON_TOPLEFT, BUTTON_TOPMIDDLE, BUTTON_TOPRIGHT}, | ||
39 | {BUTTON_MIDLEFT, BUTTON_CENTER, BUTTON_MIDRIGHT}, | ||
40 | {BUTTON_BOTTOMLEFT, BUTTON_BOTTOMMIDDLE, BUTTON_BOTTOMRIGHT}, | ||
41 | }; | ||
42 | |||
43 | void touchscreen_set_mode(enum touchscreen_mode mode) | ||
44 | { | ||
45 | current_mode = mode; | ||
46 | } | ||
47 | |||
48 | enum touchscreen_mode touchscreen_get_mode(void) | ||
49 | { | ||
50 | return current_mode; | ||
51 | } | ||
52 | |||
53 | void button_set_touch_available(void) | 35 | void button_set_touch_available(void) |
54 | { | 36 | { |
55 | touch_available = true; | 37 | touch_available = true; |
@@ -186,20 +168,9 @@ int button_read_device(int *data) | |||
186 | last_x = x; | 168 | last_x = x; |
187 | last_y = y; | 169 | last_y = y; |
188 | *data = touch_to_pixels(x, y); | 170 | *data = touch_to_pixels(x, y); |
189 | switch (current_mode) | 171 | btn |= touchscreen_to_pixels((*data&0xffff0000)>>16, |
190 | { | 172 | (*data&0x0000ffff), |
191 | case TOUCHSCREEN_POINT: | 173 | data); |
192 | btn |= BUTTON_TOUCHSCREEN; | ||
193 | break; | ||
194 | case TOUCHSCREEN_BUTTON: | ||
195 | { | ||
196 | int px_x = (*data&0xffff0000)>>16; | ||
197 | int px_y = (*data&0x0000ffff); | ||
198 | btn |= touchscreen_buttons[px_y/(LCD_HEIGHT/3)] | ||
199 | [px_x/(LCD_WIDTH/3)]; | ||
200 | break; | ||
201 | } | ||
202 | } | ||
203 | } | 174 | } |
204 | last_touch = current_tick; | 175 | last_touch = current_tick; |
205 | touch_available = false; | 176 | touch_available = false; |