summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2008-12-31 21:02:56 +0000
committerBjörn Stenberg <bjorn@haxx.se>2008-12-31 21:02:56 +0000
commit9e3844db07e684365837ca5d5f9bcd4a2cb993a6 (patch)
tree7fde79118324291a685400ca133ec2705ea8d4af
parent5bf0cf59102f6a0fa812d7f60f954b5cc9ab834a (diff)
downloadrockbox-9e3844db07e684365837ca5d5f9bcd4a2cb993a6.tar.gz
rockbox-9e3844db07e684365837ca5d5f9bcd4a2cb993a6.zip
Updated Fuze button code. FS#9645 by Thomas Martitz.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19629 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/keymaps/keymap-fuze.c77
-rw-r--r--firmware/target/arm/as3525/clock-target.h2
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/button-fuze.c257
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/button-target.h11
4 files changed, 228 insertions, 119 deletions
diff --git a/apps/keymaps/keymap-fuze.c b/apps/keymaps/keymap-fuze.c
index 7c84833b85..0f34c6bfee 100644
--- a/apps/keymaps/keymap-fuze.c
+++ b/apps/keymaps/keymap-fuze.c
@@ -19,7 +19,7 @@
19 * KIND, either express or implied. 19 * KIND, either express or implied.
20 * 20 *
21 ****************************************************************************/ 21 ****************************************************************************/
22/* Button Code Definitions for Sandisk Sansa Fuze target, based on e200 keymap*/ 22/* Button Code Definitions for Sandisk Fuze target */
23 23
24#include "config.h" 24#include "config.h"
25#include "action.h" 25#include "action.h"
@@ -40,13 +40,15 @@ static const struct button_mapping button_context_standard[] = {
40 { ACTION_STD_NEXT, BUTTON_SCROLL_FWD, BUTTON_NONE }, 40 { ACTION_STD_NEXT, BUTTON_SCROLL_FWD, BUTTON_NONE },
41 { ACTION_STD_NEXTREPEAT, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE }, 41 { ACTION_STD_NEXTREPEAT, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE },
42 42
43 { ACTION_STD_MENU, BUTTON_HOME|BUTTON_REL, BUTTON_DOWN }, 43 { ACTION_STD_MENU, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN },
44 { ACTION_STD_REC, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE },
44 45
45 { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, 46 { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
46 { ACTION_STD_OK, BUTTON_RIGHT, BUTTON_NONE }, 47 { ACTION_STD_OK, BUTTON_RIGHT, BUTTON_NONE },
47 { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE }, 48 { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE },
49 { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE },
48 50
49 { ACTION_STD_QUICKSCREEN, BUTTON_HOME|BUTTON_REPEAT, BUTTON_HOME }, 51 { ACTION_STD_QUICKSCREEN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN },
50 { ACTION_STD_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, 52 { ACTION_STD_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT },
51 53
52 LAST_ITEM_IN_LIST 54 LAST_ITEM_IN_LIST
@@ -65,9 +67,9 @@ static const struct button_mapping button_context_wps[] = {
65 { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, 67 { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
66 { ACTION_WPS_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT }, 68 { ACTION_WPS_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT },
67 69
68 { ACTION_WPS_ABSETB_NEXTDIR, BUTTON_HOME|BUTTON_RIGHT, BUTTON_HOME }, 70 { ACTION_WPS_ABSETB_NEXTDIR, BUTTON_POWER|BUTTON_RIGHT, BUTTON_POWER },
69 { ACTION_WPS_ABSETA_PREVDIR, BUTTON_HOME|BUTTON_LEFT, BUTTON_HOME }, 71 { ACTION_WPS_ABSETA_PREVDIR, BUTTON_POWER|BUTTON_LEFT, BUTTON_POWER },
70 { ACTION_WPS_ABRESET, BUTTON_HOME|BUTTON_UP, BUTTON_HOME }, 72 { ACTION_WPS_ABRESET, BUTTON_POWER|BUTTON_UP, BUTTON_POWER },
71 73
72 { ACTION_WPS_VOLUP, BUTTON_SCROLL_FWD, BUTTON_NONE }, 74 { ACTION_WPS_VOLUP, BUTTON_SCROLL_FWD, BUTTON_NONE },
73 { ACTION_WPS_VOLUP, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE }, 75 { ACTION_WPS_VOLUP, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE },
@@ -77,35 +79,36 @@ static const struct button_mapping button_context_wps[] = {
77 { ACTION_WPS_BROWSE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, 79 { ACTION_WPS_BROWSE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
78 80
79 { ACTION_WPS_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, 81 { ACTION_WPS_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT },
80 { ACTION_WPS_QUICKSCREEN, BUTTON_HOME|BUTTON_REPEAT, BUTTON_HOME }, 82 { ACTION_WPS_QUICKSCREEN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN },
81 83
82 { ACTION_WPS_MENU, BUTTON_HOME|BUTTON_REL, BUTTON_HOME }, 84 { ACTION_WPS_MENU, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN },
85 { ACTION_WPS_REC, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE },
83 86
84 { ACTION_WPS_PITCHSCREEN, BUTTON_HOME|BUTTON_UP, BUTTON_HOME }, 87 { ACTION_WPS_PITCHSCREEN, BUTTON_SELECT|BUTTON_UP, BUTTON_SELECT },
85 { ACTION_WPS_ID3SCREEN, BUTTON_HOME|BUTTON_DOWN, BUTTON_HOME }, 88 { ACTION_WPS_ID3SCREEN, BUTTON_SELECT|BUTTON_DOWN, BUTTON_SELECT },
86 89
87 LAST_ITEM_IN_LIST 90 LAST_ITEM_IN_LIST
88}; /* button_context_wps */ 91}; /* button_context_wps */
89 92
90static const struct button_mapping button_context_settings[] = { 93static const struct button_mapping button_context_settings[] = {
91 { ACTION_STD_CANCEL, BUTTON_HOME, BUTTON_NONE }, 94 { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE },
92 { ACTION_SETTINGS_INC, BUTTON_SCROLL_FWD, BUTTON_NONE }, 95 { ACTION_SETTINGS_INC, BUTTON_SCROLL_FWD, BUTTON_NONE },
93 { ACTION_SETTINGS_INCREPEAT,BUTTON_SCROLL_FWD|BUTTON_REPEAT,BUTTON_NONE }, 96 { ACTION_SETTINGS_INCREPEAT,BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE },
94 { ACTION_SETTINGS_DEC, BUTTON_SCROLL_BACK, BUTTON_NONE }, 97 { ACTION_SETTINGS_DEC, BUTTON_SCROLL_BACK, BUTTON_NONE },
95 { ACTION_SETTINGS_DECREPEAT,BUTTON_SCROLL_BACK|BUTTON_REPEAT,BUTTON_NONE }, 98 { ACTION_SETTINGS_DECREPEAT,BUTTON_SCROLL_BACK|BUTTON_REPEAT, BUTTON_NONE },
96 99
97 { ACTION_STD_PREV, BUTTON_LEFT, BUTTON_NONE }, 100 { ACTION_STD_PREV, BUTTON_LEFT, BUTTON_NONE },
98 { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, 101 { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
99 { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE }, 102 { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE },
100 { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, 103 { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
101 { ACTION_SETTINGS_RESET, BUTTON_SELECT, BUTTON_NONE }, 104 { ACTION_SETTINGS_RESET, BUTTON_SELECT, BUTTON_NONE },
102 105
103 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD), 106 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
104}; /* button_context_settings */ 107}; /* button_context_settings */
105 108
106static const struct button_mapping button_context_list[] = { 109static const struct button_mapping button_context_list[] = {
107 { ACTION_LISTTREE_PGUP, BUTTON_HOME|BUTTON_SCROLL_BACK, BUTTON_HOME }, 110 { ACTION_LISTTREE_PGUP, BUTTON_HOME|BUTTON_SCROLL_BACK, BUTTON_HOME },
108 { ACTION_LISTTREE_PGDOWN, BUTTON_HOME|BUTTON_SCROLL_FWD, BUTTON_HOME }, 111 { ACTION_LISTTREE_PGDOWN, BUTTON_HOME|BUTTON_SCROLL_FWD, BUTTON_HOME },
109 112
110 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) 113 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
111}; /* button_context_list */ 114}; /* button_context_list */
@@ -149,7 +152,7 @@ static const struct button_mapping button_context_yesno[] = {
149 152
150static const struct button_mapping button_context_quickscreen[] = { 153static const struct button_mapping button_context_quickscreen[] = {
151 { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE }, 154 { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE },
152 { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_NONE }, 155 { ACTION_STD_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_NONE },
153 { ACTION_QS_DOWNINV, BUTTON_UP|BUTTON_REL, BUTTON_NONE }, 156 { ACTION_QS_DOWNINV, BUTTON_UP|BUTTON_REL, BUTTON_NONE },
154 { ACTION_QS_DOWNINV, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, 157 { ACTION_QS_DOWNINV, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
155 { ACTION_QS_DOWN, BUTTON_DOWN|BUTTON_REL, BUTTON_NONE }, 158 { ACTION_QS_DOWN, BUTTON_DOWN|BUTTON_REL, BUTTON_NONE },
@@ -165,7 +168,7 @@ static const struct button_mapping button_context_quickscreen[] = {
165static const struct button_mapping button_context_settings_right_is_inc[] = { 168static const struct button_mapping button_context_settings_right_is_inc[] = {
166 { ACTION_SETTINGS_INC, BUTTON_SCROLL_FWD, BUTTON_NONE }, 169 { ACTION_SETTINGS_INC, BUTTON_SCROLL_FWD, BUTTON_NONE },
167 { ACTION_SETTINGS_INCREPEAT, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE }, 170 { ACTION_SETTINGS_INCREPEAT, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE },
168 { ACTION_SETTINGS_DEC, BUTTON_SCROLL_BACK, BUTTON_NONE }, 171 { ACTION_SETTINGS_DEC, BUTTON_SCROLL_BACK, BUTTON_NONE },
169 { ACTION_SETTINGS_DECREPEAT, BUTTON_SCROLL_BACK|BUTTON_REPEAT,BUTTON_NONE }, 172 { ACTION_SETTINGS_DECREPEAT, BUTTON_SCROLL_BACK|BUTTON_REPEAT,BUTTON_NONE },
170 173
171 { ACTION_STD_PREV, BUTTON_UP|BUTTON_REL, BUTTON_NONE }, 174 { ACTION_STD_PREV, BUTTON_UP|BUTTON_REL, BUTTON_NONE },
@@ -175,8 +178,8 @@ static const struct button_mapping button_context_settings_right_is_inc[] = {
175 { ACTION_NONE, BUTTON_SELECT, BUTTON_NONE }, 178 { ACTION_NONE, BUTTON_SELECT, BUTTON_NONE },
176 { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE }, 179 { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE },
177 { ACTION_NONE, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT }, 180 { ACTION_NONE, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
178 { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE }, 181 { ACTION_NONE, BUTTON_POWER, BUTTON_NONE },
179 { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE }, 182 { ACTION_STD_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_NONE },
180 183
181 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD), 184 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
182}; /* button_context_settings_right_is_inc */ 185}; /* button_context_settings_right_is_inc */
@@ -199,9 +202,9 @@ static const struct button_mapping button_context_pitchscreen[] = {
199 { ACTION_PS_NUDGE_LEFTOFF, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE }, 202 { ACTION_PS_NUDGE_LEFTOFF, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE },
200 { ACTION_PS_NUDGE_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, 203 { ACTION_PS_NUDGE_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
201 { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE }, 204 { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE },
202 { ACTION_PS_TOGGLE_MODE, BUTTON_DOWN, BUTTON_NONE }, 205 { ACTION_PS_TOGGLE_MODE, BUTTON_HOME, BUTTON_NONE },
203 { ACTION_PS_RESET, BUTTON_SELECT, BUTTON_NONE }, 206 { ACTION_PS_RESET, BUTTON_SELECT, BUTTON_NONE },
204 { ACTION_PS_EXIT, BUTTON_HOME, BUTTON_NONE }, 207 { ACTION_PS_EXIT, BUTTON_POWER, BUTTON_NONE },
205 { ACTION_PS_EXIT, BUTTON_UP, BUTTON_NONE }, 208 { ACTION_PS_EXIT, BUTTON_UP, BUTTON_NONE },
206 209
207 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD), 210 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
@@ -210,8 +213,8 @@ static const struct button_mapping button_context_pitchscreen[] = {
210/** Recording Screen **/ 213/** Recording Screen **/
211static const struct button_mapping button_context_recscreen[] = { 214static const struct button_mapping button_context_recscreen[] = {
212 { ACTION_REC_PAUSE, BUTTON_UP|BUTTON_REL, BUTTON_UP }, 215 { ACTION_REC_PAUSE, BUTTON_UP|BUTTON_REL, BUTTON_UP },
213 { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME }, 216 { ACTION_STD_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
214 { ACTION_REC_NEWFILE, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN }, 217 { ACTION_REC_NEWFILE, BUTTON_HOME|BUTTON_REL, BUTTON_HOME },
215 { ACTION_STD_MENU, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT}, 218 { ACTION_STD_MENU, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT},
216 { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE }, 219 { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE },
217 { ACTION_SETTINGS_INCREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, 220 { ACTION_SETTINGS_INCREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
@@ -221,7 +224,7 @@ static const struct button_mapping button_context_recscreen[] = {
221 { ACTION_STD_PREV, BUTTON_SCROLL_BACK|BUTTON_REPEAT, BUTTON_NONE }, 224 { ACTION_STD_PREV, BUTTON_SCROLL_BACK|BUTTON_REPEAT, BUTTON_NONE },
222 { ACTION_STD_NEXT, BUTTON_SCROLL_FWD, BUTTON_NONE }, 225 { ACTION_STD_NEXT, BUTTON_SCROLL_FWD, BUTTON_NONE },
223 { ACTION_STD_NEXT, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE }, 226 { ACTION_STD_NEXT, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE },
224 { ACTION_NONE, BUTTON_DOWN, BUTTON_DOWN }, 227 { ACTION_NONE, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN },
225 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) 228 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
226}; /* button_context_recscreen */ 229}; /* button_context_recscreen */
227 230
@@ -242,23 +245,21 @@ static const struct button_mapping button_context_keyboard[] = {
242 { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, 245 { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
243 { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, 246 { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
244 247
245/* 248 { ACTION_KBD_CURSOR_LEFT, BUTTON_HOME|BUTTON_LEFT, BUTTON_NONE },
246 { ACTION_KBD_CURSOR_LEFT, BUTTON_REC|BUTTON_LEFT, BUTTON_NONE }, 249 { ACTION_KBD_CURSOR_LEFT, BUTTON_HOME|BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
247 { ACTION_KBD_CURSOR_LEFT, BUTTON_REC|BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, 250 { ACTION_KBD_CURSOR_RIGHT, BUTTON_HOME|BUTTON_RIGHT, BUTTON_NONE },
248 { ACTION_KBD_CURSOR_RIGHT, BUTTON_REC|BUTTON_RIGHT, BUTTON_NONE }, 251 { ACTION_KBD_CURSOR_RIGHT, BUTTON_HOME|BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
249 { ACTION_KBD_CURSOR_RIGHT, BUTTON_REC|BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
250*/
251 252
252 { ACTION_KBD_UP, BUTTON_SCROLL_BACK, BUTTON_NONE }, 253 { ACTION_KBD_UP, BUTTON_SCROLL_BACK, BUTTON_NONE },
253 { ACTION_KBD_UP, BUTTON_SCROLL_BACK|BUTTON_REPEAT, BUTTON_NONE }, 254 { ACTION_KBD_UP, BUTTON_SCROLL_BACK|BUTTON_REPEAT, BUTTON_NONE },
254 { ACTION_KBD_DOWN, BUTTON_SCROLL_FWD, BUTTON_NONE }, 255 { ACTION_KBD_DOWN, BUTTON_SCROLL_FWD, BUTTON_NONE },
255 { ACTION_KBD_DOWN, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE }, 256 { ACTION_KBD_DOWN, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE },
256 { ACTION_KBD_PAGE_FLIP, BUTTON_HOME|BUTTON_SELECT, BUTTON_HOME }, 257 { ACTION_KBD_PAGE_FLIP, BUTTON_HOME|BUTTON_SELECT, BUTTON_HOME },
257 { ACTION_KBD_BACKSPACE, BUTTON_DOWN, BUTTON_NONE }, 258 { ACTION_KBD_BACKSPACE, BUTTON_DOWN, BUTTON_NONE },
258 { ACTION_KBD_BACKSPACE, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, 259 { ACTION_KBD_BACKSPACE, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
259 { ACTION_KBD_SELECT, BUTTON_SELECT, BUTTON_NONE }, 260 { ACTION_KBD_SELECT, BUTTON_SELECT, BUTTON_NONE },
260 { ACTION_KBD_DONE, BUTTON_UP, BUTTON_NONE }, 261 { ACTION_KBD_DONE, BUTTON_UP, BUTTON_NONE },
261 { ACTION_KBD_ABORT, BUTTON_HOME|BUTTON_REL, BUTTON_NONE }, 262 { ACTION_KBD_ABORT, BUTTON_POWER, BUTTON_NONE },
262 263
263 LAST_ITEM_IN_LIST 264 LAST_ITEM_IN_LIST
264}; /* button_context_keyboard */ 265}; /* button_context_keyboard */
diff --git a/firmware/target/arm/as3525/clock-target.h b/firmware/target/arm/as3525/clock-target.h
index 1e55753555..a227f464ff 100644
--- a/firmware/target/arm/as3525/clock-target.h
+++ b/firmware/target/arm/as3525/clock-target.h
@@ -53,7 +53,7 @@
53#elif defined(SANSA_M200V4) 53#elif defined(SANSA_M200V4)
54#define AS3525_DBOP_FREQ 8000000 54#define AS3525_DBOP_FREQ 8000000
55#elif defined(SANSA_FUZE) 55#elif defined(SANSA_FUZE)
56#define AS3525_DBOP_FREQ 24000000 56#define AS3525_DBOP_FREQ 8000000
57#elif defined(SANSA_E200V2) 57#elif defined(SANSA_E200V2)
58#define AS3525_DBOP_FREQ 8000000 58#define AS3525_DBOP_FREQ 8000000
59#elif defined(SANSA_C200V2) 59#elif defined(SANSA_C200V2)
diff --git a/firmware/target/arm/as3525/sansa-fuze/button-fuze.c b/firmware/target/arm/as3525/sansa-fuze/button-fuze.c
index 36a0f3aeda..2414900727 100644
--- a/firmware/target/arm/as3525/sansa-fuze/button-fuze.c
+++ b/firmware/target/arm/as3525/sansa-fuze/button-fuze.c
@@ -7,7 +7,8 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2006 by Barry Wardell 10 * Copyright (C) 2008 by Thomas Martitz
11 * Copyright (C) 2008 by Dominik Wenger
11 * 12 *
12 * This program is free software; you can redistribute it and/or 13 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 14 * modify it under the terms of the GNU General Public License
@@ -19,118 +20,229 @@
19 * 20 *
20 ****************************************************************************/ 21 ****************************************************************************/
21 22
22/* Taken from button-h10.c by Barry Wardell and reverse engineering by MrH. */ 23
24/* Basic button driver for the Fuze
25 *
26 * TODO: - Get the wheel working with interrupts
27 * - find that Home button
28 */
23 29
24#include "system.h" 30#include "system.h"
25#include "button.h" 31#include "button.h"
32#include "button-target.h"
26#include "backlight.h" 33#include "backlight.h"
27#include "powermgmt.h"
28 34
29#define WHEEL_REPEAT_INTERVAL 300000 35#define WHEEL_REPEAT_INTERVAL 30
30#define WHEEL_FAST_ON_INTERVAL 20000
31#define WHEEL_FAST_OFF_INTERVAL 60000
32#define WHEELCLICKS_PER_ROTATION 48 /* wheelclicks per full rotation */ 36#define WHEELCLICKS_PER_ROTATION 48 /* wheelclicks per full rotation */
33 37
34/* Clickwheel */
35#ifndef BOOTLOADER 38#ifndef BOOTLOADER
36static unsigned int old_wheel_value = 0;
37static unsigned int wheel_repeat = BUTTON_NONE;
38static unsigned int wheel_click_count = 0;
39static unsigned int wheel_delta = 0;
40static int wheel_fast_mode = 0;
41static unsigned long last_wheel_usec = 0;
42static unsigned long wheel_velocity = 0;
43static long last_wheel_post = 0;
44static long next_backlight_on = 0;
45/* Buttons */ 39/* Buttons */
46static bool hold_button = false; 40static bool hold_button = false;
47static bool hold_button_old = false; 41static bool hold_button_old = false;
48#define _button_hold() hold_button
49#else 42#else
50#define _button_hold() false /* FIXME */ 43#define hold_button false
51#endif /* BOOTLOADER */ 44#endif /* !BOOTLOADER */
52static int int_btn = BUTTON_NONE; 45static int int_btn = BUTTON_NONE;
46static short dbop_din = BUTTON_NONE;
53 47
54void button_init_device(void) 48void button_init_device(void)
55{ 49{
50 GPIOA_DIR |= (1<<1);
51 GPIOA_PIN(1) = (1<<1);
52}
53
54/* clickwheel */
55#if !defined(BOOTLOADER) && defined(HAVE_SCROLLWHEEL)
56static void get_wheel(void)
57{
58 static unsigned int old_wheel_value = 0;
59 static unsigned int wheel_value = 0;
60 static unsigned int wheel_repeat = BUTTON_NONE;
61 /* getting BUTTON_REPEAT works like this: We increment repeat by if the
62 * wheel was turned, and decrement it by 1 each tick,
63 * that means: if you change the wheel fast enough, repeat will be >1 and
64 * we send BUTTON_REPEAT
65 */
66 static int repeat;
67 /* we omit 3 of 4 posts to the button_queue, that works better, so count */
68 static int counter = 0;
69 /* Read wheel
70 * Bits 13 and 14 of DBOP_DIN change as follows:
71 * Clockwise rotation 00 -> 01 -> 11 -> 10 -> 00
72 * Counter-clockwise 00 -> 10 -> 11 -> 01 -> 00
73 */
74 static const unsigned char wheel_tbl[2][4] =
75 {
76 { 2, 0, 3, 1 }, /* Clockwise rotation */
77 { 1, 3, 0, 2 }, /* Counter-clockwise */
78 };
79 wheel_value = dbop_din & (1<<13|1<<14);
80 wheel_value >>= 13;
81 /* did the wheel value change? */
82 if (!hold_button)
83 {
84 unsigned int btn = BUTTON_NONE;
85 if (old_wheel_value == wheel_tbl[0][wheel_value])
86 btn = BUTTON_SCROLL_FWD;
87 else if (old_wheel_value == wheel_tbl[1][wheel_value])
88 btn = BUTTON_SCROLL_BACK;
89
90 if (btn != BUTTON_NONE)
91 {
92 if (btn != wheel_repeat)
93 {
94 /* direction reversals nullify repeats */
95 wheel_repeat = btn;
96 repeat = 0;
97 }
98 if (btn != BUTTON_NONE)
99 {
100 /* generate repeats if quick enough */
101 if (repeat > 0)
102 {
103 btn |= BUTTON_REPEAT;
104 }
105 repeat += 2;
106 /* the wheel is more reliable if we don't send ever change,
107 * every 4th is basically one "physical click" is 1 item in
108 * the rockbox menus */
109 if (queue_empty(&button_queue) && ++counter >= 4)
110 {
111 backlight_on();
112 /* 1<<24 is rather arbitary, seems to work well */
113 queue_post(&button_queue, btn, 1<<24);
114 /* message posted - reset count */
115 counter = 0;
116 }
117 }
118 }
119 }
120 if (repeat > 0)
121 repeat--;
122 else
123 repeat = 0;
124 old_wheel_value = wheel_value;
125}
126#endif /* !defined(BOOTLOADER) && defined(SCROLLWHEEL) */
127
128#if !defined(BOOTLOADER)
129/* get hold button state */
130static void get_hold(void)
131{
132 hold_button = dbop_din & (1<<12);
56} 133}
134#endif
57 135
58bool button_hold(void) 136bool button_hold(void)
59{ 137{
60 return _button_hold(); 138 return hold_button;
61} 139}
62 140
63/* clickwheel */ 141static void get_power(void)
64#ifndef BOOTLOADER
65void clickwheel_int(void)
66{ 142{
143 if (dbop_din & (1<<8))
144 int_btn |= BUTTON_POWER;
67} 145}
68#endif /* BOOTLOADER */
69 146
70/* device buttons */ 147static void get_button_from_dbob(void)
148{
149 int_btn &= ~(BUTTON_HOLD|
150 BUTTON_POWER);
151
152 /* Wait for fifo to empty */
153 while ((DBOP_STAT & (1<<10)) == 0);
154
155 DBOP_CTRL |= (1<<19);
156 DBOP_CTRL &= ~(1<<16); /* disable output */
157
158 DBOP_TIMPOL_01 = 0xe167e167;
159 DBOP_TIMPOL_23 = 0xe167006e;
160 int loop = 0;
161 do
162 {
163 asm volatile ("nop\n");
164 loop++;
165 } while(loop < 64);
166
167 DBOP_CTRL |= (1<<15); /* start read */
168 int temp;
169 do
170 {
171 temp = DBOP_STAT;
172 } while ((temp & (1<<16)) == 0); /* wait for valid data */
173
174 dbop_din = DBOP_DIN; /* now read */
175
176 DBOP_TIMPOL_01 = 0x6e167;
177 DBOP_TIMPOL_23 = 0xa167e06f;
178
179 DBOP_CTRL |= (1<<16);
180 DBOP_CTRL &= ~(1<<19);
71 181
72/* device buttons */ 182#if !defined(BOOTLOADER)
73void button_int(void) 183 get_hold();
184#if defined(HAVE_SCROLLWHEEL)
185 get_wheel();
186#endif
187#endif
188 get_power();
189}
190
191static void get_button_from_gpio(void)
74{ 192{
75 int dir_save_b = 0; 193 /* reset buttons we're going to read */
76 int afsel_save_b = 0; 194 int_btn &= ~(BUTTON_LEFT|
77 int dir_save_c = 0; 195 BUTTON_RIGHT|
78 int afsel_save_c = 0; 196 BUTTON_UP|
79 197 BUTTON_DOWN|
80 int_btn = BUTTON_NONE; 198 BUTTON_SELECT);
81 199 if(hold_button)
82 /* Save the current direction and afsel */ 200 return;
83 dir_save_b = GPIOB_DIR; 201 /* set afsel, so that we can read our buttons */
84 afsel_save_b = GPIOB_AFSEL; 202 GPIOC_AFSEL &= ~(1<<2|1<<3|1<<4|1<<5|1<<6);
85 dir_save_c = GPIOC_DIR; 203 /* set dir so we can read our buttons (but reset the C pins first) */
86 afsel_save_c = GPIOC_AFSEL; 204 GPIOB_DIR &= ~(1<<4);
87 205 GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6);
88 GPIOB_DIR = 0; 206 GPIOC_PIN(2) |= (1<<2);
89 GPIOB_AFSEL = 0; 207 GPIOC_PIN(3) |= (1<<3);
90 GPIOC_DIR = 0; 208 GPIOC_PIN(4) |= (1<<4);
91 GPIOC_AFSEL = 0; 209 GPIOC_PIN(5) |= (1<<5);
92 210 GPIOC_PIN(6) |= (1<<6);
93 /* These should not be needed with button event interupts */ 211
94 /* they are necessary now to clear out lcd data */ 212 GPIOC_DIR &= ~(1<<2|1<<3|1<<4|1<<5|1<<6);
95 GPIOC_PIN(0) |= 1; 213
96 GPIOC_PIN(1) |= 1; 214 /* small delay needed to read buttons correctly */
97 GPIOC_PIN(2) |= 1; 215 int delay = 50;
98 GPIOC_PIN(3) |= 1; 216 while(delay >0) delay--;
99 GPIOC_PIN(4) |= 1;
100 GPIOC_PIN(5) |= 1;
101 GPIOC_PIN(6) |= 1;
102 GPIOC_PIN(7) |= 1;
103 217
104 /* direct GPIO connections */ 218 /* direct GPIO connections */
105 if (GPIOB_PIN(4)) 219 if (!GPIOC_PIN(3))
106 int_btn |= BUTTON_POWER; 220 int_btn |= BUTTON_LEFT;
221 if (!GPIOC_PIN(2))
222 int_btn |= BUTTON_UP;
107 if (!GPIOC_PIN(6)) 223 if (!GPIOC_PIN(6))
108 int_btn |= BUTTON_DOWN; 224 int_btn |= BUTTON_DOWN;
109 if (!GPIOC_PIN(5)) 225 if (!GPIOC_PIN(5))
110 int_btn |= BUTTON_RIGHT; 226 int_btn |= BUTTON_RIGHT;
111 if (!GPIOC_PIN(4)) 227 if (!GPIOC_PIN(4))
112 int_btn |= BUTTON_SELECT; 228 int_btn |= BUTTON_SELECT;
113 if (!GPIOC_PIN(3))
114 int_btn |= BUTTON_LEFT;
115 if (!GPIOC_PIN(2))
116 int_btn |= BUTTON_UP;
117
118 /* return to settings needed for lcd */ 229 /* return to settings needed for lcd */
119 GPIOB_DIR = dir_save_b; 230 GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6);
120 GPIOB_AFSEL = afsel_save_b; 231 GPIOC_AFSEL |= (1<<2|1<<3|1<<4|1<<5|1<<6);
121 GPIOC_DIR = dir_save_c;
122 GPIOC_AFSEL = afsel_save_c;
123} 232}
124 233
234static inline void get_buttons_from_hw(void)
235{
236 get_button_from_dbob();
237 get_button_from_gpio();
238}
125/* 239/*
126 * Get button pressed from hardware 240 * Get button pressed from hardware
127 */ 241 */
128int button_read_device(void) 242int button_read_device(void)
129{ 243{
130#ifdef BOOTLOADER 244 get_buttons_from_hw();
131 /* Read buttons directly in the bootloader */ 245#ifndef BOOTLOADER
132 button_int();
133#else
134 /* light handling */ 246 /* light handling */
135 if (hold_button != hold_button_old) 247 if (hold_button != hold_button_old)
136 { 248 {
@@ -139,6 +251,5 @@ int button_read_device(void)
139 } 251 }
140#endif /* BOOTLOADER */ 252#endif /* BOOTLOADER */
141 253
142 /* The int_btn variable is set in the button interrupt handler */ 254 return int_btn; /* set in button_int */
143 return int_btn;
144} 255}
diff --git a/firmware/target/arm/as3525/sansa-fuze/button-target.h b/firmware/target/arm/as3525/sansa-fuze/button-target.h
index be72e1a35e..75ce3d060e 100644
--- a/firmware/target/arm/as3525/sansa-fuze/button-target.h
+++ b/firmware/target/arm/as3525/sansa-fuze/button-target.h
@@ -27,13 +27,9 @@
27 27
28#define HAS_BUTTON_HOLD 28#define HAS_BUTTON_HOLD
29 29
30bool button_hold(void);
31void button_init_device(void); 30void button_init_device(void);
31bool button_hold(void);
32int button_read_device(void); 32int button_read_device(void);
33#ifndef BOOTLOADER
34void clickwheel_int(void);
35#endif
36void button_int(void);
37 33
38/* Sandisk Sansa Fuze button codes */ 34/* Sandisk Sansa Fuze button codes */
39 35
@@ -51,11 +47,12 @@ void button_int(void);
51#define BUTTON_SCROLL_BACK 0x00000080 47#define BUTTON_SCROLL_BACK 0x00000080
52#define BUTTON_SCROLL_FWD 0x00000100 48#define BUTTON_SCROLL_FWD 0x00000100
53 49
54#define BUTTON_HOLD 0x00000200 50#define BUTTON_HOLD 0x00000400
55 51
56#define BUTTON_MAIN (BUTTON_HOME|BUTTON_DOWN|BUTTON_RIGHT|BUTTON_LEFT \ 52#define BUTTON_MAIN (BUTTON_HOME|BUTTON_DOWN|BUTTON_RIGHT|BUTTON_LEFT \
57 |BUTTON_SELECT|BUTTON_UP|BUTTON_POWER \ 53 |BUTTON_SELECT|BUTTON_UP|BUTTON_POWER \
58 |BUTTON_SCROLLBACK|BUTTON_SCROLL_FWD|BUTTON_HOLD) 54 |BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD| \
55 |BUTTON_HOLD)
59 56
60/* No Remote control */ 57/* No Remote control */
61#define BUTTON_REMOTE 0 58#define BUTTON_REMOTE 0