summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-07-24 15:21:08 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-07-24 15:21:08 +0000
commit51065bbaee2aeb2ea1c233a9ce34877e6e04ca80 (patch)
tree0138cdf732debd28a40eb75a4c2119092f792b30 /firmware
parente8e55e2aa33ee1cf828b24ced59be4ce5e42436f (diff)
downloadrockbox-51065bbaee2aeb2ea1c233a9ce34877e6e04ca80.tar.gz
rockbox-51065bbaee2aeb2ea1c233a9ce34877e6e04ca80.zip
Added key repeat control
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1433 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/button.c19
-rw-r--r--firmware/drivers/button.h7
2 files changed, 22 insertions, 4 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 8dec7696a8..b1bfdd8957 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -35,6 +35,8 @@ struct event_queue button_queue;
35#define REPEAT_START 6 35#define REPEAT_START 6
36#define REPEAT_INTERVAL 4 36#define REPEAT_INTERVAL 4
37 37
38static int repeat_mask = DEFAULT_REPEAT_MASK;
39
38static int button_read(void); 40static int button_read(void);
39 41
40static void button_tick(void) 42static void button_tick(void)
@@ -63,9 +65,13 @@ static void button_tick(void)
63 } 65 }
64 } 66 }
65 else if (count++ > REPEAT_START) { 67 else if (count++ > REPEAT_START) {
66 post = true; 68 /* Only repeat if a repeatable key is pressed */
67 repeat = true; 69 if(btn & repeat_mask)
68 count = REPEAT_INTERVAL; 70 {
71 post = true;
72 repeat = true;
73 count = REPEAT_INTERVAL;
74 }
69 /* If the OFF button is pressed long enough, and we are 75 /* If the OFF button is pressed long enough, and we are
70 still alive, then the unit must be connected to a 76 still alive, then the unit must be connected to a
71 charger. Therefore we will reboot and let the original 77 charger. Therefore we will reboot and let the original
@@ -145,6 +151,13 @@ void button_init()
145 tick_add_task(button_tick); 151 tick_add_task(button_tick);
146} 152}
147 153
154int button_set_repeat(int newmask)
155{
156 int oldmask = repeat_mask;
157 repeat_mask = newmask;
158 return oldmask;
159}
160
148/* 161/*
149 * Get button pressed from hardware 162 * Get button pressed from hardware
150 */ 163 */
diff --git a/firmware/drivers/button.h b/firmware/drivers/button.h
index 8eacab29c5..0ff6b58291 100644
--- a/firmware/drivers/button.h
+++ b/firmware/drivers/button.h
@@ -26,6 +26,7 @@ extern struct event_queue button_queue;
26 26
27void button_init (void); 27void button_init (void);
28int button_get (bool block); 28int button_get (bool block);
29int button_set_repeat(int newmask);
29 30
30/* Shared button codes */ 31/* Shared button codes */
31#define BUTTON_NONE 0x0000 32#define BUTTON_NONE 0x0000
@@ -39,7 +40,6 @@ int button_get (bool block);
39#define BUTTON_HELD 0x4000 40#define BUTTON_HELD 0x4000
40#define BUTTON_REL 0x8000 41#define BUTTON_REL 0x8000
41 42
42
43#ifdef HAVE_RECORDER_KEYPAD 43#ifdef HAVE_RECORDER_KEYPAD
44 44
45/* Recorder specific button codes */ 45/* Recorder specific button codes */
@@ -49,6 +49,9 @@ int button_get (bool block);
49#define BUTTON_F2 0x0200 49#define BUTTON_F2 0x0200
50#define BUTTON_F3 0x0400 50#define BUTTON_F3 0x0400
51 51
52#define DEFAULT_REPEAT_MASK (BUTTON_LEFT | BUTTON_RIGHT | \
53 BUTTON_UP | BUTTON_DOWN)
54
52#elif HAVE_PLAYER_KEYPAD 55#elif HAVE_PLAYER_KEYPAD
53 56
54/* Jukebox 6000 and Studio specific button codes */ 57/* Jukebox 6000 and Studio specific button codes */
@@ -56,6 +59,8 @@ int button_get (bool block);
56#define BUTTON_PLAY BUTTON_UP 59#define BUTTON_PLAY BUTTON_UP
57#define BUTTON_STOP BUTTON_DOWN 60#define BUTTON_STOP BUTTON_DOWN
58 61
62#define DEFAULT_REPEAT_MASK (BUTTON_LEFT | BUTTON_RIGHT)
63
59#endif 64#endif
60 65
61#endif 66#endif