software keylock works again

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10632 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2006-08-17 12:33:36 +00:00
parent 0b35bcfc71
commit f1781318d3
8 changed files with 72 additions and 70 deletions

View file

@ -25,13 +25,18 @@
#include "action.h" #include "action.h"
#include "kernel.h" #include "kernel.h"
#include "debug.h" #include "debug.h"
#include "splash.h"
bool ignore_until_release = false; bool ignore_until_release = false;
int last_button = BUTTON_NONE; int last_button = BUTTON_NONE;
int soft_unlock_action = ACTION_NONE;
#if (BUTTON_REMOTE != 0) /* software keylock stuff */
bool allow_remote_actions = true; #ifndef HAS_BUTTON_HOLD
#endif bool keys_locked = false;
int unlock_combo = BUTTON_NONE;
bool screen_has_lock = false;
#endif /* HAVE_SOFTWARE_KEYLOCK */
/* /*
* do_button_check is the worker function for get_default_action. * do_button_check is the worker function for get_default_action.
* returns ACTION_UNKNOWN or the requested return value from the list. * returns ACTION_UNKNOWN or the requested return value from the list.
@ -92,6 +97,7 @@ int get_action_worker(int context, int timeout,
int button; int button;
int i=0; int i=0;
int ret = ACTION_UNKNOWN; int ret = ACTION_UNKNOWN;
if (timeout == TIMEOUT_NOBLOCK) if (timeout == TIMEOUT_NOBLOCK)
button = button_get(false); button = button_get(false);
else if (timeout == TIMEOUT_BLOCK) else if (timeout == TIMEOUT_BLOCK)
@ -113,13 +119,31 @@ int get_action_worker(int context, int timeout,
} }
return ACTION_NONE; /* "safest" return value */ return ACTION_NONE; /* "safest" return value */
} }
#if (BUTTON_REMOTE != 0)
if (soft_unlock_action != ACTION_NONE) #ifndef HAS_BUTTON_HOLD
screen_has_lock = ((context&ALLOW_SOFTLOCK)==ALLOW_SOFTLOCK);
if (screen_has_lock && (keys_locked == true))
{ {
if ((button&BUTTON_REMOTE) && !allow_remote_actions) if (button == unlock_combo)
return ACTION_NONE; {
} last_button = BUTTON_NONE;
keys_locked = false;
gui_syncsplash(HZ/2, true, "Keys Unlocked");
return ACTION_REDRAW;
}
else
#if (BUTTON_REMOTE != 0)
if ((button&BUTTON_REMOTE) == 0)
#endif #endif
{
if ((button&BUTTON_REL))
gui_syncsplash(HZ, true, "Keys Locked");
return ACTION_REDRAW;
}
}
context &= ~ALLOW_SOFTLOCK;
#endif /* HAS_BUTTON_HOLD */
/* logf("%x,%x",last_button,button); */ /* logf("%x,%x",last_button,button); */
do do
{ {
@ -149,29 +173,18 @@ int get_action_worker(int context, int timeout,
else break; else break;
} while (1); } while (1);
/* DEBUGF("ret = %x\n",ret); */ /* DEBUGF("ret = %x\n",ret); */
#ifndef HAS_BUTTON_HOLD
if (soft_unlock_action != ACTION_NONE) if (screen_has_lock && (ret == ACTION_STD_KEYLOCK))
{ {
#if (BUTTON_REMOTE != 0) unlock_combo = button;
if ((button&BUTTON_REMOTE) == 0) keys_locked = true;
{ action_signalscreenchange();
#endif gui_syncsplash(HZ, true, "Keys Locked");
if (soft_unlock_action == ret)
{ button_clear_queue();
soft_unlock_action = ACTION_NONE; return ACTION_REDRAW;
ret = ACTION_NONE; /* no need to return the code */
}
#if (BUTTON_REMOTE != 0)
}
else if (!allow_remote_actions)
{
ret = ACTION_NONE;
}
#else
else ret = ACTION_NONE; /* eat the button */
#endif
} }
#endif
last_button = button; last_button = button;
return ret; return ret;
} }
@ -205,14 +218,9 @@ void action_signalscreenchange(void)
} }
last_button = BUTTON_NONE; last_button = BUTTON_NONE;
} }
#ifndef HAS_BUTTON_HOLD
void action_setsoftwarekeylock(int unlock_action, bool allow_remote) bool is_keys_locked(void)
{ {
soft_unlock_action = unlock_action; return (screen_has_lock && (keys_locked == true));
#if (BUTTON_REMOTE != 0)
allow_remote_actions = allow_remote;
#else
(void)allow_remote; /* kill the warning */
#endif
last_button = BUTTON_NONE;
} }
#endif

View file

