From f1781318d3483bac2bb5f87f4bdb96f678e6945a Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Thu, 17 Aug 2006 12:33:36 +0000 Subject: software keylock works again git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10632 a1c6a512-1295-4272-9138-f99709370657 --- apps/action.c | 88 +++++++++++++++++++++++------------------- apps/action.h | 20 +++++----- apps/gui/gwps.c | 22 +++-------- apps/gui/gwps.h | 2 - apps/gui/statusbar.c | 4 +- apps/keymaps/keymap-ondio.c | 3 +- apps/keymaps/keymap-player.c | 1 + apps/keymaps/keymap-recorder.c | 2 + 8 files changed, 72 insertions(+), 70 deletions(-) (limited to 'apps') 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 @@ #include "action.h" #include "kernel.h" #include "debug.h" +#include "splash.h" bool ignore_until_release = false; int last_button = BUTTON_NONE; -int soft_unlock_action = ACTION_NONE; -#if (BUTTON_REMOTE != 0) -bool allow_remote_actions = true; -#endif + +/* software keylock stuff */ +#ifndef HAS_BUTTON_HOLD +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. * 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 i=0; int ret = ACTION_UNKNOWN; + if (timeout == TIMEOUT_NOBLOCK) button = button_get(false); else if (timeout == TIMEOUT_BLOCK) @@ -113,13 +119,31 @@ int get_action_worker(int context, int timeout, } 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) - return ACTION_NONE; - } + if (button == unlock_combo) + { + 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 + { + 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); */ do { @@ -149,29 +173,18 @@ int get_action_worker(int context, int timeout, else break; } while (1); /* DEBUGF("ret = %x\n",ret); */ - - if (soft_unlock_action != ACTION_NONE) - { -#if (BUTTON_REMOTE != 0) - if ((button&BUTTON_REMOTE) == 0) - { -#endif - if (soft_unlock_action == ret) - { - soft_unlock_action = ACTION_NONE; - 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 +#ifndef HAS_BUTTON_HOLD + if (screen_has_lock && (ret == ACTION_STD_KEYLOCK)) + { + unlock_combo = button; + keys_locked = true; + action_signalscreenchange(); + gui_syncsplash(HZ, true, "Keys Locked"); + + button_clear_queue(); + return ACTION_REDRAW; } - +#endif last_button = button; return ret; } @@ -205,14 +218,9 @@ void action_signalscreenchange(void) } last_button = BUTTON_NONE; } - -void action_setsoftwarekeylock(int unlock_action, bool allow_remote) +#ifndef HAS_BUTTON_HOLD +bool is_keys_locked(void) { - soft_unlock_action = unlock_action; -#if (BUTTON_REMOTE != 0) - allow_remote_actions = allow_remote; -#else - (void)allow_remote; /* kill the warning */ -#endif - last_button = BUTTON_NONE; + return (screen_has_lock && (keys_locked == true)); } +#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 @@ #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 */ +#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 { CONTEXT_STD = 0, /* These CONTEXT_ values were here before me, @@ -54,6 +60,7 @@ enum { ACTION_NONE = BUTTON_NONE, ACTION_UNKNOWN, + ACTION_REDRAW, /* returned if keys are locked and we splash()'ed */ /* standard actions, use these first */ ACTION_STD_PREV, @@ -66,9 +73,7 @@ enum { ACTION_STD_CONTEXT, ACTION_STD_MENU, ACTION_STD_QUICKSCREEN, - ACTION_STD_KEYLOCK, /* software keylock in wps screen, very optional - use with action_setsoftwarekeylock */ - + ACTION_STD_KEYLOCK, /* 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! */ 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 */ const struct button_mapping* get_context_mapping(int context); - +#ifndef HAS_BUTTON_HOLD +bool is_keys_locked(void); +#endif #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; struct gui_wps gui_wps[NB_SCREENS]; static struct wps_data wps_datas[NB_SCREENS]; -bool keys_locked = false; - /* change the path to the current played track */ 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; button = BUTTON_NONE; 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) { break; } @@ -186,10 +184,10 @@ long gui_wps_show(void) /* The peak meter is disabled -> no additional screen updates needed */ else { - button = get_action(CONTEXT_WPS,HZ/5); + button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5); } #else - button = get_action(CONTEXT_WPS,HZ/5); + button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5); #endif /* Exit if audio has stopped playing. This can happen if using the @@ -426,13 +424,6 @@ long gui_wps_show(void) restore = true; break; - /* key lock */ - case ACTION_STD_KEYLOCK: - action_setsoftwarekeylock(ACTION_STD_KEYLOCK,true); - display_keylock_text(true); - restore = true; - break; - #ifdef HAVE_QUICKSCREEN case ACTION_WPS_QUICKSCREEN: @@ -542,6 +533,9 @@ long gui_wps_show(void) restore = true; break; + case ACTION_REDRAW: /* yes are locked, just redraw */ + restore = true; + break; case ACTION_NONE: /* Timeout */ update_track = true; ffwd_rew(button); /* hopefully fix the ffw/rwd bug */ @@ -599,10 +593,6 @@ long gui_wps_show(void) ab_reset_markers(); #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 */ if (global_settings.browse_current && 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 @@ #define WPS_ALIGN_CENTER 64 #define WPS_ALIGN_LEFT 128 - -extern bool keys_locked; /* wps_data*/ #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 @@ #include "led.h" #include "status.h" /* needed for battery_state global var */ -#include "gwps.h" /* for keys_locked */ +#include "action.h" /* for keys_locked */ #include "statusbar.h" @@ -178,7 +178,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) #ifdef HAS_BUTTON_HOLD bar->info.keylock = button_hold(); #else - bar->info.keylock = keys_locked; + bar->info.keylock = is_keys_locked(); #endif /* HAS_BUTTON_HOLD */ #ifdef HAS_REMOTE_BUTTON_HOLD 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[] = { { ACTION_WPS_VOLUP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_WPS_BROWSE, BUTTON_MENU|BUTTON_REL, 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 }; 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[] = { { ACTION_WPS_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU }, { ACTION_WPS_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, { ACTION_WPS_ID3SCREEN, BUTTON_MENU|BUTTON_ON, BUTTON_NONE }, + { ACTION_STD_KEYLOCK, BUTTON_MENU|BUTTON_STOP, BUTTON_NONE }, LAST_ITEM_IN_LIST }; 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[] = { { ACTION_WPS_ID3SCREEN, BUTTON_F1|BUTTON_ON, BUTTON_F1 }, { ACTION_WPS_PITCHSCREEN, BUTTON_ON|BUTTON_UP, BUTTON_ON }, { ACTION_WPS_PITCHSCREEN, BUTTON_ON|BUTTON_DOWN, BUTTON_ON }, + { ACTION_STD_KEYLOCK, BUTTON_F1|BUTTON_DOWN, BUTTON_NONE }, + LAST_ITEM_IN_LIST }; -- cgit v1.2.3