summaryrefslogtreecommitdiff
path: root/apps/action.c
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/action.c
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/action.c')
-rw-r--r--apps/action.c88
1 files changed, 48 insertions, 40 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