@ -29,6 +29,12 @@
#define CONTEXT_REMOTE 0x80000000 /* | this against another context to get remote buttons for that context */ #define CONTEXT_REMOTE 0x80000000 /* | this against another context to get remote buttons for that context */
#define CONTEXT_CUSTOM 0x40000000 /* | this against anything to get your context number */ #define CONTEXT_CUSTOM 0x40000000 /* | this against anything to get your context number */
#ifndef HAS_BUTTON_HOLD
#define ALLOW_SOFTLOCK 0x20000000 /* will be stripped.. never needed except in calls to get_action() */
#else
#define ALLOW_SOFTLOCK 0
#endif
enum { enum {
CONTEXT_STD = 0, CONTEXT_STD = 0,
/* These CONTEXT_ values were here before me, /* These CONTEXT_ values were here before me,
@ -54,6 +60,7 @@ enum {
ACTION_NONE = BUTTON_NONE, ACTION_NONE = BUTTON_NONE,
ACTION_UNKNOWN, ACTION_UNKNOWN,
ACTION_REDRAW, /* returned if keys are locked and we splash()'ed */
/* standard actions, use these first */ /* standard actions, use these first */
ACTION_STD_PREV, ACTION_STD_PREV,
@ -66,9 +73,7 @@ enum {
ACTION_STD_CONTEXT, ACTION_STD_CONTEXT,
ACTION_STD_MENU, ACTION_STD_MENU,
ACTION_STD_QUICKSCREEN, ACTION_STD_QUICKSCREEN,
ACTION_STD_KEYLOCK, /* software keylock in wps screen, very optional ACTION_STD_KEYLOCK,
use with action_setsoftwarekeylock */
/* code context actions */ /* code context actions */
@ -165,12 +170,9 @@ void action_signalscreenchange(void);
/* call this if you need to check for ACTION_STD_CANCEL only (i.e user abort! */ /* call this if you need to check for ACTION_STD_CANCEL only (i.e user abort! */
bool action_userabort(int timeout); bool action_userabort(int timeout);
/* on targets without hardware keylock, use this to to emulate keylock.
unlock_action is the action which will disaable the keylock
allow_remote should be true if you want the remote buttons to still be usable while locked */
void action_setsoftwarekeylock(int unlock_action, bool allow_remote);
/* no other code should need this apart from action.c */ /* no other code should need this apart from action.c */
const struct button_mapping* get_context_mapping(int context); const struct button_mapping* get_context_mapping(int context);
#ifndef HAS_BUTTON_HOLD
bool is_keys_locked(void);
#endif
#endif #endif

View file

@ -65,8 +65,6 @@ struct wps_state wps_state;
struct gui_wps gui_wps[NB_SCREENS]; struct gui_wps gui_wps[NB_SCREENS];
static struct wps_data wps_datas[NB_SCREENS]; static struct wps_data wps_datas[NB_SCREENS];
bool keys_locked = false;
/* change the path to the current played track */ /* change the path to the current played track */
static void wps_state_update_ctp(const char *path); static void wps_state_update_ctp(const char *path);
@ -163,7 +161,7 @@ long gui_wps_show(void)
long next_big_refresh = current_tick + HZ / 5; long next_big_refresh = current_tick + HZ / 5;
button = BUTTON_NONE; button = BUTTON_NONE;
while (TIME_BEFORE(current_tick, next_big_refresh)) { while (TIME_BEFORE(current_tick, next_big_refresh)) {
button = get_action(CONTEXT_WPS,TIMEOUT_NOBLOCK); button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_NOBLOCK);
if (button != ACTION_NONE) { if (button != ACTION_NONE) {
break; break;
} }
@ -186,10 +184,10 @@ long gui_wps_show(void)
/* The peak meter is disabled /* The peak meter is disabled
-> no additional screen updates needed */ -> no additional screen updates needed */
else { else {
button = get_action(CONTEXT_WPS,HZ/5); button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5);
} }
#else #else
button = get_action(CONTEXT_WPS,HZ/5); button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5);
#endif #endif
/* Exit if audio has stopped playing. This can happen if using the /* Exit if audio has stopped playing. This can happen if using the
@ -426,13 +424,6 @@ long gui_wps_show(void)
restore = true; restore = true;
break; break;
/* key lock */
case ACTION_STD_KEYLOCK:
action_setsoftwarekeylock(ACTION_STD_KEYLOCK,true);
display_keylock_text(true);
restore = true;
break;
#ifdef HAVE_QUICKSCREEN #ifdef HAVE_QUICKSCREEN
case ACTION_WPS_QUICKSCREEN: case ACTION_WPS_QUICKSCREEN:
@ -542,6 +533,9 @@ long gui_wps_show(void)
restore = true; restore = true;
break; break;
case ACTION_REDRAW: /* yes are locked, just redraw */
restore = true;
break;
case ACTION_NONE: /* Timeout */ case ACTION_NONE: /* Timeout */
update_track = true; update_track = true;
ffwd_rew(button); /* hopefully fix the ffw/rwd bug */ ffwd_rew(button); /* hopefully fix the ffw/rwd bug */
@ -599,10 +593,6 @@ long gui_wps_show(void)
ab_reset_markers(); ab_reset_markers();
#endif #endif
/* Keys can be locked when exiting, so either unlock here
or implement key locking in tree.c too */
keys_locked=false;
/* set dir browser to current playing song */ /* set dir browser to current playing song */
if (global_settings.browse_current && if (global_settings.browse_current &&
wps_state.current_track_path[0] != '\0') wps_state.current_track_path[0] != '\0')

View file

@ -318,8 +318,6 @@
#define WPS_ALIGN_CENTER 64 #define WPS_ALIGN_CENTER 64
#define WPS_ALIGN_LEFT 128 #define WPS_ALIGN_LEFT 128
extern bool keys_locked;
/* wps_data*/ /* wps_data*/
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP

View file

@ -34,7 +34,7 @@
#include "led.h" #include "led.h"
#include "status.h" /* needed for battery_state global var */ #include "status.h" /* needed for battery_state global var */
#include "gwps.h" /* for keys_locked */ #include "action.h" /* for keys_locked */
#include "statusbar.h" #include "statusbar.h"
@ -178,7 +178,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
#ifdef HAS_BUTTON_HOLD #ifdef HAS_BUTTON_HOLD
bar->info.keylock = button_hold(); bar->info.keylock = button_hold();
#else #else
bar->info.keylock = keys_locked; bar->info.keylock = is_keys_locked();
#endif /* HAS_BUTTON_HOLD */ #endif /* HAS_BUTTON_HOLD */
#ifdef HAS_REMOTE_BUTTON_HOLD #ifdef HAS_REMOTE_BUTTON_HOLD
bar->info.keylockremote = remote_button_hold(); bar->info.keylockremote = remote_button_hold();

View file

@ -62,7 +62,8 @@ const struct button_mapping button_context_wps[] = {
{ ACTION_WPS_VOLUP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_WPS_VOLUP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_WPS_BROWSE, BUTTON_MENU|BUTTON_REL, BUTTON_MENU }, { ACTION_WPS_BROWSE, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
{ ACTION_WPS_CONTEXT, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU }, { ACTION_WPS_CONTEXT, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
/* { ACTION_WPS_MENU, BUTTON_NONE, BUTTON_NONE }, we can't have that */ /* { ACTION_WPS_MENU, BUTTON_NONE, BUTTON_NONE }, we can't have that */
{ ACTION_STD_KEYLOCK, BUTTON_MENU|BUTTON_DOWN, BUTTON_NONE },
LAST_ITEM_IN_LIST LAST_ITEM_IN_LIST
}; };

View file

@ -58,6 +58,7 @@ static const struct button_mapping button_context_wps[] = {
{ ACTION_WPS_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU }, { ACTION_WPS_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
{ ACTION_WPS_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, { ACTION_WPS_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
{ ACTION_WPS_ID3SCREEN, BUTTON_MENU|BUTTON_ON, BUTTON_NONE }, { ACTION_WPS_ID3SCREEN, BUTTON_MENU|BUTTON_ON, BUTTON_NONE },
{ ACTION_STD_KEYLOCK, BUTTON_MENU|BUTTON_STOP, BUTTON_NONE },
LAST_ITEM_IN_LIST LAST_ITEM_IN_LIST
}; };

View file

@ -75,6 +75,8 @@ static const struct button_mapping button_context_wps[] = {
{ ACTION_WPS_ID3SCREEN, BUTTON_F1|BUTTON_ON, BUTTON_F1 }, { ACTION_WPS_ID3SCREEN, BUTTON_F1|BUTTON_ON, BUTTON_F1 },
{ ACTION_WPS_PITCHSCREEN, BUTTON_ON|BUTTON_UP, BUTTON_ON }, { ACTION_WPS_PITCHSCREEN, BUTTON_ON|BUTTON_UP, BUTTON_ON },
{ ACTION_WPS_PITCHSCREEN, BUTTON_ON|BUTTON_DOWN, BUTTON_ON }, { ACTION_WPS_PITCHSCREEN, BUTTON_ON|BUTTON_DOWN, BUTTON_ON },
{ ACTION_STD_KEYLOCK, BUTTON_F1|BUTTON_DOWN, BUTTON_NONE },
LAST_ITEM_IN_LIST LAST_ITEM_IN_LIST
}; };