summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2006-08-17 12:33:36 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2006-08-17 12:33:36 +0000
commitf1781318d3483bac2bb5f87f4bdb96f678e6945a (patch)
tree854da549cfca5dc0e33084beb681453dbf28b4b4 /apps
parent0b35bcfc7151e7e12b221d6917e31a46c73e1d3a (diff)
downloadrockbox-f1781318d3483bac2bb5f87f4bdb96f678e6945a.tar.gz
rockbox-f1781318d3483bac2bb5f87f4bdb96f678e6945a.zip
software keylock works again
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10632 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/action.c88
-rw-r--r--apps/action.h20
-rw-r--r--apps/gui/gwps.c22
-rw-r--r--apps/gui/gwps.h2
-rw-r--r--apps/gui/statusbar.c4
-rw-r--r--apps/keymaps/keymap-ondio.c3
-rw-r--r--apps/keymaps/keymap-player.c1
-rw-r--r--apps/keymaps/keymap-recorder.c2
8 files changed, 72 insertions, 70 deletions
diff --git a/apps/action.c b/apps/action.c
index 94f27ce2cf..8f6af0245c 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -25,13 +25,18 @@
25#include "action.h" 25#include "action.h"
26#include "kernel.h" 26#include "kernel.h"
27#include "debug.h" 27#include "debug.h"
28#include "splash.h"
28 29
29bool ignore_until_release = false; 30bool ignore_until_release = false;
30int last_button = BUTTON_NONE; 31int last_button = BUTTON_NONE;
31int soft_unlock_action = ACTION_NONE; 32
32#if (BUTTON_REMOTE != 0) 33/* software keylock stuff */
33bool allow_remote_actions = true; 34#ifndef HAS_BUTTON_HOLD
34#endif 35bool keys_locked = false;
36int unlock_combo = BUTTON_NONE;
37bool screen_has_lock = false;
38#endif /* HAVE_SOFTWARE_KEYLOCK */
39
35/* 40/*
36 * do_button_check is the worker function for get_default_action. 41 * do_button_check is the worker function for get_default_action.
37 * returns ACTION_UNKNOWN or the requested return value from the list. 42 * returns ACTION_UNKNOWN or the requested return value from the list.
@@ -92,6 +97,7 @@ int get_action_worker(int context, int timeout,
92 int button; 97 int button;
93 int i=0; 98 int i=0;
94 int ret = ACTION_UNKNOWN; 99 int ret = ACTION_UNKNOWN;
100
95 if (timeout == TIMEOUT_NOBLOCK) 101 if (timeout == TIMEOUT_NOBLOCK)
96 button = button_get(false); 102 button = button_get(false);
97 else if (timeout == TIMEOUT_BLOCK) 103 else if (timeout == TIMEOUT_BLOCK)
@@ -113,13 +119,31 @@ int get_action_worker(int context, int timeout,
113 } 119 }
114 return ACTION_NONE; /* "safest" return value */ 120 return ACTION_NONE; /* "safest" return value */
115 } 121 }
116#if (BUTTON_REMOTE != 0) 122
117 if (soft_unlock_action != ACTION_NONE) 123#ifndef HAS_BUTTON_HOLD
124 screen_has_lock = ((context&ALLOW_SOFTLOCK)==ALLOW_SOFTLOCK);
125 if (screen_has_lock && (keys_locked == true))
118 { 126 {
119 if ((button&BUTTON_REMOTE) && !allow_remote_actions) 127 if (button == unlock_combo)
120 return ACTION_NONE; 128 {
121 } 129 last_button = BUTTON_NONE;
130 keys_locked = false;
131 gui_syncsplash(HZ/2, true, "Keys Unlocked");
132 return ACTION_REDRAW;
133 }
134 else
135#if (BUTTON_REMOTE != 0)
136 if ((button&BUTTON_REMOTE) == 0)
122#endif 137#endif
138 {
139 if ((button&BUTTON_REL))
140 gui_syncsplash(HZ, true, "Keys Locked");
141 return ACTION_REDRAW;
142 }
143 }
144 context &= ~ALLOW_SOFTLOCK;
145#endif /* HAS_BUTTON_HOLD */
146
123 /* logf("%x,%x",last_button,button); */ 147 /* logf("%x,%x",last_button,button); */
124 do 148 do
125 { 149 {
@@ -149,29 +173,18 @@ int get_action_worker(int context, int timeout,
149 else break; 173 else break;
150 } while (1); 174 } while (1);
151 /* DEBUGF("ret = %x\n",ret); */ 175 /* DEBUGF("ret = %x\n",ret); */
152 176#ifndef HAS_BUTTON_HOLD
153 if (soft_unlock_action != ACTION_NONE) 177 if (screen_has_lock && (ret == ACTION_STD_KEYLOCK))
154 { 178 {
155#if (BUTTON_REMOTE != 0) 179 unlock_combo = button;
156 if ((button&BUTTON_REMOTE) == 0) 180 keys_locked = true;
157 { 181 action_signalscreenchange();
158#endif 182 gui_syncsplash(HZ, true, "Keys Locked");
159 if (soft_unlock_action == ret) 183
160 { 184 button_clear_queue();
161 soft_unlock_action = ACTION_NONE; 185 return ACTION_REDRAW;
162 ret = ACTION_NONE; /* no need to return the code */
163 }
164#if (BUTTON_REMOTE != 0)
165 }
166 else if (!allow_remote_actions)
167 {
168 ret = ACTION_NONE;
169 }
170#else
171 else ret = ACTION_NONE; /* eat the button */
172#endif
173 } 186 }
174 187#endif
175 last_button = button; 188 last_button = button;
176 return ret; 189 return ret;
177} 190}
@@ -205,14 +218,9 @@ void action_signalscreenchange(void)
205 } 218 }
206 last_button = BUTTON_NONE; 219 last_button = BUTTON_NONE;
207} 220}
208 221#ifndef HAS_BUTTON_HOLD
209void action_setsoftwarekeylock(int unlock_action, bool allow_remote) 222bool is_keys_locked(void)
210{ 223{
211 soft_unlock_action = unlock_action; 224 return (screen_has_lock && (keys_locked == true));
212#if (BUTTON_REMOTE != 0)
213 allow_remote_actions = allow_remote;
214#else
215 (void)allow_remote; /* kill the warning */
216#endif
217 last_button = BUTTON_NONE;
218} 225}
226#endif
diff --git a/apps/action.h b/apps/action.h
index c73a9e4867..e95d009a0f 100644
--- a/apps/action.h
+++ b/apps/action.h
@@ -29,6 +29,12 @@
29#define CONTEXT_REMOTE 0x80000000 /* | this against another context to get remote buttons for that context */ 29#define CONTEXT_REMOTE 0x80000000 /* | this against another context to get remote buttons for that context */
30#define CONTEXT_CUSTOM 0x40000000 /* | this against anything to get your context number */ 30#define CONTEXT_CUSTOM 0x40000000 /* | this against anything to get your context number */
31 31
32#ifndef HAS_BUTTON_HOLD
33#define ALLOW_SOFTLOCK 0x20000000 /* will be stripped.. never needed except in calls to get_action() */
34#else
35#define ALLOW_SOFTLOCK 0
36#endif
37
32enum { 38enum {
33 CONTEXT_STD = 0, 39 CONTEXT_STD = 0,
34 /* These CONTEXT_ values were here before me, 40 /* These CONTEXT_ values were here before me,
@@ -54,6 +60,7 @@ enum {
54 60
55 ACTION_NONE = BUTTON_NONE, 61 ACTION_NONE = BUTTON_NONE,
56 ACTION_UNKNOWN, 62 ACTION_UNKNOWN,
63 ACTION_REDRAW, /* returned if keys are locked and we splash()'ed */
57 64
58 /* standard actions, use these first */ 65 /* standard actions, use these first */
59 ACTION_STD_PREV, 66 ACTION_STD_PREV,
@@ -66,9 +73,7 @@ enum {
66 ACTION_STD_CONTEXT, 73 ACTION_STD_CONTEXT,
67 ACTION_STD_MENU, 74 ACTION_STD_MENU,
68 ACTION_STD_QUICKSCREEN, 75 ACTION_STD_QUICKSCREEN,
69 ACTION_STD_KEYLOCK, /* software keylock in wps screen, very optional 76 ACTION_STD_KEYLOCK,
70 use with action_setsoftwarekeylock */
71
72 77
73 /* code context actions */ 78 /* code context actions */
74 79
@@ -165,12 +170,9 @@ void action_signalscreenchange(void);
165/* call this if you need to check for ACTION_STD_CANCEL only (i.e user abort! */ 170/* call this if you need to check for ACTION_STD_CANCEL only (i.e user abort! */
166bool action_userabort(int timeout); 171bool action_userabort(int timeout);
167 172
168/* on targets without hardware keylock, use this to to emulate keylock.
169 unlock_action is the action which will disaable the keylock
170 allow_remote should be true if you want the remote buttons to still be usable while locked */
171void action_setsoftwarekeylock(int unlock_action, bool allow_remote);
172
173/* no other code should need this apart from action.c */ 173/* no other code should need this apart from action.c */
174const struct button_mapping* get_context_mapping(int context); 174const struct button_mapping* get_context_mapping(int context);
175 175#ifndef HAS_BUTTON_HOLD
176bool is_keys_locked(void);
177#endif
176#endif 178#endif
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index 12e120f7d4..06e7ae4aed 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -65,8 +65,6 @@ struct wps_state wps_state;
65struct gui_wps gui_wps[NB_SCREENS]; 65struct gui_wps gui_wps[NB_SCREENS];
66static struct wps_data wps_datas[NB_SCREENS]; 66static struct wps_data wps_datas[NB_SCREENS];
67 67
68bool keys_locked = false;
69
70/* change the path to the current played track */ 68/* change the path to the current played track */
71static void wps_state_update_ctp(const char *path); 69static void wps_state_update_ctp(const char *path);
72 70
@@ -163,7 +161,7 @@ long gui_wps_show(void)
163 long next_big_refresh = current_tick + HZ / 5; 161 long next_big_refresh = current_tick + HZ / 5;
164 button = BUTTON_NONE; 162 button = BUTTON_NONE;
165 while (TIME_BEFORE(current_tick, next_big_refresh)) { 163 while (TIME_BEFORE(current_tick, next_big_refresh)) {
166 button = get_action(CONTEXT_WPS,TIMEOUT_NOBLOCK); 164 button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_NOBLOCK);
167 if (button != ACTION_NONE) { 165 if (button != ACTION_NONE) {
168 break; 166 break;
169 } 167 }
@@ -186,10 +184,10 @@ long gui_wps_show(void)
186 /* The peak meter is disabled 184 /* The peak meter is disabled
187 -> no additional screen updates needed */ 185 -> no additional screen updates needed */
188 else { 186 else {
189 button = get_action(CONTEXT_WPS,HZ/5); 187 button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5);
190 } 188 }
191#else 189#else
192 button = get_action(CONTEXT_WPS,HZ/5); 190 button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5);
193#endif 191#endif
194 192
195 /* Exit if audio has stopped playing. This can happen if using the 193 /* Exit if audio has stopped playing. This can happen if using the
@@ -426,13 +424,6 @@ long gui_wps_show(void)
426 restore = true; 424 restore = true;
427 break; 425 break;
428 426
429 /* key lock */
430 case ACTION_STD_KEYLOCK:
431 action_setsoftwarekeylock(ACTION_STD_KEYLOCK,true);
432 display_keylock_text(true);
433 restore = true;
434 break;
435
436 427
437#ifdef HAVE_QUICKSCREEN 428#ifdef HAVE_QUICKSCREEN
438 case ACTION_WPS_QUICKSCREEN: 429 case ACTION_WPS_QUICKSCREEN:
@@ -542,6 +533,9 @@ long gui_wps_show(void)
542 restore = true; 533 restore = true;
543 break; 534 break;
544 535
536 case ACTION_REDRAW: /* yes are locked, just redraw */
537 restore = true;
538 break;
545 case ACTION_NONE: /* Timeout */ 539 case ACTION_NONE: /* Timeout */
546 update_track = true; 540 update_track = true;
547 ffwd_rew(button); /* hopefully fix the ffw/rwd bug */ 541 ffwd_rew(button); /* hopefully fix the ffw/rwd bug */
@@ -599,10 +593,6 @@ long gui_wps_show(void)
599 ab_reset_markers(); 593 ab_reset_markers();
600#endif 594#endif
601 595
602 /* Keys can be locked when exiting, so either unlock here
603 or implement key locking in tree.c too */
604 keys_locked=false;
605
606 /* set dir browser to current playing song */ 596 /* set dir browser to current playing song */
607 if (global_settings.browse_current && 597 if (global_settings.browse_current &&
608 wps_state.current_track_path[0] != '\0') 598 wps_state.current_track_path[0] != '\0')
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h
index 5b27696dd8..2c9638d5c9 100644
--- a/apps/gui/gwps.h
+++ b/apps/gui/gwps.h
@@ -318,8 +318,6 @@
318#define WPS_ALIGN_CENTER 64 318#define WPS_ALIGN_CENTER 64
319#define WPS_ALIGN_LEFT 128 319#define WPS_ALIGN_LEFT 128
320 320
321
322extern bool keys_locked;
323/* wps_data*/ 321/* wps_data*/
324 322
325#ifdef HAVE_LCD_BITMAP 323#ifdef HAVE_LCD_BITMAP
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c
index cceb54ede6..cbd1709bbc 100644
--- a/apps/gui/statusbar.c
+++ b/apps/gui/statusbar.c
@@ -34,7 +34,7 @@
34#include "led.h" 34#include "led.h"
35 35
36#include "status.h" /* needed for battery_state global var */ 36#include "status.h" /* needed for battery_state global var */
37#include "gwps.h" /* for keys_locked */ 37#include "action.h" /* for keys_locked */
38#include "statusbar.h" 38#include "statusbar.h"
39 39
40 40
@@ -178,7 +178,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
178#ifdef HAS_BUTTON_HOLD 178#ifdef HAS_BUTTON_HOLD
179 bar->info.keylock = button_hold(); 179 bar->info.keylock = button_hold();
180#else 180#else
181 bar->info.keylock = keys_locked; 181 bar->info.keylock = is_keys_locked();
182#endif /* HAS_BUTTON_HOLD */ 182#endif /* HAS_BUTTON_HOLD */
183#ifdef HAS_REMOTE_BUTTON_HOLD 183#ifdef HAS_REMOTE_BUTTON_HOLD
184 bar->info.keylockremote = remote_button_hold(); 184 bar->info.keylockremote = remote_button_hold();
diff --git a/apps/keymaps/keymap-ondio.c b/apps/keymaps/keymap-ondio.c
index 12745dfb44..5476268065 100644
--- a/apps/keymaps/keymap-ondio.c
+++ b/apps/keymaps/keymap-ondio.c
@@ -62,7 +62,8 @@ const struct button_mapping button_context_wps[] = {
62 { ACTION_WPS_VOLUP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, 62 { ACTION_WPS_VOLUP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
63 { ACTION_WPS_BROWSE, BUTTON_MENU|BUTTON_REL, BUTTON_MENU }, 63 { ACTION_WPS_BROWSE, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
64 { ACTION_WPS_CONTEXT, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU }, 64 { ACTION_WPS_CONTEXT, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
65 /* { ACTION_WPS_MENU, BUTTON_NONE, BUTTON_NONE }, we can't have that */ 65 /* { ACTION_WPS_MENU, BUTTON_NONE, BUTTON_NONE }, we can't have that */
66 { ACTION_STD_KEYLOCK, BUTTON_MENU|BUTTON_DOWN, BUTTON_NONE },
66 67
67 LAST_ITEM_IN_LIST 68 LAST_ITEM_IN_LIST
68}; 69};
diff --git a/apps/keymaps/keymap-player.c b/apps/keymaps/keymap-player.c
index 8ed5d9dc55..0681dc2ded 100644
--- a/apps/keymaps/keymap-player.c
+++ b/apps/keymaps/keymap-player.c
@@ -58,6 +58,7 @@ static const struct button_mapping button_context_wps[] = {
58 { ACTION_WPS_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU }, 58 { ACTION_WPS_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
59 { ACTION_WPS_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, 59 { ACTION_WPS_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
60 { ACTION_WPS_ID3SCREEN, BUTTON_MENU|BUTTON_ON, BUTTON_NONE }, 60 { ACTION_WPS_ID3SCREEN, BUTTON_MENU|BUTTON_ON, BUTTON_NONE },
61 { ACTION_STD_KEYLOCK, BUTTON_MENU|BUTTON_STOP, BUTTON_NONE },
61 62
62 LAST_ITEM_IN_LIST 63 LAST_ITEM_IN_LIST
63}; 64};
diff --git a/apps/keymaps/keymap-recorder.c b/apps/keymaps/keymap-recorder.c
index a16f5ee44e..409aebf600 100644
--- a/apps/keymaps/keymap-recorder.c
+++ b/apps/keymaps/keymap-recorder.c
@@ -75,6 +75,8 @@ static const struct button_mapping button_context_wps[] = {
75 { ACTION_WPS_ID3SCREEN, BUTTON_F1|BUTTON_ON, BUTTON_F1 }, 75 { ACTION_WPS_ID3SCREEN, BUTTON_F1|BUTTON_ON, BUTTON_F1 },
76 { ACTION_WPS_PITCHSCREEN, BUTTON_ON|BUTTON_UP, BUTTON_ON }, 76 { ACTION_WPS_PITCHSCREEN, BUTTON_ON|BUTTON_UP, BUTTON_ON },
77 { ACTION_WPS_PITCHSCREEN, BUTTON_ON|BUTTON_DOWN, BUTTON_ON }, 77 { ACTION_WPS_PITCHSCREEN, BUTTON_ON|BUTTON_DOWN, BUTTON_ON },
78 { ACTION_STD_KEYLOCK, BUTTON_F1|BUTTON_DOWN, BUTTON_NONE },
79
78 80
79 LAST_ITEM_IN_LIST 81 LAST_ITEM_IN_LIST
80}; 82};