Redesigned the button handling. The code now uses symbolic function defines instead of checking for specific buttons. This makes it easier to add support for new devices with different button layouts.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5091 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2004-09-19 21:58:37 +00:00
parent 17f54a40f1
commit 6c33c51a4c
36 changed files with 1049 additions and 1163 deletions

View file

@ -256,33 +256,25 @@ bool bookmark_autobookmark(void)
{
/* Wait for a key to be pushed */
key = button_get(true);
switch (key)
if (key & BUTTON_REL)
{
case BUTTON_DOWN | BUTTON_REL:
case BUTTON_ON | BUTTON_REL:
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_OFF | BUTTON_REL:
case BUTTON_RIGHT | BUTTON_REL:
case BUTTON_UP | BUTTON_REL:
#ifdef BUTTON_PLAY
if (key & BUTTON_PLAY)
#else
if (key & BUTTON_RIGHT)
#endif
case BUTTON_LEFT | BUTTON_REL:
done = true;
break;
case BUTTON_PLAY | BUTTON_REL:
{
if (global_settings.autocreatebookmark ==
BOOKMARK_RECENT_ONLY_ASK)
write_bookmark(false);
else
write_bookmark(true);
}
done = true;
break;
}
default:
if (default_event_handler(key) == SYS_USB_CONNECTED)
return false;
break;
}
}
return true;
}
@ -520,7 +512,11 @@ bool bookmark_autoload(const char* file)
case BUTTON_DOWN:
return bookmark_load(global_bookmark_file_name, false);
#endif
#ifdef BUTTON_PLAY
case BUTTON_PLAY:
#else
case BUTTON_RIGHT:
#endif
return bookmark_load(global_bookmark_file_name, true);
default:
@ -668,7 +664,10 @@ static char* select_bookmark(const char* bookmark_file_name)
key = button_get(true);
switch(key)
{
case BUTTON_PLAY:
case SETTINGS_OK:
#ifdef SETTINGS_OK2
case SETTINGS_OK2:
#endif
/* User wants to use this bookmark */
#ifdef HAVE_LCD_BITMAP
if (global_settings.statusbar)
@ -678,7 +677,11 @@ static char* select_bookmark(const char* bookmark_file_name)
#endif
return bookmark;
#if defined(BUTTON_ON) && defined(BUTTON_PLAY)
case BUTTON_ON | BUTTON_PLAY:
#elif defined(BUTTON_MENU) && defined(BUTTON_RIGHT)
case BUTTON_MENU | BUTTON_RIGHT:
#endif
/* User wants to delete this bookmark */
delete_bookmark(bookmark_file_name, bookmark_id);
bookmark_id_prev=-1;
@ -687,36 +690,20 @@ static char* select_bookmark(const char* bookmark_file_name)
while (button_get(false)); /* clear button queue */
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
case SETTINGS_DEC:
bookmark_id--;
break;
case BUTTON_DOWN:
case SETTINGS_INC:
bookmark_id++;
break;
case BUTTON_LEFT:
case BUTTON_OFF:
#ifdef HAVE_LCD_BITMAP
if (global_settings.statusbar)
lcd_setmargins(0, STATUSBAR_HEIGHT);
else
lcd_setmargins(0, 0);
case SETTINGS_CANCEL:
#ifdef SETTINGS_CANCEL2
case SETTINGS_CANCEL2:
#endif
return NULL;
#else
case BUTTON_LEFT:
bookmark_id--;
break;
case BUTTON_RIGHT:
bookmark_id++;
break;
case BUTTON_STOP:
return NULL;
#endif
default:
if(default_event_handler(key) == SYS_USB_CONNECTED)
return NULL;

View file

@ -54,7 +54,7 @@ void roll_credits(void)
}
/* abort on keypress */
if (button_get_w_tmo(DISPLAY_TIME))
if (button_get_w_tmo(DISPLAY_TIME) & BUTTON_REL)
return;
}
return;

View file

