diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-11-20 19:05:16 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-11-24 18:49:03 -0500 |
commit | 44acbc66291da6a8ade8571b73a10e34341a622b (patch) | |
tree | 226f9d9f971756f481455da082443f700bcfc786 /firmware/target/mips/ingenic_x1000/shanlingq1 | |
parent | b39acee3abd199d80b84c68ebfa7301b7e7a957e (diff) | |
download | rockbox-44acbc66291da6a8ade8571b73a10e34341a622b.tar.gz rockbox-44acbc66291da6a8ade8571b73a10e34341a622b.zip |
Shanling Q1: enable multi-touch reporting
The FT6x06 driver used for the Shanling Q1's touchscreen
has been extended to report more than one touch point. It
can also return the gesture detected by the controller,
but this doesn't seem to report anything useful on the Q1.
Multi-touch is only useful in 3x3 grid mode since the Rockbox
button API cannot report more than one touch point.
The FiiO M3K uses the same driver so it's been updated to the
multi-touch API, but functionality is unchanged.
Change-Id: I4de42f44808d6eb902e3da212d8f936b7a5042c7
Diffstat (limited to 'firmware/target/mips/ingenic_x1000/shanlingq1')
-rw-r--r-- | firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c | 83 |
1 files changed, 73 insertions, 10 deletions
diff --git a/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c b/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c index 27c49a7bd7..13b0cdd078 100644 --- a/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c +++ b/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c | |||
@@ -32,6 +32,11 @@ | |||
32 | #include "i2c-x1000.h" | 32 | #include "i2c-x1000.h" |
33 | #include <stdbool.h> | 33 | #include <stdbool.h> |
34 | 34 | ||
35 | #ifndef BOOTLOADER | ||
36 | # include "lcd.h" | ||
37 | # include "font.h" | ||
38 | #endif | ||
39 | |||
35 | /* Volume wheel rotation */ | 40 | /* Volume wheel rotation */ |
36 | static volatile int wheel_pos = 0; | 41 | static volatile int wheel_pos = 0; |
37 | 42 | ||
@@ -109,6 +114,7 @@ void button_init_device(void) | |||
109 | 114 | ||
110 | int button_read_device(int* data) | 115 | int button_read_device(int* data) |
111 | { | 116 | { |
117 | const struct ft6x06_point* point; | ||
112 | int r = 0; | 118 | int r = 0; |
113 | 119 | ||
114 | /* Read GPIO buttons, these are all active low */ | 120 | /* Read GPIO buttons, these are all active low */ |
@@ -138,16 +144,22 @@ int button_read_device(int* data) | |||
138 | reset_poweroff_timer(); | 144 | reset_poweroff_timer(); |
139 | } | 145 | } |
140 | 146 | ||
141 | /* Handle touchscreen | 147 | if(touchscreen_get_mode() == TOUCHSCREEN_POINT) { |
142 | * | 148 | /* Pointing mode can't use multitouch since we can only pass |
143 | * TODO: Support 2-point multitouch (useful for 3x3 grid mode) | 149 | * along coordinates for one touch event at a time */ |
144 | * TODO: Support simple gestures by converting them to fake buttons | 150 | point = &ft6x06_state.points[0]; |
145 | */ | 151 | int t = touchscreen_to_pixels(point->pos_x, point->pos_y, data); |
146 | int t = touchscreen_to_pixels(ft6x06_state.pos_x, ft6x06_state.pos_y, data); | 152 | if(point->event == FT6x06_EVT_PRESS || |
147 | if(ft6x06_state.event == FT6x06_EVT_PRESS || | 153 | point->event == FT6x06_EVT_CONTACT) |
148 | ft6x06_state.event == FT6x06_EVT_CONTACT) { | 154 | r |= t; |
149 | /* Only set the button bit if the screen is being touched. */ | 155 | } else { |
150 | r |= t; | 156 | /* 3x3 mode can have simultaneous 'button' presses via multitouch */ |
157 | for(int i = 0; i < ft6x06_state.nr_points; ++i) { | ||
158 | point = &ft6x06_state.points[i]; | ||
159 | if(point->event == FT6x06_EVT_PRESS || | ||
160 | point->event == FT6x06_EVT_CONTACT) | ||
161 | r |= touchscreen_to_pixels(point->pos_x, point->pos_y, NULL); | ||
162 | } | ||
151 | } | 163 | } |
152 | 164 | ||
153 | return r; | 165 | return r; |
@@ -193,3 +205,54 @@ void GPIOD03(void) | |||
193 | handle_wheel_irq(); | 205 | handle_wheel_irq(); |
194 | gpio_flip_edge_irq(GPIO_WHEEL2); | 206 | gpio_flip_edge_irq(GPIO_WHEEL2); |
195 | } | 207 | } |
208 | |||
209 | #ifndef BOOTLOADER | ||
210 | static int getbtn(void) | ||
211 | { | ||
212 | int btn; | ||
213 | do { | ||
214 | btn = button_get_w_tmo(1); | ||
215 | } while(btn & (BUTTON_REL|BUTTON_REPEAT)); | ||
216 | return btn; | ||
217 | } | ||
218 | |||
219 | bool dbg_shanlingq1_touchscreen(void) | ||
220 | { | ||
221 | /* definition of box used to represent the touchpad */ | ||
222 | const int pad_w = LCD_WIDTH; | ||
223 | const int pad_h = LCD_HEIGHT; | ||
224 | const int box_h = pad_h - SYSFONT_HEIGHT*5; | ||
225 | const int box_w = pad_w * box_h / pad_h; | ||
226 | const int box_x = (LCD_WIDTH - box_w) / 2; | ||
227 | const int box_y = SYSFONT_HEIGHT * 9 / 2; | ||
228 | |||
229 | bool draw_border = true; | ||
230 | |||
231 | do { | ||
232 | int line = 0; | ||
233 | lcd_clear_display(); | ||
234 | lcd_putsf(0, line++, "nr_points: %d gesture: %d", | ||
235 | ft6x06_state.nr_points, ft6x06_state.gesture); | ||
236 | |||
237 | /* draw touchpad box borders */ | ||
238 | if(draw_border) | ||
239 | lcd_drawrect(box_x, box_y, box_w, box_h); | ||
240 | |||
241 | for(int i = 0; i < ft6x06_state.nr_points; ++i) { | ||
242 | const struct ft6x06_point* point = &ft6x06_state.points[i]; | ||
243 | lcd_putsf(0, line++, "pt%d id:%d pos: %d,%d wgt: %d area:%d", | ||
244 | i, point->touch_id, point->pos_x, point->pos_y, | ||
245 | point->weight, point->area); | ||
246 | |||
247 | /* draw crosshair */ | ||
248 | int tx = box_x + point->pos_x * box_w / pad_w; | ||
249 | int ty = box_y + point->pos_y * box_h / pad_h; | ||
250 | lcd_hline(tx-2, tx+2, ty); | ||
251 | lcd_vline(tx, ty-2, ty+2); | ||
252 | } | ||
253 | |||
254 | lcd_update(); | ||
255 | } while(getbtn() != BUTTON_POWER); | ||
256 | return false; | ||
257 | } | ||
258 | #endif | ||