diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-12-01 18:25:42 +0000 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2014-09-08 11:21:54 +0200 |
commit | 8146b40e73bb999001787fbf414c96acf5dce2a8 (patch) | |
tree | e3a1b2f951fd439c71d82e387d04df10d926b4e9 | |
parent | 847106cdb20a0297dc9a10f212f0e3c8e6f3d58c (diff) | |
download | rockbox-8146b40e73bb999001787fbf414c96acf5dce2a8.tar.gz rockbox-8146b40e73bb999001787fbf414c96acf5dce2a8.zip |
Fuze+: add a configurable deadzone area for touchpad buttons
To stop erroneous button presses, allow users to add a deadzone between
the button via the Settings > General > System menu > Touch Dead Zone.
The configuration was chosen this way: the touchpad has the same DPI
in both direction so the setting applies the same on both the X and Y
axis. The setting ranges from 0 to 100 and is internally multiplied by 2
giving a maximum deadzone of 2*100 = 200 around each button, which
account for 400 total (once around each button), effectively reducing
each virtual button from 1000x600 to 600x200 when using the maximum value.
Change-Id: I8683c63d2950200eb32d1dda0a00bbd92d83d5be
Reviewed-on: http://gerrit.rockbox.org/677
Reviewed-by: Benjamin Brown <foolshperson@gmail.com>
Tested: Benjamin Brown <foolshperson@gmail.com>
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
-rw-r--r-- | apps/features.txt | 4 | ||||
-rw-r--r-- | apps/lang/english-us.lang | 17 | ||||
-rw-r--r-- | apps/lang/english.lang | 17 | ||||
-rw-r--r-- | apps/menus/settings_menu.c | 7 | ||||
-rw-r--r-- | apps/settings.c | 4 | ||||
-rw-r--r-- | apps/settings.h | 4 | ||||
-rw-r--r-- | apps/settings_list.c | 8 | ||||
-rw-r--r-- | firmware/export/config/sansafuzeplus.h | 8 | ||||
-rw-r--r-- | firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c | 66 | ||||
-rw-r--r-- | firmware/target/arm/imx233/sansa-fuzeplus/button-target.h | 1 |
10 files changed, 108 insertions, 28 deletions
diff --git a/apps/features.txt b/apps/features.txt index 63f023458f..d9ca1a3ece 100644 --- a/apps/features.txt +++ b/apps/features.txt | |||
@@ -199,6 +199,10 @@ lineout_poweroff | |||
199 | touchscreen | 199 | touchscreen |
200 | #endif | 200 | #endif |
201 | 201 | ||
202 | #if defined(HAVE_TOUCHPAD_DEADZONE) | ||
203 | touchpad_deadzone | ||
204 | #endif | ||
205 | |||
202 | #if defined(HAVE_IMX233_CODEC) || defined(HAVE_WM8750) || defined(HAVE_WM8978) | 206 | #if defined(HAVE_IMX233_CODEC) || defined(HAVE_WM8750) || defined(HAVE_WM8978) |
203 | depth_3d | 207 | depth_3d |
204 | #endif | 208 | #endif |
diff --git a/apps/lang/english-us.lang b/apps/lang/english-us.lang index a6549dafd5..4a316cedca 100644 --- a/apps/lang/english-us.lang +++ b/apps/lang/english-us.lang | |||
@@ -10606,6 +10606,23 @@ | |||
10606 | </voice> | 10606 | </voice> |
10607 | </phrase> | 10607 | </phrase> |
10608 | <phrase> | 10608 | <phrase> |
10609 | id: LANG_DEADZONE | ||
10610 | desc: touchpad deadzone setting | ||
10611 | user: core | ||
10612 | <source> | ||
10613 | *: none | ||
10614 | sansafuzeplus: "Touchpad Dead Zone" | ||
10615 | </source> | ||
10616 | <dest> | ||
10617 | *: none | ||
10618 | sansafuzeplus: "Touchpad Dead Zone" | ||
10619 | </dest> | ||
10620 | <voice> | ||
10621 | *: none | ||
10622 | sansafuzeplus: "Touchpad Dead Zone" | ||
10623 | </voice> | ||
10624 | </phrase> | ||
10625 | <phrase> | ||
10609 | id: LANG_HIGH | 10626 | id: LANG_HIGH |
10610 | desc: in settings_menu | 10627 | desc: in settings_menu |
10611 | user: core | 10628 | user: core |
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 9914b160f1..113570522c 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -10693,6 +10693,23 @@ | |||
10693 | </voice> | 10693 | </voice> |
10694 | </phrase> | 10694 | </phrase> |
10695 | <phrase> | 10695 | <phrase> |
10696 | id: LANG_DEADZONE | ||
10697 | desc: touchpad deadzone setting | ||
10698 | user: core | ||
10699 | <source> | ||
10700 | *: none | ||
10701 | sansafuzeplus: "Touchpad Dead Zone" | ||
10702 | </source> | ||
10703 | <dest> | ||
10704 | *: none | ||
10705 | sansafuzeplus: "Touchpad Dead Zone" | ||
10706 | </dest> | ||
10707 | <voice> | ||
10708 | *: none | ||
10709 | sansafuzeplus: "Touchpad Dead Zone" | ||
10710 | </voice> | ||
10711 | </phrase> | ||
10712 | <phrase> | ||
10696 | id: LANG_HIGH | 10713 | id: LANG_HIGH |
10697 | desc: in settings_menu | 10714 | desc: in settings_menu |
10698 | user: core | 10715 | user: core |
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c index 0d2a7febf1..130f5be1a2 100644 --- a/apps/menus/settings_menu.c +++ b/apps/menus/settings_menu.c | |||
@@ -317,6 +317,10 @@ MENUITEM_SETTING(buttonlight_brightness, &global_settings.buttonlight_brightness | |||
317 | MENUITEM_SETTING(touchpad_sensitivity, &global_settings.touchpad_sensitivity, NULL); | 317 | MENUITEM_SETTING(touchpad_sensitivity, &global_settings.touchpad_sensitivity, NULL); |
318 | #endif | 318 | #endif |
319 | 319 | ||
320 | #ifdef HAVE_TOUCHPAD_DEADZONE | ||
321 | MENUITEM_SETTING(touchpad_deadzone, &global_settings.touchpad_deadzone, NULL); | ||
322 | #endif | ||
323 | |||
320 | #ifdef HAVE_QUICKSCREEN | 324 | #ifdef HAVE_QUICKSCREEN |
321 | MENUITEM_SETTING(shortcuts_replaces_quickscreen, &global_settings.shortcuts_replaces_qs, NULL); | 325 | MENUITEM_SETTING(shortcuts_replaces_quickscreen, &global_settings.shortcuts_replaces_qs, NULL); |
322 | #endif | 326 | #endif |
@@ -363,6 +367,9 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM), | |||
363 | #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING | 367 | #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING |
364 | &touchpad_sensitivity, | 368 | &touchpad_sensitivity, |
365 | #endif | 369 | #endif |
370 | #ifdef HAVE_TOUCHPAD_DEADZONE | ||
371 | &touchpad_deadzone, | ||
372 | #endif | ||
366 | #ifdef USB_ENABLE_HID | 373 | #ifdef USB_ENABLE_HID |
367 | &usb_hid, | 374 | &usb_hid, |
368 | &usb_keypad_mode, | 375 | &usb_keypad_mode, |
diff --git a/apps/settings.c b/apps/settings.c index 819924a421..515e7cb5f3 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -1061,6 +1061,10 @@ void settings_apply(bool read_disk) | |||
1061 | touchpad_set_sensitivity(global_settings.touchpad_sensitivity); | 1061 | touchpad_set_sensitivity(global_settings.touchpad_sensitivity); |
1062 | #endif | 1062 | #endif |
1063 | 1063 | ||
1064 | #ifdef HAVE_TOUCHPAD_DEADZONE | ||
1065 | touchpad_set_deadzone(global_settings.touchpad_deadzone); | ||
1066 | #endif | ||
1067 | |||
1064 | #ifdef HAVE_USB_CHARGING_ENABLE | 1068 | #ifdef HAVE_USB_CHARGING_ENABLE |
1065 | usb_charging_enable(global_settings.usb_charging); | 1069 | usb_charging_enable(global_settings.usb_charging); |
1066 | #endif | 1070 | #endif |
diff --git a/apps/settings.h b/apps/settings.h index 60658f6857..3ec5ee6207 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -460,6 +460,10 @@ struct user_settings | |||
460 | int touchpad_sensitivity; | 460 | int touchpad_sensitivity; |
461 | #endif | 461 | #endif |
462 | 462 | ||
463 | #ifdef HAVE_TOUCHPAD_DEADZONE | ||
464 | int touchpad_deadzone; | ||
465 | #endif | ||
466 | |||
463 | int pause_rewind; /* time in s to rewind when pausing */ | 467 | int pause_rewind; /* time in s to rewind when pausing */ |
464 | #ifdef HAVE_HEADPHONE_DETECTION | 468 | #ifdef HAVE_HEADPHONE_DETECTION |
465 | int unplug_mode; /* pause on headphone unplug */ | 469 | int unplug_mode; /* pause on headphone unplug */ |
diff --git a/apps/settings_list.c b/apps/settings_list.c index 53acb78d98..cddc062d40 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c | |||
@@ -2024,6 +2024,14 @@ const struct settings_list settings[] = { | |||
2024 | ID2P(LANG_NORMAL), ID2P(LANG_HIGH)), | 2024 | ID2P(LANG_NORMAL), ID2P(LANG_HIGH)), |
2025 | #endif /* boolean or analogig values */ | 2025 | #endif /* boolean or analogig values */ |
2026 | #endif /* HAVE_TOUCHPAD_SENSITIVITY_SETTING */ | 2026 | #endif /* HAVE_TOUCHPAD_SENSITIVITY_SETTING */ |
2027 | |||
2028 | #ifdef HAVE_TOUCHPAD_DEADZONE | ||
2029 | INT_SETTING(F_NO_WRAP, touchpad_deadzone, LANG_DEADZONE, | ||
2030 | DEFAULT_TOUCHPAD_DEADZONE_SETTING, "touchpad deadzone", UNIT_INT, | ||
2031 | MIN_TOUCHPAD_DEADSPACE_SETTING, MAX_TOUCHPAD_DEADSPACE_SETTING, 1, | ||
2032 | NULL, NULL, touchpad_set_deadzone), | ||
2033 | #endif | ||
2034 | |||
2027 | #ifdef HAVE_QUICKSCREEN | 2035 | #ifdef HAVE_QUICKSCREEN |
2028 | CUSTOM_SETTING(0, qs_items[QUICKSCREEN_TOP], LANG_TOP_QS_ITEM, | 2036 | CUSTOM_SETTING(0, qs_items[QUICKSCREEN_TOP], LANG_TOP_QS_ITEM, |
2029 | NULL, "qs top", | 2037 | NULL, "qs top", |
diff --git a/firmware/export/config/sansafuzeplus.h b/firmware/export/config/sansafuzeplus.h index c6f30ab00e..270060d594 100644 --- a/firmware/export/config/sansafuzeplus.h +++ b/firmware/export/config/sansafuzeplus.h | |||
@@ -80,6 +80,14 @@ | |||
80 | #define MAX_TOUCHPAD_SENSITIVITY_SETTING 25 | 80 | #define MAX_TOUCHPAD_SENSITIVITY_SETTING 25 |
81 | #define DEFAULT_TOUCHPAD_SENSITIVITY_SETTING 13 | 81 | #define DEFAULT_TOUCHPAD_SENSITIVITY_SETTING 13 |
82 | 82 | ||
83 | /* Define this to enable dead zone on touchpad */ | ||
84 | #ifndef SIMULATOR | ||
85 | #define HAVE_TOUCHPAD_DEADZONE | ||
86 | #define DEFAULT_TOUCHPAD_DEADZONE_SETTING 30 | ||
87 | #define MIN_TOUCHPAD_DEADSPACE_SETTING 0 | ||
88 | #define MAX_TOUCHPAD_DEADSPACE_SETTING 100 | ||
89 | #endif | ||
90 | |||
83 | /* Define this to enable morse code input */ | 91 | /* Define this to enable morse code input */ |
84 | #define HAVE_MORSE_INPUT | 92 | #define HAVE_MORSE_INPUT |
85 | 93 | ||
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c index f4166d0c2c..ea4aa083e5 100644 --- a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c +++ b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c | |||
@@ -192,33 +192,22 @@ bool button_debug_screen(void) | |||
192 | return true; | 192 | return true; |
193 | } | 193 | } |
194 | 194 | ||
195 | struct button_area_t | 195 | /* we emulate a 3x3 grid, this gives the button mapping */ |
196 | int button_mapping[3][3] = | ||
196 | { | 197 | { |
197 | /* define a rectangle region */ | 198 | {BUTTON_BOTTOMLEFT, BUTTON_LEFT, BUTTON_BACK}, |
198 | int lx, ly; | 199 | {BUTTON_DOWN, BUTTON_SELECT, BUTTON_UP}, |
199 | int rx, ry; | 200 | {BUTTON_BOTTOMRIGHT, BUTTON_RIGHT, BUTTON_PLAYPAUSE}, |
200 | int button; | ||
201 | }; | ||
202 | |||
203 | static struct button_area_t button_areas[] = | ||
204 | { | ||
205 | {1003, 658, 2006, 1316, BUTTON_SELECT}, | ||
206 | {0, 658, 1003, 1316, BUTTON_LEFT}, | ||
207 | {2006, 658, 3009, 1316, BUTTON_RIGHT}, | ||
208 | {1003, 0 , 2006, 658, BUTTON_DOWN}, | ||
209 | {1003, 1316, 2006, 1974, BUTTON_UP}, | ||
210 | {2006, 1316, 3009, 1974, BUTTON_PLAYPAUSE}, | ||
211 | {0, 1316, 1003, 1974, BUTTON_BACK}, | ||
212 | {0, 0 , 1003, 658, BUTTON_BOTTOMLEFT}, | ||
213 | {2006, 0 , 3009, 658, BUTTON_BOTTOMRIGHT}, | ||
214 | {0, 0, 0, 0, 0}, | ||
215 | }; | 201 | }; |
216 | 202 | ||
217 | #define RMI_INTERRUPT 1 | 203 | #define RMI_INTERRUPT 1 |
218 | #define RMI_SET_SENSITIVITY 2 | 204 | #define RMI_SET_SENSITIVITY 2 |
219 | #define RMI_SET_SLEEP_MODE 3 | 205 | #define RMI_SET_SLEEP_MODE 3 |
220 | /* timeout before lowering touchpad power from lack of activity */ | 206 | /* timeout before lowering touchpad power from lack of activity */ |
221 | #define ACTIVITY_TMO (5 * HZ) | 207 | #define ACTIVITY_TMO (5 * HZ) |
208 | #define TOUCHPAD_WIDTH 3010 | ||
209 | #define TOUCHPAD_HEIGHT 1975 | ||
210 | #define DEADZONE_MULTIPLIER 2 /* deadzone multiplier */ | ||
222 | 211 | ||
223 | static int touchpad_btns = 0; | 212 | static int touchpad_btns = 0; |
224 | static long rmi_stack [DEFAULT_STACK_SIZE/sizeof(long)]; | 213 | static long rmi_stack [DEFAULT_STACK_SIZE/sizeof(long)]; |
@@ -226,17 +215,38 @@ static const char rmi_thread_name[] = "rmi"; | |||
226 | static struct event_queue rmi_queue; | 215 | static struct event_queue rmi_queue; |
227 | static unsigned last_activity = 0; | 216 | static unsigned last_activity = 0; |
228 | static bool t_enable = true; | 217 | static bool t_enable = true; |
218 | static int deadzone; | ||
219 | |||
220 | /* Ignore deadzone function. If outside of the pad, project to border. */ | ||
221 | static int find_button_no_deadzone(int x, int y) | ||
222 | { | ||
223 | /* compute grid coordinate */ | ||
224 | int gx = MAX(MIN(x * 3 / TOUCHPAD_WIDTH, 2), 0); | ||
225 | int gy = MAX(MIN(y * 3 / TOUCHPAD_HEIGHT, 2), 0); | ||
226 | |||
227 | return button_mapping[gx][gy]; | ||
228 | } | ||
229 | 229 | ||
230 | static int find_button(int x, int y) | 230 | static int find_button(int x, int y) |
231 | { | 231 | { |
232 | struct button_area_t *area = button_areas; | 232 | /* find button ignoring deadzones */ |
233 | for(; area->button != 0; area++) | 233 | int btn = find_button_no_deadzone(x, y); |
234 | { | 234 | /* To check if we are in a deadzone, we try to shift the coordinates |
235 | if(area->lx <= x && x <= area->rx && | 235 | * and see if we get the same button. Not that we do not want to apply |
236 | area->ly <= y && y <= area->ry) | 236 | * the deadzone in the borders ! The code works even in the borders because |
237 | return area->button; | 237 | * the find_button_no_deadzone() project out-of-bound coordinates to the |
238 | } | 238 | * borders */ |
239 | return 0; | 239 | if(find_button_no_deadzone(x + deadzone, y) != btn || |
240 | find_button_no_deadzone(x - deadzone, y) != btn || | ||
241 | find_button_no_deadzone(x, y + deadzone) != btn || | ||
242 | find_button_no_deadzone(x, y - deadzone) != btn) | ||
243 | return 0; | ||
244 | return btn; | ||
245 | } | ||
246 | |||
247 | void touchpad_set_deadzone(int touchpad_deadzone) | ||
248 | { | ||
249 | deadzone = touchpad_deadzone * DEADZONE_MULTIPLIER; | ||
240 | } | 250 | } |
241 | 251 | ||
242 | static int touchpad_read_device(void) | 252 | static int touchpad_read_device(void) |
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h b/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h index ce5ffe464a..7a4396e0f2 100644 --- a/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h +++ b/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <stdbool.h> | 24 | #include <stdbool.h> |
25 | bool button_debug_screen(void); | 25 | bool button_debug_screen(void); |
26 | void touchpad_set_sensitivity(int level); | 26 | void touchpad_set_sensitivity(int level); |
27 | void touchpad_set_deadzone(int touchpad_deadzone); | ||
27 | void touchpad_enable_device(bool en); | 28 | void touchpad_enable_device(bool en); |
28 | 29 | ||
29 | /* Main unit's buttons */ | 30 | /* Main unit's buttons */ |