summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/viewer.c5
-rw-r--r--firmware/drivers/button.c59
-rw-r--r--firmware/drivers/button.h9
3 files changed, 13 insertions, 60 deletions
diff --git a/apps/viewer.c b/apps/viewer.c
index a588852b4c..f653866626 100644
--- a/apps/viewer.c
+++ b/apps/viewer.c
@@ -334,15 +334,12 @@ bool viewer_run(char* file)
334 int button; 334 int button;
335 int col = 0; 335 int col = 0;
336 int ok; 336 int ok;
337 int oldmask;
338 337
339#ifdef HAVE_LCD_BITMAP 338#ifdef HAVE_LCD_BITMAP
340 /* no margins */ 339 /* no margins */
341 lcd_setmargins(0, 0); 340 lcd_setmargins(0, 0);
342#endif 341#endif
343 342
344 oldmask = button_set_release(~0);
345
346 ok = viewer_init(file); 343 ok = viewer_init(file);
347 if (!ok) { 344 if (!ok) {
348 lcd_clear_display(); 345 lcd_clear_display();
@@ -431,7 +428,5 @@ bool viewer_run(char* file)
431 return true; 428 return true;
432 } 429 }
433 } 430 }
434 button_set_release(oldmask);
435 return false; 431 return false;
436} 432}
437
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index e70246314d..ea3ffadffd 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -47,9 +47,6 @@ long last_keypress;
47/* speed repeat finishes at */ 47/* speed repeat finishes at */
48#define REPEAT_INTERVAL_FINISH 2 48#define REPEAT_INTERVAL_FINISH 2
49 49
50static int repeat_mask = DEFAULT_REPEAT_MASK;
51static int release_mask = DEFAULT_RELEASE_MASK;
52
53static int button_read(void); 50static int button_read(void);
54 51
55static void button_tick(void) 52static void button_tick(void)
@@ -79,10 +76,9 @@ static void button_tick(void)
79 76
80 /* Find out if a key has been released */ 77 /* Find out if a key has been released */
81 diff = btn ^ lastbtn; 78 diff = btn ^ lastbtn;
82 if((btn & diff) == 0) 79 if(diff && (btn & diff) == 0)
83 { 80 {
84 if(diff & release_mask) 81 queue_post(&button_queue, BUTTON_REL | diff, NULL);
85 queue_post(&button_queue, BUTTON_REL | diff, NULL);
86 } 82 }
87 83
88 if ( btn ) 84 if ( btn )
@@ -111,36 +107,21 @@ static void button_tick(void)
111 } 107 }
112 else 108 else
113 { 109 {
114 if(btn & repeat_mask || 110 if (count++ > REPEAT_START)
115#ifdef HAVE_RECORDER_KEYPAD
116 btn == BUTTON_OFF)
117#else
118 btn == BUTTON_STOP)
119#endif
120 { 111 {
121 if (count++ > REPEAT_START) 112 post = true;
122 { 113 repeat = true;
123 /* Only repeat if a repeatable key is pressed */ 114 /* initial repeat */
124 if(btn & repeat_mask) 115 count = REPEAT_INTERVAL_START;
125 { 116
126 post = true; 117 /* Reboot if the OFF button is pressed long enough
127 repeat = true; 118 and we are connected to a charger. */
128 /* initial repeat */
129 count = REPEAT_INTERVAL_START;
130 }
131 /* Reboot if the OFF button is pressed long enough
132 and we are connected to a charger. */
133#ifdef HAVE_RECORDER_KEYPAD 119#ifdef HAVE_RECORDER_KEYPAD
134 if(btn == BUTTON_OFF && charger_inserted()) 120 if(btn == BUTTON_OFF && charger_inserted())
135#elif HAVE_PLAYER_KEYPAD 121#elif HAVE_PLAYER_KEYPAD
136 if(btn == BUTTON_STOP && charger_inserted()) 122 if(btn == BUTTON_STOP && charger_inserted())
137#endif 123#endif
138 system_reboot(); 124 system_reboot();
139 }
140 }
141 else
142 {
143 count = 0;
144 } 125 }
145 } 126 }
146 } 127 }
@@ -197,20 +178,6 @@ int button_get_w_tmo(int ticks)
197 return BUTTON_NONE; 178 return BUTTON_NONE;
198} 179}
199 180
200int button_set_repeat(int newmask)
201{
202 int oldmask = repeat_mask;
203 repeat_mask = newmask;
204 return oldmask;
205}
206
207int button_set_release(int newmask)
208{
209 int oldmask = release_mask;
210 release_mask = newmask;
211 return oldmask;
212}
213
214#ifdef HAVE_RECORDER_KEYPAD 181#ifdef HAVE_RECORDER_KEYPAD
215 182
216/* AJBR buttons are connected to the CPU as follows: 183/* AJBR buttons are connected to the CPU as follows:
diff --git a/firmware/drivers/button.h b/firmware/drivers/button.h
index 4e37057138..d961e775d0 100644
--- a/firmware/drivers/button.h
+++ b/firmware/drivers/button.h
@@ -28,8 +28,6 @@ extern long last_keypress;
28void button_init (void); 28void button_init (void);
29int button_get (bool block); 29int button_get (bool block);
30int button_get_w_tmo(int ticks); 30int button_get_w_tmo(int ticks);
31int button_set_repeat(int newmask);
32int button_set_release(int newmask);
33 31
34/* Shared button codes */ 32/* Shared button codes */
35#define BUTTON_NONE 0x0000 33#define BUTTON_NONE 0x0000
@@ -59,9 +57,6 @@ int button_set_release(int newmask);
59#define BUTTON_F2 0x0200 57#define BUTTON_F2 0x0200
60#define BUTTON_F3 0x0400 58#define BUTTON_F3 0x0400
61 59
62#define DEFAULT_REPEAT_MASK (BUTTON_LEFT | BUTTON_RIGHT | \
63 BUTTON_UP | BUTTON_DOWN)
64
65#define ALL_BUTTONS (BUTTON_ON | BUTTON_UP | BUTTON_DOWN | BUTTON_LEFT | \ 60#define ALL_BUTTONS (BUTTON_ON | BUTTON_UP | BUTTON_DOWN | BUTTON_LEFT | \
66 BUTTON_RIGHT | BUTTON_OFF | BUTTON_PLAY | BUTTON_F1 | \ 61 BUTTON_RIGHT | BUTTON_OFF | BUTTON_PLAY | BUTTON_F1 | \
67 BUTTON_F2 | BUTTON_F3) 62 BUTTON_F2 | BUTTON_F3)
@@ -73,15 +68,11 @@ int button_set_release(int newmask);
73#define BUTTON_PLAY BUTTON_UP 68#define BUTTON_PLAY BUTTON_UP
74#define BUTTON_STOP BUTTON_DOWN 69#define BUTTON_STOP BUTTON_DOWN
75 70
76#define DEFAULT_REPEAT_MASK (BUTTON_LEFT | BUTTON_RIGHT)
77
78#define ALL_BUTTONS (BUTTON_ON | BUTTON_UP | BUTTON_DOWN | BUTTON_LEFT | \ 71#define ALL_BUTTONS (BUTTON_ON | BUTTON_UP | BUTTON_DOWN | BUTTON_LEFT | \
79 BUTTON_RIGHT | BUTTON_MENU) 72 BUTTON_RIGHT | BUTTON_MENU)
80 73
81#endif /* HAVE_PLAYER_KEYPAD */ 74#endif /* HAVE_PLAYER_KEYPAD */
82 75
83#define DEFAULT_RELEASE_MASK ALL_BUTTONS
84
85#endif 76#endif
86 77
87/* ----------------------------------------------------------------- 78/* -----------------------------------------------------------------