@ -93,10 +93,7 @@ bool dbg_os(void)
switch(button)
{
#ifdef BUTTON_OFF
case BUTTON_OFF:
#endif
case BUTTON_LEFT:
case SETTINGS_CANCEL:
return false;
}
}
@ -127,16 +124,16 @@ bool dbg_os(void)
switch(button)
{
case BUTTON_STOP:
case SETTINGS_CANCEL:
return false;
case BUTTON_LEFT:
case SETTINGS_DEC:
currval--;
if(currval < 0)
currval = num_threads-1;
break;
case BUTTON_RIGHT:
case SETTINGS_INC:
currval++;
if(currval > num_threads-1)
currval = 0;
@ -161,7 +158,7 @@ bool dbg_mpeg_thread(void)
button = button_get_w_tmo(HZ/5);
switch(button)
{
case BUTTON_OFF | BUTTON_REL:
case SETTINGS_CANCEL:
return false;
}
@ -375,7 +372,7 @@ bool dbg_hw_info(void)
while(1)
{
button = button_get(true);
if(button == (BUTTON_OFF | BUTTON_REL))
if(button == SETTINGS_CANCEL)
return false;
}
@ -460,16 +457,16 @@ bool dbg_hw_info(void)
switch(button)
{
case BUTTON_STOP:
case SETTINGS_CANCEL:
return false;
case BUTTON_LEFT:
case SETTINGS_DEC:
currval--;
if(currval < 0)
currval = 5;
break;
case BUTTON_RIGHT:
case SETTINGS_INC:
currval++;
if(currval > 5)
currval = 0;
@ -507,26 +504,17 @@ bool dbg_partitions(void)
switch(button)
{
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_OFF:
#else
case BUTTON_STOP:
#endif
case SETTINGS_OK:
case SETTINGS_CANCEL:
return false;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
#endif
case BUTTON_LEFT:
case SETTINGS_DEC:
partition--;
if (partition < 0)
partition = 3;
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_DOWN:
#endif
case BUTTON_RIGHT:
case SETTINGS_INC:
partition++;
if (partition > 3)
partition = 0;
@ -595,7 +583,7 @@ bool dbg_ports(void)
switch(button)
{
case BUTTON_OFF | BUTTON_REL:
case SETTINGS_CANCEL:
return false;
}
}
@ -675,16 +663,16 @@ bool dbg_ports(void)
switch(button)
{
case BUTTON_STOP | BUTTON_REL:
case SETTINGS_CANCEL:
return false;
case BUTTON_LEFT:
case SETTINGS_DEC:
currval--;
if(currval < 0)
currval = 10;
break;
case BUTTON_RIGHT:
case SETTINGS_INC:
currval++;
if(currval > 10)
currval = 0;
@ -727,19 +715,24 @@ bool dbg_rtc(void)
switch(button)
{
case BUTTON_DOWN:
case SETTINGS_INC:
if (addr < 63-16) { addr += 16; }
break;
case BUTTON_UP:
case SETTINGS_DEC:
if (addr) { addr -= 16; }
break;
#ifdef BUTTON_F2
case BUTTON_F2:
/* clear the user RAM space */
for (c = 0; c <= 43; c++)
rtc_write(0x14 + c, 0);
break;
case BUTTON_OFF | BUTTON_REL:
case BUTTON_LEFT | BUTTON_REL:
#endif
case SETTINGS_OK:
case SETTINGS_CANCEL:
return false;
}
}
@ -781,25 +774,16 @@ bool dbg_mas(void)
switch(button_get_w_tmo(HZ/16))
{
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_DOWN:
#else
case BUTTON_RIGHT:
#endif
case SETTINGS_INC:
addr = (addr + NUMROWS) & 0xFF; /* register addrs are 8 bit */
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
#else
case BUTTON_LEFT:
#endif
case SETTINGS_DEC:
addr = (addr - NUMROWS) & 0xFF; /* register addrs are 8 bit */
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_LEFT:
#else
case BUTTON_DOWN:
#endif
case SETTINGS_OK:
case SETTINGS_CANCEL:
return false;
}
}
@ -830,14 +814,15 @@ bool dbg_mas_codec(void)
switch(button_get_w_tmo(HZ/16))
{
case BUTTON_DOWN:
case SETTINGS_INC:
addr += 4;
break;
case BUTTON_UP:
case SETTINGS_DEC:
if (addr) { addr -= 4; }
break;
case BUTTON_LEFT | BUTTON_REL:
case BUTTON_OFF | BUTTON_REL:
case SETTINGS_OK:
case SETTINGS_CANCEL:
return false;
}
}
@ -994,18 +979,18 @@ bool view_battery(void)
switch(button_get_w_tmo(HZ/2))
{
case BUTTON_UP:
case SETTINGS_DEC:
if (view)
view--;
break;
case BUTTON_DOWN:
case SETTINGS_INC:
if (view < 3)
view++;
break;
case BUTTON_LEFT | BUTTON_REL:
case BUTTON_OFF | BUTTON_REL:
case SETTINGS_OK:
case SETTINGS_CANCEL:
return false;
}
}
@ -1148,21 +1133,22 @@ bool dbg_mas_info(void)
button = button_get_w_tmo(HZ/5);
switch(button)
{
case BUTTON_STOP:
case SETTINGS_CANCEL:
return false;
case BUTTON_LEFT:
case SETTINGS_DEC:
currval--;
if(currval < 0)
currval = 23;
break;
case BUTTON_RIGHT:
case SETTINGS_INC:
currval++;
if(currval > 23)
currval = 0;
break;
case BUTTON_PLAY:
case SETTINGS_OK:
pll_toggle = !pll_toggle;
if(pll_toggle)
{
@ -1233,23 +1219,19 @@ static bool view_runtime(void)
/* Wait for a key to be pushed */
key = button_get_w_tmo(HZ);
switch(key) {
#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
case BUTTON_STOP | BUTTON_REL:
#elif HAVE_RECORDER_KEYPAD
case BUTTON_OFF | BUTTON_REL:
#endif
case SETTINGS_CANCEL:
done = true;
break;
case BUTTON_LEFT:
case BUTTON_RIGHT:
case SETTINGS_INC:
case SETTINGS_DEC:
if (state == 1)
state = 2;
else
state = 1;
break;
case BUTTON_PLAY:
case SETTINGS_OK:
lcd_clear_display();
lcd_puts(0,0,"Clear time?");
lcd_puts(0,1,"PLAY = Yes");
@ -1258,7 +1240,7 @@ static bool view_runtime(void)
key = button_get_w_tmo(HZ*10);
if ( key & BUTTON_REL )
continue;
if ( key == BUTTON_PLAY ) {
if ( key == SETTINGS_OK ) {
if ( state == 1 )
global_settings.runtime = 0;
else
@ -1412,25 +1394,21 @@ static bool dbg_disk_info(void)
/* Wait for a key to be pushed */
key = button_get_w_tmo(HZ*5);
switch(key) {
#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
case BUTTON_STOP | BUTTON_REL:
#else
case BUTTON_OFF | BUTTON_REL:
#endif
case SETTINGS_CANCEL:
done = true;
break;
case BUTTON_LEFT:
case SETTINGS_DEC:
if (--page < 0)
page = max_page;
break;
case BUTTON_RIGHT:
case SETTINGS_INC:
if (++page > max_page)
page = 0;
break;
case BUTTON_PLAY:
case SETTINGS_OK:
if (page == 3) {
mpeg_stop(); /* stop playback, to avoid disk access */
lcd_clear_display();
@ -1498,11 +1476,7 @@ bool dbg_fm_radio(void)
switch(button)
{
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_OFF:
#else
case BUTTON_STOP:
#endif
case SETTINGS_CANCEL:
return false;
}
}

View file

@ -169,7 +169,7 @@ void init(void)
lcd_puts(0, 1, str);
lcd_puts(0, 3, "Press ON to debug");
lcd_update();
while(button_get(true) != BUTTON_ON);
while(!(button_get(true) & BUTTON_REL));
dbg_ports();
#endif
panicf("ata: %d", rc);

View file

@ -231,24 +231,19 @@ bool show_info(void)
/* Wait for a key to be pushed */
key = button_get_w_tmo(HZ*5);
switch(key) {
#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
case BUTTON_STOP | BUTTON_REL:
#else
case BUTTON_LEFT | BUTTON_REL:
case BUTTON_OFF | BUTTON_REL:
#endif
case SETTINGS_OK:
case SETTINGS_CANCEL:
done = true;
break;
#if defined(HAVE_RECORDER_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
case BUTTON_LEFT:
case BUTTON_RIGHT:
case SETTINGS_INC:
case SETTINGS_DEC:
if (state == 1)
state = 2;
else
state = 1;
break;
#endif
default:
if(default_event_handler(key) == SYS_USB_CONNECTED)
return true;

View file

@ -288,11 +288,17 @@ int menu_show(int m)
}
menu_lines = height / fh;
#else
int menu_lines = MENU_LINES;
#endif
/* Put the cursor on the first line and draw the menu */
put_cursor(m, menus[m].cursor);
/* wait until all keys are released */
while (button_get(false) != BUTTON_NONE)
yield();
while (!exit) {
key = button_get_w_tmo(HZ/2);
@ -308,25 +314,15 @@ int menu_show(int m)
key = menus[m].callback(key, m);
switch( key ) {
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT:
#else
case BUTTON_LEFT:
case BUTTON_LEFT | BUTTON_REPEAT:
#endif
case MENU_PREV:
case MENU_PREV | BUTTON_REPEAT:
if (menus[m].cursor) {
/* move up */
put_cursor(m, menus[m].cursor-1);
}
else {
/* move to bottom */
#ifdef HAVE_RECORDER_KEYPAD
menus[m].top = menus[m].itemcount-(menu_lines+1);
#else
menus[m].top = menus[m].itemcount-3;
#endif
if (menus[m].top < 0)
menus[m].top = 0;
menus[m].cursor = menus[m].itemcount-1;
@ -334,13 +330,8 @@ int menu_show(int m)
}
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_DOWN:
case BUTTON_DOWN | BUTTON_REPEAT:
#else
case BUTTON_RIGHT:
case BUTTON_RIGHT | BUTTON_REPEAT:
#endif
case MENU_NEXT:
case MENU_NEXT | BUTTON_REPEAT:
if (menus[m].cursor < menus[m].itemcount-1) {
/* move down */
put_cursor(m, menus[m].cursor+1);
@ -353,22 +344,23 @@ int menu_show(int m)
}
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_RIGHT:
case MENU_ENTER:
#ifdef MENU_ENTER2
case MENU_ENTER2:
#endif
case BUTTON_PLAY:
/* Erase current display state */
lcd_clear_display();
return menus[m].cursor;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_LEFT:
case BUTTON_F1:
case BUTTON_OFF | BUTTON_REPEAT:
#else
case BUTTON_STOP:
case BUTTON_MENU:
case BUTTON_STOP | BUTTON_REPEAT:
case MENU_EXIT:
case MENU_EXIT | BUTTON_REPEAT:
#ifdef MENU_EXIT2
case MENU_EXIT2:
case MENU_EXIT2 | BUTTON_REPEAT:
#endif
#ifdef MENU_EXIT3
case MENU_EXIT3:
case MENU_EXIT3 | BUTTON_REPEAT:
#endif
lcd_stop_scroll();
exit = true;
@ -388,14 +380,17 @@ int menu_show(int m)
bool menu_run(int m)
{
bool stop=false;
while (!stop) {
int result=menu_show(m);
if (result == MENU_SELECTED_EXIT)
while (1) {
switch (menu_show(m))
{
case MENU_SELECTED_EXIT:
return false;
else if (result == MENU_ATTACHED_USB)
case MENU_ATTACHED_USB:
return true;
if (menus[m].items[menus[m].cursor].function()) {
default:
if (menus[m].items[menus[m].cursor].function())
return true;
}
}

View file

@ -22,6 +22,32 @@
#include <stdbool.h>
/* button definitions */
#ifdef HAVE_RECORDER_KEYPAD
#define MENU_NEXT BUTTON_DOWN
#define MENU_PREV BUTTON_UP
#define MENU_EXIT (BUTTON_LEFT | BUTTON_REL)
#define MENU_EXIT2 (BUTTON_OFF | BUTTON_REL)
#define MENU_EXIT3 (BUTTON_F1 | BUTTON_REL)
#define MENU_ENTER (BUTTON_RIGHT | BUTTON_REL)
#define MENU_ENTER2 (BUTTON_PLAY | BUTTON_REL)
#elif defined HAVE_PLAYER_KEYPAD
#define MENU_NEXT BUTTON_RIGHT
#define MENU_PREV BUTTON_LEFT
#define MENU_EXIT (BUTTON_STOP | BUTTON_REL)
#define MENU_EXIT2 (BUTTON_MENU | BUTTON_REL)
#define MENU_ENTER (BUTTON_PLAY | BUTTON_REL)
#elif defined HAVE_ONDIO_KEYPAD
#define MENU_NEXT BUTTON_DOWN
#define MENU_PREV BUTTON_UP
#define MENU_EXIT (BUTTON_LEFT | BUTTON_REL)
#define MENU_EXIT2 (BUTTON_MENU | BUTTON_REL)
#define MENU_ENTER (BUTTON_RIGHT | BUTTON_REL)
#endif
struct menu_item {
unsigned char *desc; /* string or ID */
bool (*function) (void); /* return true if USB was connected */

View file

@ -16,6 +16,7 @@
* KIND, either express or implied.
*
****************************************************************************/
#include <stdlib.h>
#include <ctype.h>
#include "lang.h"
#include "string.h"
@ -206,7 +207,9 @@ bool settings_parseline(char* line, char** name, char** value)
bool clean_shutdown(void)
{
#ifndef SIMULATOR
#ifdef SIMULATOR
exit(0);
#else
if(!charger_inserted())
{
lcd_clear_display();

View file

@ -116,10 +116,11 @@ static bool add_to_playlist(int position, bool queue)
while (!exit) {
int btn = button_get(true);
switch (btn) {
case BUTTON_PLAY:
case SETTINGS_OK:
recurse = true;
exit = true;
break;
default:
/* ignore button releases */
if (!(btn & BUTTON_REL))
@ -303,7 +304,7 @@ static bool delete_handler(bool is_dir)
while (!exit) {
int btn = button_get(true);
switch (btn) {
case BUTTON_PLAY:
case SETTINGS_OK:
if (is_dir)
{
char pathname[MAX_PATH]; /* space to go deep */

View file

@ -181,14 +181,15 @@ int kbd_input(char* text, int buflen)
case MENU_LINE_INPUT:
switch (button_pressed)
{
case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT:
case BUTTON_PLAY:
case BUTTON_PLAY | BUTTON_REPEAT:
if (cursor_pos<len)
cursor_pos++;
button_pressed=BUTTON_NONE;
break;
case BUTTON_DOWN:
case BUTTON_DOWN | BUTTON_REPEAT:
case BUTTON_STOP:
case BUTTON_STOP | BUTTON_REPEAT:
if (cursor_pos>0)
cursor_pos--;
button_pressed=BUTTON_NONE;
@ -199,13 +200,13 @@ int kbd_input(char* text, int buflen)
case MENU_LINE_NEWCHARS:
switch (button_pressed)
{
case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT:
case BUTTON_PLAY:
case BUTTON_PLAY | BUTTON_REPEAT:
x=(x+1+linelen)%linelen;
button_pressed=BUTTON_NONE;
break;
case BUTTON_DOWN:
case BUTTON_DOWN | BUTTON_REPEAT:
case BUTTON_STOP:
case BUTTON_STOP | BUTTON_REPEAT:
x=(x-1+linelen)%linelen;
button_pressed=BUTTON_NONE;
break;

View file

@ -564,11 +564,7 @@ static int add_directory_to_playlist(struct playlist_info* playlist,
for (i=0; i<num_files; i++)
{
/* user abort */
#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
if (button_get(false) == BUTTON_STOP)
#else
if (button_get(false) == BUTTON_OFF)
#endif
if (button_get(false) == SETTINGS_CANCEL)
{
result = -1;
break;
@ -2016,11 +2012,7 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
while ((max = read_line(fd, temp_buf, sizeof(temp_buf))) > 0)
{
/* user abort */
#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
if (button_get(false) == BUTTON_STOP)
#else
if (button_get(false) == BUTTON_OFF)
#endif
if (button_get(false) == SETTINGS_CANCEL)
break;
if (temp_buf[0] != '#' && temp_buf[0] != '\0')
@ -2384,11 +2376,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
int seek;
/* user abort */
#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
if (button_get(false) == BUTTON_STOP)
#else
if (button_get(false) == BUTTON_OFF)
#endif
if (button_get(false) == SETTINGS_CANCEL)
break;
control_file = playlist->indices[index] & PLAYLIST_INSERT_TYPE_MASK;

View file

@ -130,7 +130,7 @@ static void update_display_line(int line, bool scroll);
static void scroll_display(int lines);
static void update_first_index(void);
static bool update_playlist(bool force);
#ifdef BUTTON_ON
#ifdef TREE_SHIFT
static int onplay_menu(int index);
#endif
static bool viewer_menu(void);
@ -672,7 +672,7 @@ static bool update_playlist(bool force)
return true;
}
#ifdef BUTTON_ON
#ifdef TREE_SHIFT
/* Menu of playlist commands. Invoked via ON+PLAY on main viewer screen.
Returns -1 if USB attached, 0 if no playlist change, and 1 if playlist
changed. */
@ -902,67 +902,37 @@ bool playlist_viewer_ex(char* filename)
switch (button)
{
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_OFF:
case BUTTON_LEFT:
#else
case BUTTON_STOP:
#endif
case TREE_EXIT:
exit = true;
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT:
#else
case BUTTON_LEFT:
case BUTTON_LEFT | BUTTON_REPEAT:
#endif
case TREE_PREV:
case TREE_PREV | BUTTON_REPEAT:
scroll_display(-1);
update = true;
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_DOWN:
case BUTTON_DOWN | BUTTON_REPEAT:
#else
case BUTTON_RIGHT:
case BUTTON_RIGHT | BUTTON_REPEAT:
#endif
case TREE_NEXT:
case TREE_NEXT | BUTTON_REPEAT:
scroll_display(1);
update = true;
break;
#ifdef BUTTON_ON
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_ON | BUTTON_UP:
case BUTTON_ON | BUTTON_UP | BUTTON_REPEAT:
#else
case BUTTON_ON | BUTTON_LEFT:
case BUTTON_ON | BUTTON_LEFT | BUTTON_REPEAT:
#endif
case TREE_SHIFT | TREE_PREV:
case TREE_SHIFT | TREE_PREV | BUTTON_REPEAT:
/* Pageup */
scroll_display(-viewer.num_display_lines);
update = true;
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_ON | BUTTON_DOWN:
case BUTTON_ON | BUTTON_DOWN | BUTTON_REPEAT:
#else
case BUTTON_ON | BUTTON_RIGHT:
case BUTTON_ON | BUTTON_RIGHT | BUTTON_REPEAT:
#endif
case TREE_SHIFT | TREE_NEXT:
case TREE_SHIFT | TREE_NEXT | BUTTON_REPEAT:
/* Pagedown */
scroll_display(viewer.num_display_lines);
update = true;
break;
#endif /* BUTTON_ON */
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_RIGHT:
#endif
case BUTTON_PLAY:
case TREE_RUN:
if (viewer.move_track >= 0)
{
/* Move track */
@ -1003,8 +973,7 @@ bool playlist_viewer_ex(char* filename)
update = true;
break;
#ifdef BUTTON_ON
case BUTTON_ON | BUTTON_PLAY:
case TREE_SHIFT | TREE_RUN:
{
/* ON+PLAY menu */
int ret;
@ -1030,12 +999,8 @@ bool playlist_viewer_ex(char* filename)
update = true;
break;
}
#endif /* BUTTON_ON */
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_F1:
#else
case BUTTON_MENU:
#endif
case TREE_MENU:
if (viewer_menu())
{
ret = true;

View file

@ -71,6 +71,8 @@ static void calendar_init(struct today *today, struct shown *shown)
int w,h;
#ifdef HAVE_RTC
struct tm *tm;
#else
(void)today;
#endif
rb->lcd_getstringsize("A",&w,&h);
if ( ((w * 14) > LCD_WIDTH) || ((h * 7) > LCD_HEIGHT) )

View file

@ -33,6 +33,7 @@
#define KEYBOARD_LINES 4
#define KEYBOARD_PAGES 3
#ifdef HAVE_RECORDER_KEYPAD
static void kbd_setupkeys(const char* line[KEYBOARD_LINES], int page)
{
switch (page) {
@ -58,6 +59,7 @@ static void kbd_setupkeys(const char* line[KEYBOARD_LINES], int page)
break;
}
}
#endif
/* helper function to spell a char if voice UI is enabled */
void kbd_spellchar(char c)
@ -75,6 +77,12 @@ void kbd_spellchar(char c)
int kbd_input(char* text, int buflen)
{
#ifndef HAVE_RECORDER_KEYPAD
(void)text;
(void)buflen;
splash(HZ*2, true, "Keyboard not implemented yet");
return 0;
#else
bool done = false;
int page = 0;
@ -240,7 +248,6 @@ int kbd_input(char* text, int buflen)
kbd_spellchar(line[y][x]);
break;
#if (BUTTON_UP != BUTTON_PLAY) /* FixMe, this is just to make the Ondio compile */
case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT:
if (y)
@ -249,7 +256,7 @@ int kbd_input(char* text, int buflen)
y = KEYBOARD_LINES - 1;
kbd_spellchar(line[y][x]);
break;
#endif
case BUTTON_F3:
case BUTTON_F3 | BUTTON_REPEAT:
/* backspace */
@ -326,5 +333,7 @@ int kbd_input(char* text, int buflen)
}
}
lcd_setfont(FONT_UI);
return 0;
#endif /* ONDIO */
}

View file

@ -167,6 +167,10 @@ static void remember_frequency(void)
bool radio_screen(void)
{
#ifndef HAVE_RECORDER_KEYPAD
splash(HZ*2, true, "Radio not supported yet");
return false;
#else
char buf[MAX_PATH];
bool done = false;
int button;
@ -554,6 +558,7 @@ bool radio_screen(void)
}
#endif
return have_recorded;
#endif /* ONDIO */
}
void radio_save_presets(void)
@ -663,12 +668,14 @@ static bool radio_add_preset(void)
static int handle_radio_presets_menu_cb(int key, int m)
{
(void)m;
#ifdef HAVE_RECORDER_KEYPAD
switch(key)
{
case BUTTON_F3:
key = BUTTON_LEFT; /* Fake an exit */
break;
}
#endif
return key;
}
@ -725,6 +732,11 @@ bool handle_radio_presets_menu(void)
int handle_radio_presets_cb(int key, int m)
{
#ifdef HAVE_ONDIO_KEYPAD
(void)key;
(void)m;
return BUTTON_NONE;
#else
bool ret;
switch(key)
@ -750,6 +762,7 @@ int handle_radio_presets_cb(int key, int m)
break;
}
return key;
#endif
}
bool handle_radio_presets(void)

View file

@ -166,6 +166,10 @@ int rec_create_directory(void)
bool recording_screen(void)
{
#ifndef HAVE_RECORDING_KEYPAD
splash(HZ*2, true, "Recording not supported yet");
return false;
#else
int button;
bool done = false;
char buf[32];
@ -280,13 +284,12 @@ bool recording_screen(void)
}
break;
#if (BUTTON_UP != BUTTON_PLAY) /* FixMe, this is just to make the Ondio compile */
case BUTTON_UP:
cursor--;
adjust_cursor();
update_countdown = 1; /* Update immediately */
break;
#endif
case BUTTON_DOWN:
cursor++;
adjust_cursor();
@ -619,8 +622,10 @@ bool recording_screen(void)
reload_directory();
return been_in_usb_mode;
#endif
}
#ifdef HAVE_RECORDER_KEYPAD
bool f2_rec_screen(void)
{
bool exit = false;
@ -813,3 +818,4 @@ bool f3_rec_screen(void)
return false;
}
#endif

View file

@ -40,6 +40,7 @@
#include "action.h"
#include "talk.h"
#include "misc.h"
#include "id3.h"
#ifdef HAVE_LCD_BITMAP
#define BMPHEIGHT_usb_logo 32
@ -240,7 +241,7 @@ int charging_screen(void)
{
int button;
int rc = 0;
#ifdef HAVE_RECORDER_KEYPAD
#ifdef BUTTON_OFF
const int offbutton = BUTTON_OFF;
#else
const int offbutton = BUTTON_STOP;
@ -263,7 +264,11 @@ int charging_screen(void)
status_draw(false);
charging_display_info(true);
button = button_get_w_tmo(HZ/3);
#ifdef BUTTON_ON
if (button == (BUTTON_ON | BUTTON_REL))
#else
if (button == (BUTTON_RIGHT | BUTTON_REL))
#endif
rc = 3;
else if (button == offbutton)
rc = 2;
@ -286,7 +291,7 @@ int charging_screen(void)
0 if no key was pressed
1 if a key was pressed (or if ON was held down long enough to repeat)
2 if USB was connected */
int on_screen(void)
int pitch_screen(void)
{
int button;
static int pitch = 1000;
@ -1082,15 +1087,19 @@ bool set_time_screen(const char* string, struct tm *tm)
*valptr = min;
say_time(cursorpos, tm);
break;
#ifdef BUTTON_ON
case BUTTON_ON:
#elif defined BUTTON_MENU
case BUTTON_MENU:
#endif
done = true;
break;
#if (BUTTON_ON != BUTTON_OFF) /* FixMe, this is just to make the Ondio compile */
case BUTTON_OFF:
done = true;
tm->tm_year = -1;
break;
#endif
default:
if (default_event_handler(button) == SYS_USB_CONNECTED)
@ -1140,3 +1149,143 @@ bool shutdown_screen(void)
return false;
}
#endif
bool browse_id3(void)
{
struct mp3entry* id3 = mpeg_current_track();
int button;
int menu_pos = 0;
int menu_max = 8;
bool exit = false;
char scroll_text[MAX_PATH];
if (!(mpeg_status() & MPEG_STATUS_PLAY))
return false;
while (!exit)
{
lcd_clear_display();
switch (menu_pos)
{
case 0:
lcd_puts(0, 0, str(LANG_ID3_TITLE));
lcd_puts_scroll(0, 1, id3->title ? id3->title :
(char*)str(LANG_ID3_NO_TITLE));
break;
case 1:
lcd_puts(0, 0, str(LANG_ID3_ARTIST));
lcd_puts_scroll(0, 1,
id3->artist ? id3->artist :
(char*)str(LANG_ID3_NO_ARTIST));
break;
case 2:
lcd_puts(0, 0, str(LANG_ID3_ALBUM));
lcd_puts_scroll(0, 1, id3->album ? id3->album :
(char*)str(LANG_ID3_NO_ALBUM));
break;
case 3:
lcd_puts(0, 0, str(LANG_ID3_TRACKNUM));
if (id3->tracknum) {
snprintf(scroll_text,sizeof(scroll_text), "%d",
id3->tracknum);
lcd_puts_scroll(0, 1, scroll_text);
}
else
lcd_puts_scroll(0, 1, str(LANG_ID3_NO_TRACKNUM));
break;
case 4:
lcd_puts(0, 0, str(LANG_ID3_GENRE));
lcd_puts_scroll(0, 1,
id3_get_genre(id3) ?
id3_get_genre(id3) :
(char*)str(LANG_ID3_NO_INFO));
break;
case 5:
lcd_puts(0, 0, str(LANG_ID3_YEAR));
if (id3->year) {
snprintf(scroll_text,sizeof(scroll_text), "%d",
id3->year);
lcd_puts_scroll(0, 1, scroll_text);
}
else
lcd_puts_scroll(0, 1, str(LANG_ID3_NO_INFO));
break;
case 6:
lcd_puts(0, 0, str(LANG_ID3_LENGHT));
snprintf(scroll_text,sizeof(scroll_text), "%d:%02d",
id3->length / 60000,
id3->length % 60000 / 1000 );
lcd_puts(0, 1, scroll_text);
break;
case 7:
lcd_puts(0, 0, str(LANG_ID3_PLAYLIST));
snprintf(scroll_text,sizeof(scroll_text), "%d/%d",
playlist_get_display_index(), playlist_amount());
lcd_puts_scroll(0, 1, scroll_text);
break;
case 8:
lcd_puts(0, 0, str(LANG_ID3_BITRATE));
snprintf(scroll_text,sizeof(scroll_text), "%d kbps",
id3->bitrate);
lcd_puts(0, 1, scroll_text);
break;
case 9:
lcd_puts(0, 0, str(LANG_ID3_FRECUENCY));
snprintf(scroll_text,sizeof(scroll_text), "%d Hz",
id3->frequency);
lcd_puts(0, 1, scroll_text);
break;
case 10:
lcd_puts(0, 0, str(LANG_ID3_PATH));
lcd_puts_scroll(0, 1, id3->path);
break;
}
lcd_update();
button = button_get(true);
switch(button)
{
case SETTINGS_DEC:
if (menu_pos > 0)
menu_pos--;
else
menu_pos = menu_max;
break;
case SETTINGS_INC:
if (menu_pos < menu_max)
menu_pos++;
else
menu_pos = 0;
break;
case SETTINGS_CANCEL:
lcd_stop_scroll();
/* eat release event */
button_get(true);
exit = true;
break;
default:
if(default_event_handler(button) == SYS_USB_CONNECTED)
return true;
break;
}
}
return false;
}

View file

@ -27,7 +27,7 @@ int charging_screen(void);
void charging_splash(void);
#ifdef HAVE_RECORDER_KEYPAD
int on_screen(void);
int pitch_screen(void);
bool quick_screen(const int, const int);
#endif
@ -42,6 +42,7 @@ bool set_time_screen(const char* string, struct tm *tm);
#endif
bool shutdown_screen(void);
bool browse_id3(void);
#endif

View file

@ -70,6 +70,7 @@ struct user_settings global_settings;
const char rec_base_directory[] = REC_BASE_DIR;
#define CONFIG_BLOCK_VERSION 16
#define CONFIG_BLOCK_SIZE 512
#define RTC_BLOCK_SIZE 44
@ -1319,40 +1320,26 @@ bool set_int(const char* string,
button = button_get_w_tmo(HZ/2);
switch(button) {
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT:
#else
case BUTTON_RIGHT:
case BUTTON_RIGHT | BUTTON_REPEAT:
#endif
case SETTINGS_INC:
case SETTINGS_INC | BUTTON_REPEAT:
*variable += step;
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_DOWN:
case BUTTON_DOWN | BUTTON_REPEAT:
#else
case BUTTON_LEFT:
case BUTTON_LEFT | BUTTON_REPEAT:
#endif
case SETTINGS_DEC:
case SETTINGS_DEC | BUTTON_REPEAT:
*variable -= step;
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_LEFT:
case BUTTON_PLAY:
#else
case BUTTON_PLAY:
case SETTINGS_OK:
#ifdef SETTINGS_OK2
case SETTINGS_OK2:
#endif
done = true;
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_OFF:
#else
case BUTTON_STOP:
case BUTTON_MENU:
case SETTINGS_CANCEL:
#ifdef SETTINGS_CANCEL2
case SETTINGS_CANCEL2:
#endif
if (*variable != org_value) {
*variable=org_value;
@ -1431,13 +1418,8 @@ bool set_option(const char* string, void* variable, enum optiontype type,
button = button_get_w_tmo(HZ/2);
switch (button) {
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT:
#else
case BUTTON_RIGHT:
case BUTTON_RIGHT | BUTTON_REPEAT:
#endif
case SETTINGS_INC:
case SETTINGS_INC | BUTTON_REPEAT:
if (type == INT) {
if ( *intvar < (numoptions-1) )
(*intvar)++;
@ -1448,13 +1430,8 @@ bool set_option(const char* string, void* variable, enum optiontype type,
*boolvar = !*boolvar;
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_DOWN:
case BUTTON_DOWN | BUTTON_REPEAT:
#else
case BUTTON_LEFT:
case BUTTON_LEFT | BUTTON_REPEAT:
#endif
case SETTINGS_DEC:
case SETTINGS_DEC | BUTTON_REPEAT:
if (type == INT) {
if ( *intvar > 0 )
(*intvar)--;
@ -1465,20 +1442,16 @@ bool set_option(const char* string, void* variable, enum optiontype type,
*boolvar = !*boolvar;
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_LEFT:
case BUTTON_PLAY:
#else
case BUTTON_PLAY:
case SETTINGS_OK:
#ifdef SETTINGS_OK2
case SETTINGS_OK2:
#endif
done = true;
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_OFF:
#else
case BUTTON_STOP:
case BUTTON_MENU:
case SETTINGS_CANCEL:
#ifdef SETTINGS_CANCEL2
case SETTINGS_CANCEL2:
#endif
if (((type==INT) && (*intvar != oldval)) ||
((type==BOOL) && (*boolvar != (bool)oldval))) {

View file

@ -33,6 +33,31 @@
#define MAX_FILENAME 20
/* button definitions */
#ifdef HAVE_RECORDER_KEYPAD
#define SETTINGS_INC BUTTON_UP
#define SETTINGS_DEC BUTTON_DOWN
#define SETTINGS_OK (BUTTON_PLAY|BUTTON_REL)
#define SETTINGS_OK2 (BUTTON_LEFT|BUTTON_REL)
#define SETTINGS_CANCEL (BUTTON_OFF|BUTTON_REL)
#define SETTINGS_CANCEL2 (BUTTON_F1|BUTTON_REL)
#elif defined HAVE_PLAYER_KEYPAD
#define SETTINGS_INC BUTTON_RIGHT
#define SETTINGS_DEC BUTTON_LEFT
#define SETTINGS_OK (BUTTON_PLAY|BUTTON_REL)
#define SETTINGS_CANCEL (BUTTON_STOP|BUTTON_REL)
#define SETTINGS_CANCEL2 (BUTTON_MENU|BUTTON_REL)
#elif defined HAVE_ONDIO_KEYPAD
#define SETTINGS_INC BUTTON_UP
#define SETTINGS_DEC BUTTON_DOWN
#define SETTINGS_OK (BUTTON_RIGHT|BUTTON_REL)
#define SETTINGS_OK2 (BUTTON_LEFT|BUTTON_REL)
#define SETTINGS_CANCEL (BUTTON_MENU|BUTTON_REL)
#endif
/* data structures */
#define RESUME_OFF 0

View file

@ -1066,7 +1066,7 @@ static bool reset_settings(void)
while(!done) {
button = button_get(true);
switch(button) {
case BUTTON_PLAY:
case SETTINGS_OK:
settings_reset();
settings_apply();
lcd_clear_display();
@ -1074,11 +1074,7 @@ static bool reset_settings(void)
done = true;
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_OFF:
#else
case BUTTON_STOP:
#endif
case SETTINGS_CANCEL:
lcd_clear_display();
lcd_puts(0,1,str(LANG_RESET_DONE_CANCEL));
done = true;

View file

@ -69,21 +69,11 @@ bool sleeptimer_screen(void)
button = button_get_w_tmo(HZ);
switch(button)
{
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_LEFT:
case BUTTON_PLAY:
#else
case BUTTON_PLAY:
#endif
case SETTINGS_OK:
done = true;
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_OFF:
#else
case BUTTON_STOP:
case BUTTON_MENU:
#endif
case SETTINGS_CANCEL:
if (changed) {
lcd_stop_scroll();
lcd_puts(0, 0, str(LANG_MENU_SETTING_CANCEL));
@ -94,11 +84,7 @@ bool sleeptimer_screen(void)
done = true;
break;
#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
case BUTTON_RIGHT:
#else
case BUTTON_UP:
#endif
case SETTINGS_INC:
oldtime = (get_sleep_timer()+59) / 60;
if(oldtime < THRESHOLD)
amount = SMALL_STEP_SIZE;
@ -113,11 +99,7 @@ bool sleeptimer_screen(void)
set_sleep_timer(newtime);
break;
#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
case BUTTON_LEFT:
#else
case BUTTON_DOWN:
#endif
case SETTINGS_DEC:
oldtime = (get_sleep_timer()+59) / 60;
if(oldtime <= THRESHOLD)
amount = SMALL_STEP_SIZE;

View file

@ -103,38 +103,29 @@ bool set_sound(const char* string,
changed = false;
button = button_get_w_tmo(HZ/2);
switch( button ) {
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT:
#else
case BUTTON_RIGHT:
case BUTTON_RIGHT | BUTTON_REPEAT:
#endif
case SETTINGS_INC:
case SETTINGS_INC | BUTTON_REPEAT:
(*variable)+=steps;
if(*variable > max )
*variable = max;
changed = true;
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_DOWN:
case BUTTON_DOWN | BUTTON_REPEAT:
#else
case BUTTON_LEFT:
case BUTTON_LEFT | BUTTON_REPEAT:
#endif
case SETTINGS_DEC:
case SETTINGS_DEC | BUTTON_REPEAT:
(*variable)-=steps;
if(*variable < min )
*variable = min;
changed = true;
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_LEFT:
#else
case BUTTON_STOP:
case BUTTON_MENU:
case BUTTON_PLAY:
case SETTINGS_OK:
case SETTINGS_CANCEL:
#ifdef SETTINGS_OK2
case SETTINGS_OK2:
#endif
#ifdef SETTINGS_CANCEL2
case SETTINGS_CANCEL2:
#endif
done = true;
break;

View file

@ -194,20 +194,6 @@ void tree_get_filetypes(const struct filetype** types, int* count)
#endif /* HAVE_LCD_BITMAP */
#ifdef HAVE_RECORDER_KEYPAD
#define TREE_NEXT BUTTON_DOWN
#define TREE_PREV BUTTON_UP
#define TREE_EXIT BUTTON_LEFT
#define TREE_ENTER BUTTON_RIGHT
#define TREE_MENU BUTTON_F1
#else
#define TREE_NEXT BUTTON_RIGHT
#define TREE_PREV BUTTON_LEFT
#define TREE_EXIT BUTTON_STOP
#define TREE_ENTER BUTTON_PLAY
#define TREE_MENU BUTTON_MENU
#endif /* HAVE_RECORDER_KEYPAD */
/* talkbox hovering delay, to avoid immediate disk activity */
#define HOVER_DELAY (HZ/2)
@ -641,9 +627,9 @@ static bool ask_resume(bool ask_once)
while (!stop) {
button = button_get(true);
switch (button) {
case BUTTON_PLAY:
#ifdef BUTTON_RC_PLAY
case BUTTON_RC_PLAY:
case TREE_RUN:
#ifdef TREE_RC_RUN
case TREE_RC_RUN:
#endif
return true;
@ -771,8 +757,9 @@ void set_current_file(char *path)
}
}
#ifdef BUTTON_ON
static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen,
#ifdef TREE_SHIFT
static bool handle_shift(int *ds, int *dc, int numentries,
int tree_max_on_screen,
const int *dirfilter)
{
bool exit = false;
@ -790,12 +777,12 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen,
while (!exit) {
switch (button_get(true)) {
case TREE_PREV:
#ifdef BUTTON_RC_LEFT
case BUTTON_RC_LEFT:
#ifdef TREE_RC_PREV
case TREE_RC_PREV:
#endif
#ifdef BUTTON_ON
case BUTTON_ON | TREE_PREV:
case BUTTON_ON | TREE_PREV | BUTTON_REPEAT:
#ifdef TREE_SHIFT
case TREE_SHIFT | TREE_PREV:
case TREE_SHIFT | TREE_PREV | BUTTON_REPEAT:
#endif
used = true;
if ( dirstart ) {
@ -808,12 +795,12 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen,
break;
case TREE_NEXT:
#ifdef BUTTON_RC_RIGHT
case BUTTON_RC_RIGHT:
#ifdef TREE_RC_NEXT
case TREE_RC_NEXT:
#endif
#ifdef BUTTON_ON
case BUTTON_ON | TREE_NEXT:
case BUTTON_ON | TREE_NEXT | BUTTON_REPEAT:
#ifdef TREE_SHIFT
case TREE_SHIFT | TREE_NEXT:
case TREE_SHIFT | TREE_NEXT | BUTTON_REPEAT:
#endif
used = true;
if ( dirstart < numentries - tree_max_on_screen ) {
@ -827,12 +814,12 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen,
break;
case BUTTON_PLAY:
#ifdef BUTTON_RC_PLAY
case BUTTON_RC_PLAY:
case TREE_RUN:
#ifdef TREE_RC_PLAY
case TREE_RC_RUN:
#endif
#ifdef BUTTON_ON
case BUTTON_ON | BUTTON_PLAY:
#ifdef TREE_SHIFT
case TREE_SHIFT | TREE_RUN:
#endif
{
int onplay_result;
@ -866,10 +853,10 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen,
exit = true;
break;
}
#ifdef BUTTON_ON
case BUTTON_ON | BUTTON_REL:
case BUTTON_ON | TREE_PREV | BUTTON_REL:
case BUTTON_ON | TREE_NEXT | BUTTON_REL:
#ifdef TREE_SHIFT
case TREE_SHIFT | BUTTON_REL:
case TREE_SHIFT | TREE_PREV | BUTTON_REL:
case TREE_SHIFT | TREE_NEXT | BUTTON_REL:
exit = true;
break;
#endif
@ -969,7 +956,7 @@ static bool dirbrowse(const char *root, const int *dirfilter)
while (!stop) {
button = button_get(true);
switch (button) {
case BUTTON_PLAY:
case TREE_RUN:
rolo_load("/" BOOTFILE);
stop = true;
break;
@ -988,11 +975,9 @@ static bool dirbrowse(const char *root, const int *dirfilter)
switch ( button ) {
case TREE_EXIT:
#ifdef BUTTON_RC_STOP
case BUTTON_RC_STOP:
#endif
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_LEFT | BUTTON_REPEAT:
case TREE_EXIT | BUTTON_REPEAT:
#ifdef TREE_RC_EXIT
case TREE_RC_EXIT:
#endif
i=strlen(currdir);
if (i>1) {
@ -1027,8 +1012,8 @@ static bool dirbrowse(const char *root, const int *dirfilter)
}
break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_OFF:
#ifdef TREE_OFF
case TREE_OFF:
/* Stop the music if it is playing, else show the shutdown
screen */
if(mpeg_status())
@ -1042,27 +1027,23 @@ static bool dirbrowse(const char *root, const int *dirfilter)
restore = true;
}
break;
#endif
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_OFF | BUTTON_REPEAT:
#else
case BUTTON_STOP | BUTTON_REPEAT:
#endif
case TREE_OFF | BUTTON_REPEAT:
if (charger_inserted()) {
charging_splash();
restore = true;
}
break;
#endif
case TREE_ENTER:
case TREE_ENTER | BUTTON_REPEAT:
#ifdef BUTTON_RC_PLAY
case BUTTON_RC_PLAY:
#if defined TREE_RC_ENTER && (TREE_RC_ENTER != TREE_RC_RUN)
case TREE_RC_ENTER:
#endif
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_PLAY:
case BUTTON_PLAY | BUTTON_REPEAT:
#if defined TREE_RUN && (TREE_RUN != TREE_ENTER)
case TREE_RUN:
case TREE_RUN | BUTTON_REPEAT:
#endif
if ( !numentries )
break;
@ -1255,8 +1236,9 @@ static bool dirbrowse(const char *root, const int *dirfilter)
case TREE_PREV:
case TREE_PREV | BUTTON_REPEAT:
#ifdef BUTTON_RC_LEFT
case BUTTON_RC_LEFT:
#ifdef TREE_RC_PREV
case TREE_RC_PREV:
case TREE_RC_PREV | BUTTON_REPEAT:
#endif
if(filesindir) {
if(dircursor) {
@ -1295,8 +1277,9 @@ static bool dirbrowse(const char *root, const int *dirfilter)
case TREE_NEXT:
case TREE_NEXT | BUTTON_REPEAT:
#ifdef BUTTON_RC_RIGHT
case BUTTON_RC_RIGHT:
#ifdef TREE_RC_NEXT
case TREE_RC_NEXT:
case TREE_RC_NEXT | BUTTON_REPEAT:
#endif
if(filesindir)
{
@ -1340,10 +1323,10 @@ static bool dirbrowse(const char *root, const int *dirfilter)
}
break;
#ifdef BUTTON_ON /* I bet the folks without ON-button want this to
#ifdef TREE_SHIFT /* I bet the folks without ON-button want this to
work on a different button */
case BUTTON_ON:
if (handle_on(&dirstart, &dircursor, numentries,
case TREE_SHIFT:
if (handle_shift(&dirstart, &dircursor, numentries,
tree_max_on_screen, dirfilter))
{
/* start scroll */

View file

@ -21,6 +21,48 @@
#include <stdbool.h>
#ifdef HAVE_RECORDER_KEYPAD
#define TREE_NEXT BUTTON_DOWN
#define TREE_PREV BUTTON_UP
#define TREE_EXIT BUTTON_LEFT
#define TREE_ENTER BUTTON_RIGHT
#define TREE_RUN BUTTON_PLAY
#define TREE_MENU (BUTTON_F1 | BUTTON_REL)
#define TREE_SHIFT BUTTON_ON
#define TREE_OFF BUTTON_OFF
#define TREE_RC_NEXT BUTTON_RC_RIGHT
#define TREE_RC_REV BUTTON_RC_LEFT
#define TREE_RC_EXIT BUTTON_RC_STOP
#define TREE_RC_ENTER BUTTON_RC_PLAY
#define TREE_RC_RUN BUTTON_RC_PLAY
#elif defined HAVE_PLAYER_KEYPAD
#define TREE_NEXT BUTTON_RIGHT
#define TREE_PREV BUTTON_LEFT
#define TREE_EXIT BUTTON_STOP
#define TREE_ENTER BUTTON_PLAY
#define TREE_RUN BUTTON_PLAY
#define TREE_MENU (BUTTON_MENU | BUTTON_REL)
#define TREE_SHIFT BUTTON_ON
#define TREE_RC_NEXT BUTTON_RC_RIGHT
#define TREE_RC_REV BUTTON_RC_LEFT
#define TREE_RC_EXIT BUTTON_RC_STOP
#define TREE_RC_ENTER BUTTON_RC_PLAY
#define TREE_RC_RUN BUTTON_RC_PLAY
#elif defined HAVE_ONDIO_KEYPAD
#define TREE_NEXT BUTTON_DOWN
#define TREE_PREV BUTTON_UP
#define TREE_EXIT BUTTON_LEFT
#define TREE_ENTER BUTTON_RIGHT
#define TREE_RUN BUTTON_RIGHT
#define TREE_MENU (BUTTON_MENU | BUTTON_REPEAT)
#define TREE_SHIFT BUTTON_MENU
#endif
struct entry {
short attr; /* FAT attributes + file type flags */
unsigned long time_write; /* Last write time */

View file

@ -61,63 +61,86 @@ static struct mp3entry* id3 = NULL;
static struct mp3entry* nid3 = NULL;
static char current_track_path[MAX_PATH+1];
#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
void player_change_volume(int button)
{
bool exit = false;
char buffer[32];
/* button definitions */
#ifdef HAVE_RECORDER_KEYPAD
#define WPS_NEXT (BUTTON_RIGHT | BUTTON_REL)
#define WPS_PREV (BUTTON_LEFT | BUTTON_REL)
#define WPS_FFWD (BUTTON_RIGHT | BUTTON_REPEAT)
#define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT)
#define WPS_INCVOL BUTTON_UP
#define WPS_DECVOL BUTTON_DOWN
#define WPS_PAUSE BUTTON_PLAY
#define WPS_MENU (BUTTON_F1 | BUTTON_REL)
#define WPS_MENU_PRE BUTTON_F1
#define WPS_BROWSE (BUTTON_ON | BUTTON_REL)
#define WPS_EXIT BUTTON_OFF
#define WPS_KEYLOCK (BUTTON_F1 | BUTTON_DOWN)
#define WPS_ID3 (BUTTON_F1 | BUTTON_ON)
lcd_stop_scroll();
while (!exit)
{
switch (button)
{
case BUTTON_MENU | BUTTON_RIGHT:
case BUTTON_MENU | BUTTON_RIGHT | BUTTON_REPEAT:
global_settings.volume++;
if(global_settings.volume > mpeg_sound_max(SOUND_VOLUME))
global_settings.volume = mpeg_sound_max(SOUND_VOLUME);
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
wps_refresh(id3, nid3, 0, WPS_REFRESH_NON_STATIC);
settings_save();
break;
#define WPS_RC_NEXT BUTTON_RC_RIGHT
#define WPS_RC_PREV BUTTON_RC_LEFT
#define WPS_RC_PAUSE BUTTON_RC_PLAY
#define WPS_RC_INCVOL BUTTON_RC_VOL_UP
#define WPS_RC_DECVOL BUTTON_RC_VOL_DOWN
#define WPS_RC_EXIT BUTTON_RC_STOP
case BUTTON_MENU | BUTTON_LEFT:
case BUTTON_MENU | BUTTON_LEFT | BUTTON_REPEAT:
global_settings.volume--;
#elif defined HAVE_PLAYER_KEYPAD
#define WPS_NEXT BUTTON_RIGHT
#define WPS_PREV BUTTON_LEFT
#define WPS_FFWD (BUTTON_RIGHT | BUTTON_REPEAT)
#define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT)
#define WPS_INCVOL (BUTTON_MENU | BUTTON_RIGHT)
#define WPS_DECVOL (BUTTON_MENU | BUTTON_LEFT)
#define WPS_PAUSE BUTTON_PLAY
#define WPS_MENU (BUTTON_MENU | BUTTON_REL)
#define WPS_MENU_PRE BUTTON_MENU
#define WPS_BROWSE (BUTTON_ON | BUTTON_REL)
#define WPS_EXIT BUTTON_STOP
#define WPS_KEYLOCK (BUTTON_MENU | BUTTON_STOP)
#define WPS_ID3 (BUTTON_MENU | BUTTON_ON)
#define WPS_RC_NEXT BUTTON_RC_RIGHT
#define WPS_RC_PREV BUTTON_RC_LEFT
#define WPS_RC_PAUSE BUTTON_RC_PLAY
#define WPS_RC_INCVOL BUTTON_RC_VOL_UP
#define WPS_RC_DECVOL BUTTON_RC_VOL_DOWN
#define WPS_RC_EXIT BUTTON_RC_STOP
#elif defined HAVE_ONDIO_KEYPAD
#define WPS_NEXT (BUTTON_RIGHT | BUTTON_REL)
#define WPS_PREV (BUTTON_LEFT | BUTTON_REL)
#define WPS_FFWD (BUTTON_RIGHT | BUTTON_REPEAT)
#define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT)
#define WPS_INCVOL BUTTON_UP
#define WPS_DECVOL BUTTON_DOWN
#define WPS_PAUSE BUTTON_OFF
#define WPS_MENU (BUTTON_MENU | BUTTON_REPEAT)
#define WPS_BROWSE (BUTTON_MENU | BUTTON_REL)
#define WPS_KEYLOCK (BUTTON_MENU | BUTTON_DOWN)
#endif
/* set volume
return true if screen restore is needed
return false otherwise
*/
static bool setvol(void)
{
if (global_settings.volume < mpeg_sound_min(SOUND_VOLUME))
global_settings.volume = mpeg_sound_min(SOUND_VOLUME);
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
status_draw(false);
wps_refresh(id3, nid3, 0, WPS_REFRESH_NON_STATIC);
settings_save();
break;
case BUTTON_MENU | BUTTON_REL:
case BUTTON_MENU | BUTTON_LEFT | BUTTON_REL:
case BUTTON_MENU | BUTTON_RIGHT | BUTTON_REL:
exit = true;
break;
}
snprintf(buffer,sizeof(buffer),"Vol: %d %% ",
mpeg_val2phys(SOUND_VOLUME, global_settings.volume));
#ifdef HAVE_LCD_CHARCELLS
lcd_puts(0, 0, buffer);
#else
lcd_puts(2, 3, buffer);
lcd_update();
splash(0, false, "Vol: %d %% ",
mpeg_val2phys(SOUND_VOLUME, global_settings.volume));
return true;
#endif
status_draw(false);
if (!exit)
button = button_get(true);
return false;
}
wps_refresh(id3, nid3, 0, WPS_REFRESH_ALL);
}
#endif
void display_keylock_text(bool locked)
static void display_keylock_text(bool locked)
{
char* s;
lcd_stop_scroll();
@ -135,176 +158,6 @@ void display_keylock_text(bool locked)
splash(HZ, true, s);
}
void display_mute_text(bool muted)
{
char *s;
lcd_stop_scroll();
#ifdef HAVE_LCD_CHARCELLS
if (muted)
s = str(LANG_MUTE_ON_PLAYER);
else
s = str(LANG_MUTE_OFF_PLAYER);
#else
if (muted)
s = str(LANG_MUTE_ON_RECORDER);
else
s = str(LANG_MUTE_OFF_RECORDER);
#endif
splash(HZ, true, s);
}
bool browse_id3(void)
{
int button;
int menu_pos = 0;
int menu_max = 8;
bool exit = false;
char scroll_text[MAX_PATH];
if (!(mpeg_status() & MPEG_STATUS_PLAY))
return false;
while (!exit)
{
lcd_clear_display();
switch (menu_pos)
{
case 0:
lcd_puts(0, 0, str(LANG_ID3_TITLE));
lcd_puts_scroll(0, 1, id3->title ? id3->title :
(char*)str(LANG_ID3_NO_TITLE));
break;
case 1:
lcd_puts(0, 0, str(LANG_ID3_ARTIST));
lcd_puts_scroll(0, 1,
id3->artist ? id3->artist :
(char*)str(LANG_ID3_NO_ARTIST));
break;
case 2:
lcd_puts(0, 0, str(LANG_ID3_ALBUM));
lcd_puts_scroll(0, 1, id3->album ? id3->album :
(char*)str(LANG_ID3_NO_ALBUM));
break;
case 3:
lcd_puts(0, 0, str(LANG_ID3_TRACKNUM));
if (id3->tracknum) {
snprintf(scroll_text,sizeof(scroll_text), "%d",
id3->tracknum);
lcd_puts_scroll(0, 1, scroll_text);
}
else
lcd_puts_scroll(0, 1, str(LANG_ID3_NO_TRACKNUM));
break;
case 4:
lcd_puts(0, 0, str(LANG_ID3_GENRE));
lcd_puts_scroll(0, 1,
id3_get_genre(id3) ?
id3_get_genre(id3) :
(char*)str(LANG_ID3_NO_INFO));
break;
case 5:
lcd_puts(0, 0, str(LANG_ID3_YEAR));
if (id3->year) {
snprintf(scroll_text,sizeof(scroll_text), "%d",
id3->year);
lcd_puts_scroll(0, 1, scroll_text);
}
else
lcd_puts_scroll(0, 1, str(LANG_ID3_NO_INFO));
break;
case 6:
lcd_puts(0, 0, str(LANG_ID3_LENGHT));
snprintf(scroll_text,sizeof(scroll_text), "%d:%02d",
id3->length / 60000,
id3->length % 60000 / 1000 );
lcd_puts(0, 1, scroll_text);
break;
case 7:
lcd_puts(0, 0, str(LANG_ID3_PLAYLIST));
snprintf(scroll_text,sizeof(scroll_text), "%d/%d",
playlist_get_display_index(), playlist_amount());
lcd_puts_scroll(0, 1, scroll_text);
break;
case 8:
lcd_puts(0, 0, str(LANG_ID3_BITRATE));
snprintf(scroll_text,sizeof(scroll_text), "%d kbps",
id3->bitrate);
lcd_puts(0, 1, scroll_text);
break;
case 9:
lcd_puts(0, 0, str(LANG_ID3_FRECUENCY));
snprintf(scroll_text,sizeof(scroll_text), "%d Hz",
id3->frequency);
lcd_puts(0, 1, scroll_text);
break;
case 10:
lcd_puts(0, 0, str(LANG_ID3_PATH));
lcd_puts_scroll(0, 1, id3->path);
break;
}
lcd_update();
button = button_get(true);
switch(button)
{
case BUTTON_LEFT:
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
#endif
if (menu_pos > 0)
menu_pos--;
else
menu_pos = menu_max;
break;
case BUTTON_RIGHT:
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_DOWN:
#endif
if (menu_pos < menu_max)
menu_pos++;
else
menu_pos = 0;
break;
case BUTTON_REPEAT:
break;
#ifdef BUTTON_STOP
case BUTTON_STOP:
#else
case BUTTON_OFF:
#endif
case BUTTON_PLAY:
lcd_stop_scroll();
/* eat release event */
button_get(true);
exit = true;
break;
default:
if(default_event_handler(button) == SYS_USB_CONNECTED)
return true;
break;
}
}
return false;
}
static bool ffwd_rew(int button)
{
static const int ff_rew_steps[] = {
@ -324,8 +177,8 @@ static bool ffwd_rew(int button)
while (!exit) {
switch ( button ) {
case BUTTON_LEFT | BUTTON_REPEAT:
case BUTTON_RIGHT | BUTTON_REPEAT:
case WPS_FFWD:
case WPS_REW:
if (ff_rewind)
{
if (direction == 1)
@ -367,7 +220,7 @@ static bool ffwd_rew(int button)
#ifdef HAVE_PLAYER_KEYPAD
lcd_stop_scroll();
#endif
direction = (button & BUTTON_RIGHT) ? 1 : -1;
direction = (button & WPS_FFWD) ? 1 : -1;
if (direction > 0)
status_set_ffmode(STATUS_FASTFORWARD);
@ -405,8 +258,8 @@ static bool ffwd_rew(int button)
break;
case BUTTON_LEFT | BUTTON_REL:
case BUTTON_RIGHT | BUTTON_REL:
case WPS_PREV:
case WPS_NEXT:
mpeg_ff_rewind(id3->elapsed+ff_rewind_count);
ff_rewind_count = 0;
ff_rewind = false;
@ -483,133 +336,6 @@ static bool update(void)
return retcode;
}
static bool menu(void)
{
static bool muted = false;
bool exit = false;
int last_button = 0;
#ifdef HAVE_LCD_CHARCELLS
status_set_param(true);
status_draw(false);
#endif
while (!exit) {
int button = button_get(true);
/* these are never locked */
switch (button)
{
/* key lock */
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_F1 | BUTTON_DOWN:
#else
case BUTTON_MENU | BUTTON_STOP:
#endif
keys_locked = !keys_locked;
display_keylock_text(keys_locked);
exit = true;
while (button_get(false)); /* clear button queue */
break;
default:
if(default_event_handler(button) == SYS_USB_CONNECTED) {
keys_locked = false;
return true;
}
break;
}
if (keys_locked) {
display_keylock_text(true);
break;
}
switch ( button ) {
/* go into menu */
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_F1 | BUTTON_REL:
#else
case BUTTON_MENU | BUTTON_REL:
#endif
exit = true;
if ( !last_button && !keys_locked ) {
lcd_stop_scroll();
if (main_menu())
return true;
#ifdef HAVE_LCD_BITMAP
if(global_settings.statusbar)
lcd_setmargins(0, STATUSBAR_HEIGHT);
else
lcd_setmargins(0, 0);
#endif
}
break;
/* mute */
#ifdef BUTTON_MENU
case BUTTON_MENU | BUTTON_PLAY:
#else
case BUTTON_F1 | BUTTON_PLAY:
#endif
if ( muted )
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
else
mpeg_sound_set(SOUND_VOLUME, 0);
muted = !muted;
#ifdef HAVE_LCD_CHARCELLS
status_set_param(false);
#endif
display_mute_text(muted);
break;
#ifdef BUTTON_MENU
/* change volume */
case BUTTON_MENU | BUTTON_LEFT:
case BUTTON_MENU | BUTTON_LEFT | BUTTON_REPEAT:
case BUTTON_MENU | BUTTON_RIGHT:
case BUTTON_MENU | BUTTON_RIGHT | BUTTON_REPEAT:
player_change_volume(button);
exit = true;
break;
/* show id3 tags */
#ifdef BUTTON_ON
case BUTTON_MENU | BUTTON_ON:
#ifdef HAVE_LCD_CHARCELLS
status_set_param(true);
status_set_audio(true);
#endif
#endif
#else
case BUTTON_F1 | BUTTON_ON:
#endif
lcd_clear_display();
lcd_puts(0, 0, str(LANG_ID3_INFO));
lcd_puts(0, 1, str(LANG_ID3_SCREEN));
lcd_update();
sleep(HZ);
if(browse_id3())
return true;
#ifdef HAVE_PLAYER_KEYPAD
status_set_param(false);
status_set_audio(true);
#endif
exit = true;
break;
}
last_button = button;
}
#ifdef HAVE_LCD_CHARCELLS
status_set_param(false);
#endif
return false;
}
static void fade(bool fade_in)
{
if (fade_in) {
@ -647,12 +373,20 @@ static void fade(bool fade_in)
}
static void waitfor_nokey(void)
{
/* wait until all keys are released */
while (button_get(false) != BUTTON_NONE)
yield();
}
/* demonstrates showing different formats from playtune */
int wps_show(void)
{
int button = 0, lastbutton = 0;
bool ignore_keyup = true;
bool restore = false;
long restoretimer = 0; /* timer to delay screen redraw temporarily */
bool exit = false;
bool update_track = false;
@ -764,25 +498,21 @@ int wps_show(void)
continue;
}
#ifdef WPS_KEYLOCK
/* ignore non-remote buttons when keys are locked */
if (keys_locked &&
! ((button < 0) ||
#ifdef HAVE_RECORDER_KEYPAD
(button & BUTTON_F1) ||
#else
(button & BUTTON_MENU) ||
#endif
(button == BUTTON_NONE)
#ifdef BUTTON_REMOTE
|| (button & BUTTON_REMOTE)
#endif
(button == BUTTON_NONE) ||
((button & WPS_KEYLOCK) == WPS_KEYLOCK) ||
(button & BUTTON_REMOTE)
))
{
while (button_get(false)); /* clear button queue */
if (!(button & BUTTON_REL))
display_keylock_text(true);
restore = true;
continue;
button = BUTTON_NONE;
}
#endif
/* Exit if mpeg has stopped playing. This can happen if using the
sleep timer with the charger plugged or if starting a recording
@ -792,31 +522,10 @@ int wps_show(void)
switch(button)
{
#ifdef BUTTON_ON
case BUTTON_ON:
#ifdef HAVE_RECORDER_KEYPAD
switch (on_screen()) {
case 2:
/* usb connected? */
return SYS_USB_CONNECTED;
case 1:
/* was on_screen used? */
restore = true;
/* pause may have been turned off by pitch screen */
if (paused && !(mpeg_status() & MPEG_STATUS_PAUSE)) {
paused = false;
}
break;
case 0:
/* otherwise, exit to browser */
#else
case WPS_BROWSE:
#ifdef HAVE_LCD_CHARCELLS
status_set_record(false);
status_set_audio(false);
#endif
#endif
lcd_stop_scroll();
@ -826,15 +535,12 @@ int wps_show(void)
set_current_file(current_track_path);
return 0;
#ifdef HAVE_RECORDER_KEYPAD
}
break;
#endif
#endif /* BUTTON_ON */
/* play/pause */
case BUTTON_PLAY:
#ifdef BUTTON_RC_PLAY
case BUTTON_RC_PLAY:
case WPS_PAUSE:
#ifdef WPS_RC_PAUSE
case WPS_RC_PAUSE:
#endif
if ( paused )
{
@ -861,53 +567,50 @@ int wps_show(void)
break;
/* volume up */
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT:
#endif
#ifdef BUTTON_RC_VOL_UP
case BUTTON_RC_VOL_UP:
case WPS_INCVOL:
case WPS_INCVOL | BUTTON_REPEAT:
#ifdef WPS_RC_INCVOL
case WPS_RC_INCVOL:
#endif
global_settings.volume++;
if(global_settings.volume > mpeg_sound_max(SOUND_VOLUME))
global_settings.volume = mpeg_sound_max(SOUND_VOLUME);
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
status_draw(false);
settings_save();
if (setvol()) {
restore = true;
restoretimer = current_tick + HZ;
}
break;
/* volume down */
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_DOWN:
case BUTTON_DOWN | BUTTON_REPEAT:
#endif
#ifdef BUTTON_RC_VOL_DOWN
case BUTTON_RC_VOL_DOWN:
case WPS_DECVOL:
case WPS_DECVOL | BUTTON_REPEAT:
#ifdef WPS_RC_DECVOL
case WPS_RC_DECVOL:
#endif
global_settings.volume--;
if(global_settings.volume < mpeg_sound_min(SOUND_VOLUME))
global_settings.volume = mpeg_sound_min(SOUND_VOLUME);
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
status_draw(false);
settings_save();
if (setvol()) {
restore = true;
restoretimer = current_tick + HZ;
}
break;
/* fast forward / rewind */
case BUTTON_LEFT | BUTTON_REPEAT:
case BUTTON_RIGHT | BUTTON_REPEAT:
case WPS_FFWD:
case WPS_REW:
#ifdef WPS_RC_FFWD
case WPS_RC_FFWD:
case WPS_RC_RWD:
#endif
ffwd_rew(button);
break;
/* prev / restart */
#ifdef BUTTON_RC_LEFT
case BUTTON_RC_LEFT:
#ifdef WPS_RC_PREV
case WPS_RC_PREV:
#endif
case BUTTON_LEFT | BUTTON_REL:
#ifdef HAVE_RECORDER_KEYPAD
if ((button == (BUTTON_LEFT | BUTTON_REL)) &&
(lastbutton != BUTTON_LEFT ))
case WPS_PREV:
/* ignore release event after rewind */
if (lastbutton & BUTTON_REPEAT)
break;
#endif
if (!id3 || (id3->elapsed < 3*1000)) {
mpeg_prev();
}
@ -923,31 +626,45 @@ int wps_show(void)
break;
/* next */
#ifdef BUTTON_RC_RIGHT
case BUTTON_RC_RIGHT:
#ifdef WPS_RC_NEXT
case WPS_RC_NEXT:
#endif
case BUTTON_RIGHT | BUTTON_REL:
case WPS_NEXT:
#ifdef HAVE_RECORDER_KEYPAD
if ((button == (BUTTON_RIGHT | BUTTON_REL)) &&
(lastbutton != BUTTON_RIGHT))
if (lastbutton & BUTTON_REPEAT)
break;
#endif
mpeg_next();
break;
/* menu key functions */
#ifdef BUTTON_MENU
case BUTTON_MENU:
#else
case BUTTON_F1:
case WPS_MENU:
#ifdef WPS_MENU_PRE
if (lastbutton != WPS_MENU_PRE)
break;
#endif
if (menu())
return SYS_USB_CONNECTED;
lcd_stop_scroll();
update_track = true;
if (main_menu())
return true;
#ifdef HAVE_LCD_BITMAP
if (global_settings.statusbar)
lcd_setmargins(0, STATUSBAR_HEIGHT);
else
lcd_setmargins(0, 0);
#endif
restore = true;
break;
/* key lock */
case WPS_KEYLOCK:
case WPS_KEYLOCK | BUTTON_REPEAT:
keys_locked = !keys_locked;
display_keylock_text(keys_locked);
restore = true;
waitfor_nokey();
break;
#ifdef HAVE_RECORDER_KEYPAD
/* play settings */
case BUTTON_F2:
@ -962,21 +679,31 @@ int wps_show(void)
return SYS_USB_CONNECTED;
restore = true;
break;
/* pitch screen */
case BUTTON_ON | BUTTON_REPEAT:
if (2 == pitch_screen())
return SYS_USB_CONNECTED;
restore = true;
break;
#endif
/* stop and exit wps */
#ifdef BUTTON_OFF
case BUTTON_OFF | BUTTON_REL:
#else
case BUTTON_STOP | BUTTON_REL:
if ( lastbutton != BUTTON_STOP )
break;
#endif
#ifdef BUTTON_RC_STOP
case BUTTON_RC_STOP:
#ifdef WPS_EXIT
case WPS_EXIT:
#ifdef WPS_RC_EXIT
case WPS_RC_EXIT:
#endif
exit = true;
break;
#endif
#ifdef WPS_ID3
case WPS_ID3:
browse_id3();
restore = true;
break;
#endif
case BUTTON_NONE: /* Timeout */
update_track = true;
@ -1029,8 +756,12 @@ int wps_show(void)
if ( button )
ata_spin();
if (restore) {
if (restore &&
((restoretimer == 0) ||
(restoretimer < current_tick)))
{
restore = false;
restoretimer = 0;
if (wps_display(id3, nid3))
{
/* set dir browser to current playing song */

View file

@ -27,7 +27,6 @@ extern bool wps_time_countup;
int wps_show(void);
bool refresh_wps(bool refresh_scroll);
void handle_usb(void);
bool browse_id3(void);
#ifdef HAVE_RECORDER_KEYPAD
bool f2_screen(void);

View file

@ -267,7 +267,6 @@ void button_set_flip(bool flip)
}
}
/*
* Get button pressed from hardware
*/
@ -376,12 +375,12 @@ static int button_read(void)
if(adc_read(2) < 0x180)
btn |= BUTTON_RIGHT;
if(adc_read(3) < 0x180)
btn |= BUTTON_PLAY | BUTTON_UP;
btn |= BUTTON_PLAY;
if ( !(porta & 0x20) )
btn |= BUTTON_ON;
if ( !(porta & 0x800) )
btn |= BUTTON_STOP | BUTTON_DOWN;
btn |= BUTTON_STOP;
return btn;
}
@ -488,7 +487,7 @@ static int button_read(void)
if(adc_read(ADC_BUTTON_OPTION) > 0x200) /* active high */
btn |= BUTTON_MENU;
if(adc_read(ADC_BUTTON_ONOFF) < 0x120) /* active low */
btn |= BUTTON_ON;
btn |= BUTTON_OFF;
/* Check the 4 direction keys, hard-coded analog limits for now */
if (data >= 0x2EF)
@ -496,9 +495,9 @@ static int button_read(void)
else if (data >= 0x246)
btn |= BUTTON_RIGHT;
else if (data >= 0x19D)
btn |= BUTTON_PLAY | BUTTON_UP;
btn |= BUTTON_UP;
else if (data >= 0x0A1)
btn |= BUTTON_STOP | BUTTON_DOWN;
btn |= BUTTON_DOWN;
return btn;
}

View file

@ -85,7 +85,7 @@ int remote_control_rx(void)
}
else
{
#ifndef HAVE_NEO_KEYPAD /* This needs to be fixed for Neo */
#if !defined(HAVE_NEO_KEYPAD) && !defined(HAVE_ONDIO_KEYPAD)
switch (btn)
{
case STOP:

View file

@ -37,7 +37,7 @@ void button_set_flip(bool flip); /* turn 180 degrees */
#define BUTTON_NONE 0x0000
#ifdef HAVE_NEO_KEYPAD
/* neo button codes */
#define BUTTON_UP 0x0080
#define BUTTON_DOWN 0x0010
#define BUTTON_LEFT 0x0001
@ -80,9 +80,6 @@ void button_set_flip(bool flip); /* turn 180 degrees */
#else
/* Shared button codes */
#define BUTTON_ON 0x0001
#define BUTTON_UP 0x0010
#define BUTTON_DOWN 0x0020
#define BUTTON_LEFT 0x0040
#define BUTTON_RIGHT 0x0080
@ -94,38 +91,42 @@ void button_set_flip(bool flip); /* turn 180 degrees */
/* remote control buttons */
#define BUTTON_RC_VOL_UP (0x0008 | BUTTON_REMOTE)
#define BUTTON_RC_VOL_DOWN (0x0800 | BUTTON_REMOTE)
#define BUTTON_RC_PLAY (BUTTON_UP | BUTTON_REMOTE)
#define BUTTON_RC_STOP (BUTTON_DOWN | BUTTON_REMOTE)
#define BUTTON_RC_LEFT (BUTTON_LEFT | BUTTON_REMOTE)
#define BUTTON_RC_RIGHT (BUTTON_RIGHT| BUTTON_REMOTE)
#ifdef HAVE_RECORDER_KEYPAD
/* Recorder specific button codes */
#define BUTTON_ON 0x0001
#define BUTTON_OFF 0x0002
#define BUTTON_PLAY 0x0004
#define BUTTON_UP 0x0010
#define BUTTON_DOWN 0x0020
#define BUTTON_F1 0x0100
#define BUTTON_F2 0x0200
#define BUTTON_F3 0x0400
#define BUTTON_RC_PLAY (BUTTON_PLAY | BUTTON_REMOTE)
#define BUTTON_RC_STOP (BUTTON_OFF | BUTTON_REMOTE)
#elif defined(HAVE_PLAYER_KEYPAD)
/* Jukebox 6000 and Studio specific button codes */
#define BUTTON_ON 0x0001
#define BUTTON_MENU 0x0002
#define BUTTON_PLAY BUTTON_UP
#define BUTTON_STOP BUTTON_DOWN
#define BUTTON_PLAY 0x0010
#define BUTTON_STOP 0x0020
#define BUTTON_RC_PLAY (BUTTON_PLAY | BUTTON_REMOTE)
#define BUTTON_RC_STOP (BUTTON_STOP | BUTTON_REMOTE)
#elif defined HAVE_ONDIO_KEYPAD
/* Ondio specific button codes */
#define BUTTON_MENU 0x0002
#define BUTTON_PLAY BUTTON_UP
#define BUTTON_STOP BUTTON_DOWN
/* ON is also interpreted as OFF, let's see if that helps a bit */
#define BUTTON_OFF BUTTON_ON
#define BUTTON_F1 0x0100 /* unreacheable */
#define BUTTON_F2 0x0200 /* unreacheable */
#define BUTTON_F3 0x0400 /* unreacheable */
#define BUTTON_OFF 0x0002
#define BUTTON_UP 0x0010
#define BUTTON_DOWN 0x0020
#define BUTTON_MENU 0x0100
#endif /* HAVE_RECORDER/PLAYER/ONDIO_KEYPAD */

View file

@ -135,7 +135,7 @@ static void usb_slave_mode(bool on)
lcd_puts(0, 0, str);
lcd_puts(0, 1, "Press ON to debug");
lcd_update();
while(button_get(true) != BUTTON_ON) {};
while(!(button_get(true) & BUTTON_REL)) {};
dbg_ports();
panicf("ata: %d",rc);
}

View file

@ -102,7 +102,7 @@ void lcd_print_char(int x, int y)
static char bitmap_content[11*8][2*8];
if (double_height == 2 && y == 1)
return; /* Second row can't be printed in double height. ??*/
return; /* only one row available if text is double height */
for (col=0; col<5; col++) {
unsigned char fontbitmap=(*font_player)[ch][col];

View file

@ -23,6 +23,7 @@ PLAYDIR = $(APPDIR)/player
PLUGINDIR = $(APPDIR)/plugins
SIMCOMMON = ../common
ISONDIO := $(findstring ONDIO, $(TARGET))
ISPLAYER := $(findstring PLAYER, $(TARGET))
ifeq ($(ISPLAYER), PLAYER)
MACHINEDIR = $(PLAYDIR)
@ -124,8 +125,10 @@ SRCS = button.c lcd-win32.c panic-win32.c thread-win32.c \
OBJS := $(OBJDIR)/lang.o $(SRCS:%.c=$(OBJDIR)/%.o) $(OBJDIR)/uisw32-res.o
ifneq ($(ISONDIO),ONDIO)
ROCKS := $(patsubst $(PLUGINDIR)/%.c,$(OBJDIR)/%.rock,$(wildcard $(PLUGINDIR)/*.c))
PLUGINLIBOBJS := $(patsubst $(PLUGINDIR)/lib/%.c,$(OBJDIR)/%.o,$(wildcard $(PLUGINDIR)/lib/*.c))
endif
all: $(TOOLSDIR)/convbdf $(EXEFILE) $(ROCKS)

View file

@ -59,22 +59,38 @@ void button_event(int key, bool pressed)
case VK_RIGHT:
new_btn = BUTTON_RIGHT;
break;
case VK_NUMPAD8:
case VK_UP:
#ifdef BUTTON_UP
new_btn = BUTTON_UP;
#elif defined BUTTON_PLAY
new_btn = BUTTON_PLAY;
#endif
break;
case VK_NUMPAD2:
case VK_DOWN:
#ifdef BUTTON_DOWN
new_btn = BUTTON_DOWN;
#elif defined BUTTON_STOP
new_btn = BUTTON_STOP;
#endif
break;
#ifdef BUTTON_ON
case VK_ADD:
new_btn = BUTTON_ON;
break;
#endif
#ifdef HAVE_RECORDER_KEYPAD
#ifdef BUTTON_OFF
case VK_RETURN:
new_btn = BUTTON_OFF;
break;
#endif
#ifdef BUTTON_F1
case VK_DIVIDE:
case VK_F1:
new_btn = BUTTON_F1;
@ -87,11 +103,16 @@ void button_event(int key, bool pressed)
case VK_F3:
new_btn = BUTTON_F3;
break;
#endif
#ifdef BUTTON_PLAY
case VK_NUMPAD5:
case VK_SPACE:
new_btn = BUTTON_PLAY;
break;
#endif
#ifdef HAVE_LCD_BITMAP
case VK_NUMPAD0:
case VK_F5:
if(pressed)
@ -100,8 +121,14 @@ void button_event(int key, bool pressed)
return;
}
break;
#else
#endif
#ifdef BUTTON_MENU
#ifdef HAVE_PLAYER_KEYPAD
case VK_RETURN:
#elif defined HAVE_ONDIO_KEYPAD
case VK_INSERT:
#endif
new_btn = BUTTON_MENU;
break;
#endif

View file

@ -23,6 +23,7 @@ PLAYDIR = $(APPDIR)/player
PLUGINDIR = $(APPDIR)/plugins
SIMCOMMON = ../common
ISONDIO := $(findstring ONDIO, $(TARGET))
ISPLAYER := $(findstring PLAYER, $(TARGET))
ifeq ($(ISPLAYER), PLAYER)
MACHINEDIR = $(PLAYDIR)
@ -142,8 +143,10 @@ SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c \
OBJS := $(OBJDIR)/lang.o $(SRCS:%.c=$(OBJDIR)/%.o)
ifneq ($(ISONDIO),ONDIO)
ROCKS := $(patsubst $(PLUGINDIR)/%.c,$(OBJDIR)/%.rock,$(wildcard $(PLUGINDIR)/*.c))
PLUGINLIBOBJS := $(patsubst $(PLUGINDIR)/lib/%.c,$(OBJDIR)/%.o,$(wildcard $(PLUGINDIR)/lib/*.c))
endif
all: $(TOOLSDIR)/convbdf $(EXEFILE) $(ROCKS)
@ -249,11 +252,11 @@ $(OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
ifeq ($(UNAME),CYGWIN)
$(EXEFILE): $(OBJS) $(OBJDIR)/libplugin.a
$(EXEFILE): $(OBJS)
@echo LD $@
@$(CC) -g -o $(EXEFILE) $(OBJS) $(LIBDIRS) $(LDFLAGS) $(LIBS)
else
$(EXEFILE): $(OBJS) $(OBJDIR)/libplugin.a
$(EXEFILE): $(OBJS)
@echo LD $@
@$(CC) -g -o $(EXEFILE) $(LIBDIRS) $(LDFLAGS) $(OBJS) $(LIBS)
endif

View file

@ -75,35 +75,49 @@ static int get_raw_button (void)
case XK_KP_Up:
case XK_Up:
case XK_KP_8:
#ifdef BUTTON_UP
k = BUTTON_UP;
#elif defined BUTTON_PLAY
k = BUTTON_PLAY;
#endif
break;
case XK_KP_Down:
case XK_Down:
case XK_KP_2:
#ifdef BUTTON_DOWN
k = BUTTON_DOWN;
#elif defined BUTTON_STOP
k = BUTTON_STOP;
#endif
break;
#ifdef HAVE_RECORDER_KEYPAD
#ifdef BUTTON_PLAY
case XK_KP_Space:
case XK_KP_5:
case XK_KP_Begin:
case XK_space:
k = BUTTON_PLAY;
break;
#endif
#ifdef BUTTON_OFF
case XK_KP_Enter:
case XK_A:
case XK_a:
k = BUTTON_OFF;
break;
#endif
#ifdef BUTTON_ON
case XK_KP_Add:
case XK_Q:
case XK_q:
k = BUTTON_ON;
break;
#endif
#ifdef BUTTON_F1
case XK_KP_Divide:
case XK_1:
k = BUTTON_F1;
@ -118,7 +132,9 @@ static int get_raw_button (void)
case XK_3:
k = BUTTON_F3;
break;
#endif
#ifdef HAVE_LCD_BITMAP
case XK_5:
if(!release)
{
@ -126,16 +142,16 @@ static int get_raw_button (void)
return 0;
}
break;
#endif
#else
case XK_KP_Add:
case XK_Q:
case XK_q:
k = BUTTON_ON;
break;
#ifdef BUTTON_MENU
#ifdef HAVE_PLAYER_KEYPAD
case XK_KP_Enter:
case XK_Return:
#elif defined HAVE_ONDIO_KEYPAD
case XK_KP_Insert:
case XK_Control_R:
#endif
k = BUTTON_MENU;
break;
#endif