summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/calendar.c8
-rw-r--r--apps/plugins/chessclock.c20
-rw-r--r--apps/plugins/dice.c15
-rw-r--r--apps/plugins/keybox.c25
-rw-r--r--apps/plugins/mazezam.c13
-rw-r--r--apps/plugins/pacbox/pacbox.c21
-rw-r--r--apps/plugins/rockpaint.c9
-rw-r--r--apps/plugins/snake.c22
-rw-r--r--apps/plugins/star.c30
9 files changed, 106 insertions, 57 deletions
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index e938af873e..e00afe19b6 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -24,6 +24,7 @@
#if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0)
#include <timefuncs.h>
+#include "lib/playback_control.h"
PLUGIN_HEADER
@@ -620,7 +621,8 @@ static bool edit_memo(int change, struct shown *shown)
MENUITEM_STRINGLIST(edit_menu, "Edit menu", edit_menu_cb,
"Remove", "Edit",
"New Weekly", "New Monthly",
- "New Yearly", "New One off");
+ "New Yearly", "New One off",
+ "Playback Control");
while (!exit)
{
@@ -652,6 +654,10 @@ static bool edit_memo(int change, struct shown *shown)
add_memo(shown,3);
return false;
+ case 6: /* playback control */
+ playback_control(NULL);
+ break;
+
case GO_TO_PREVIOUS:
return false;
diff --git a/apps/plugins/chessclock.c b/apps/plugins/chessclock.c
index 28b1d95df3..337e2cc5b0 100644
--- a/apps/plugins/chessclock.c
+++ b/apps/plugins/chessclock.c
@@ -19,6 +19,7 @@
*
****************************************************************************/
#include "plugin.h"
+#include "lib/playback_control.h"
PLUGIN_HEADER
@@ -327,13 +328,13 @@ enum plugin_status plugin_start(const void* parameter)
int i;
bool done;
int nr;
-
+
(void)parameter;
settings.nr_timers = 1;
settings.total_time = 10;
settings.round_time = 10;
-
+
/* now go ahead and have fun! */
rb->splash(HZ, "Chess Clock");
@@ -380,7 +381,7 @@ enum plugin_status plugin_start(const void* parameter)
timer_holder[i].used_time=0;
timer_holder[i].hidden=false;
}
-
+
pause=true; /* We start paused */
nr=0;
@@ -431,7 +432,7 @@ enum plugin_status plugin_start(const void* parameter)
static void show_pause_mode(bool enabled)
{
static const char pause_icon[] = {0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00};
-
+
if (enabled)
rb->lcd_mono_bitmap((unsigned char *)pause_icon, 52, 0, 7, 8);
else
@@ -524,13 +525,14 @@ static int run_timer(int nr)
{
MENUITEM_STRINGLIST(menu, "Menu", NULL,
"Delete player", "Restart round",
- "Set round time", "Set total time");
+ "Set round time", "Set total time",
+ "Playback Control");
int val, res;
switch(rb->do_menu(&menu, NULL, NULL, false))
{
case 0:
- /* delete player */
+ /* delete player */
timer_holder[nr].hidden=true;
retval = CHCL_NEXT;
done=true;
@@ -544,8 +546,7 @@ static int run_timer(int nr)
/* set round time */
val=(max_ticks-ticks)/HZ;
res=chessclock_set_int("Round time",
- &val,
- 10, 0, MAX_TIME,
+ &val, 10, 0, MAX_TIME,
FLAGS_SET_INT_SECONDS);
if (res==CHCL_USB) {
retval = CHCL_USB;
@@ -569,6 +570,9 @@ static int run_timer(int nr)
timer_holder[nr].total_time=val;
}
break;
+ case 4:
+ playback_control(NULL);
+ break;
case MENU_ATTACHED_USB:
retval = CHCL_USB;
done=true;
diff --git a/apps/plugins/dice.c b/apps/plugins/dice.c
index 5ef5d5099d..ddbc0cc60e 100644
--- a/apps/plugins/dice.c
+++ b/apps/plugins/dice.c
@@ -22,6 +22,7 @@
#include "plugin.h"
#include "lib/pluginlib_actions.h"
#include "lib/configfile.h"
+#include "lib/playback_control.h"
#define MAX_DICES 12
#define INITIAL_NB_DICES 1
@@ -79,7 +80,7 @@ enum plugin_status plugin_start(const void* parameter) {
dice_init(&dice);
rb->srand(*rb->current_tick);
-
+
configfile_load(CFG_FILE, config, 2, 0);
dice.nb_sides = nb_sides_values[sides_index];
if(!dice_menu(&dice))
@@ -171,8 +172,10 @@ bool dice_menu(struct dices * dice) {
int selection;
bool menu_quit = false, result = false;
- MENUITEM_STRINGLIST(menu,"Dice Menu",NULL,"Roll Dice","Number of Dice",
- "Number of Sides","Quit");
+ MENUITEM_STRINGLIST(menu, "Dice Menu", NULL,
+ "Roll Dice",
+ "Number of Dice", "Number of Sides",
+ "Playback Control", "Quit");
while (!menu_quit) {
@@ -194,11 +197,15 @@ bool dice_menu(struct dices * dice) {
dice->nb_sides=nb_sides_values[sides_index];
break;
+ case 3:
+ playback_control(NULL);
+ break;
+
default:
menu_quit = true;
result = false;
break;
- }
+ }
}
return result;
}
diff --git a/apps/plugins/keybox.c b/apps/plugins/keybox.c
index 73fd138f09..448050938f 100644
--- a/apps/plugins/keybox.c
+++ b/apps/plugins/keybox.c
@@ -19,6 +19,7 @@
*
****************************************************************************/
#include "plugin.h"
+#include "lib/playback_control.h"
#include "lib/md5.h"
PLUGIN_HEADER
@@ -29,7 +30,6 @@ PLUGIN_HEADER
/* The header begins with the unencrypted salt (4 bytes) padded with 4 bytes of
zeroes. After that comes the encrypted hash of the master password (16 bytes) */
-
#define HEADER_LEN 24
@@ -106,9 +106,10 @@ static void decrypt(uint32_t* v, uint32_t* k)
static int context_item_cb(int action, const struct menu_item_ex *this_item)
{
+ int i = (intptr_t)this_item;
if (action == ACTION_REQUEST_MENUITEM
&& pw_list.num_entries == 0
- && ((intptr_t)this_item) != 0)
+ && (i != 0 && i != 5))
{
return ACTION_EXIT_MENUITEM;
}
@@ -117,8 +118,9 @@ static int context_item_cb(int action, const struct menu_item_ex *this_item)
MENUITEM_STRINGLIST(context_m, "Context menu", context_item_cb,
"Add entry",
- "Edit title", "Edit user name", "Edit password",
- "Delete entry")
+ "Edit title", "Edit user name", "Edit password",
+ "Delete entry",
+ "Playback Control");
static char * kb_list_cb(int selected_item, void *data,
char *buffer, size_t buffer_len)
@@ -133,7 +135,7 @@ static char * kb_list_cb(int selected_item, void *data,
}
if (!entry)
return NULL;
-
+
rb->snprintf(buffer, buffer_len, "%s", entry->title);
return buffer;
@@ -161,7 +163,7 @@ static void delete_entry(int selected_item)
entry2 = entry->next;
if (!entry2)
return;
-
+
entry->next = entry2->next;
entry2->used = false;
@@ -289,6 +291,9 @@ static void context_menu(int selected_item)
case 4:
delete_entry(selected_item);
return;
+ case 5:
+ playback_control(NULL);
+ return;
default:
exit = true;
break;
@@ -610,8 +615,9 @@ static int main_menu(void)
int selection, result, ret;
bool exit = false;
- MENUITEM_STRINGLIST(menu,"Keybox", NULL, "Enter Keybox",
- "Reset Keybox", "Exit");
+ MENUITEM_STRINGLIST(menu, "Keybox", NULL,
+ "Enter Keybox", "Reset Keybox",
+ "Playback Control", "Exit");
do {
result = rb->do_menu(&menu, &selection, NULL, false);
@@ -625,6 +631,9 @@ static int main_menu(void)
reset();
break;
case 2:
+ playback_control(NULL);
+ break;
+ case 3:
exit = true;
break;
}
diff --git a/apps/plugins/mazezam.c b/apps/plugins/mazezam.c
index a19c8a027e..ad5e5437af 100644
--- a/apps/plugins/mazezam.c
+++ b/apps/plugins/mazezam.c
@@ -224,7 +224,7 @@ static enum {
STATE_FAILED, /* The player wants to retry the level */
STATE_GAME_MENU, /* The player wan't to access the in-game menu */
-
+
STATE_IN_LEVEL,
} state;
@@ -519,7 +519,7 @@ static void draw_level(
short xOff = (LCD_WIDTH - (size*li->width))/2;
short yOff = (LCD_HEIGHT - (size*li->height))/2;
short i;
-
+
rb->lcd_clear_display();
draw_walls(size,xOff,yOff,li->width, li->height, li->entrance, li->exit);
@@ -658,7 +658,7 @@ static void in_game_menu(void)
MAZEZAM_TEXT_RETRY_LEVEL,
MAZEZAM_TEXT_AUDIO_PLAYBACK,
MAZEZAM_TEXT_QUIT);
-
+
/* Don't show the status bar */
switch(rb->do_menu(&menu, &start_selection, NULL, false)){
case 1: /* retry */
@@ -888,6 +888,7 @@ static void main_menu(void)
MENUITEM_STRINGLIST(menu,MAZEZAM_TEXT_MAIN_MENU,main_menu_cb,
MAZEZAM_TEXT_CONTINUE,
MAZEZAM_TEXT_PLAY_NEW_GAME,
+ MAZEZAM_TEXT_AUDIO_PLAYBACK,
MAZEZAM_TEXT_QUIT);
while (state >= STATE_IN_APPLICATION) {
@@ -906,6 +907,10 @@ static void main_menu(void)
game_loop(&r_data);
break;
+ case 2: /* Audio playback */
+ playback_control(NULL);
+ break;
+
case MENU_ATTACHED_USB:
state = STATE_USB_CONNECTED;
break;
@@ -935,7 +940,7 @@ enum plugin_status plugin_start(const void* parameter)
store_lcd_settings();
state = STATE_MAIN_MENU;
- main_menu();
+ main_menu();
switch (state) {
case STATE_USB_CONNECTED:
diff --git a/apps/plugins/pacbox/pacbox.c b/apps/plugins/pacbox/pacbox.c
index e7b92c38cf..0e3343252f 100644
--- a/apps/plugins/pacbox/pacbox.c
+++ b/apps/plugins/pacbox/pacbox.c
@@ -29,6 +29,7 @@
#include "pacbox.h"
#include "pacbox_lcd.h"
#include "lib/configfile.h"
+#include "lib/playback_control.h"
PLUGIN_HEADER
PLUGIN_IRAM_DECLARE
@@ -78,9 +79,9 @@ static bool loadFile( const char * name, unsigned char * buf, int len )
if( fd < 0 ) {
return false;
}
-
+
int n = rb->read( fd, buf, len);
-
+
rb->close( fd );
if( n != len ) {
@@ -174,7 +175,8 @@ static bool pacbox_menu(void)
MENUITEM_STRINGLIST(menu, "Pacbox Menu", NULL,
"Difficulty", "Pacmen Per Game", "Bonus Life",
- "Ghost Names", "Display FPS", "Restart", "Quit");
+ "Ghost Names", "Display FPS",
+ "Playback Control", "Restart", "Quit");
rb->button_clear_queue();
@@ -220,10 +222,13 @@ static bool pacbox_menu(void)
}
break;
case 4: /* Show FPS */
- rb->set_option("Display FPS",&settings.showfps,INT,
+ rb->set_option("Display FPS",&settings.showfps,INT,
noyes, 2, NULL);
break;
- case 5: /* Restart */
+ case 5: /* playback control */
+ playback_control(NULL);
+ break;
+ case 6: /* Restart */
need_restart=true;
menu_quit=1;
break;
@@ -323,7 +328,7 @@ static int gameProc( void )
yield_counter = 0;
rb->yield ();
}
-
+
/* The following functions render the Pacman screen from the
contents of the video and color ram. We first update the
background, and then draw the Sprites on top.
@@ -343,10 +348,10 @@ static int gameProc( void )
rb->lcd_update();
- /* Keep the framerate at Pacman's 60fps */
+ /* Keep the framerate at Pacman's 60fps */
end_time = start_time + (video_frames*HZ)/FPS;
while (TIME_BEFORE(*rb->current_tick,end_time)) {
- rb->sleep(1);
+ rb->sleep(1);
}
}
}
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c
index 5388aceed5..458f6b552a 100644
--- a/apps/plugins/rockpaint.c
+++ b/apps/plugins/rockpaint.c
@@ -31,6 +31,7 @@
#include "plugin.h"
#include "lib/pluginlib_bmp.h"
#include "lib/rgb_hsv.h"
+#include "lib/playback_control.h"
PLUGIN_HEADER
@@ -533,6 +534,7 @@ enum {
MAIN_MENU_NEW, MAIN_MENU_LOAD, MAIN_MENU_SAVE,
MAIN_MENU_BRUSH_SIZE, MAIN_MENU_BRUSH_SPEED, MAIN_MENU_COLOR,
MAIN_MENU_GRID_SIZE,
+ MAIN_MENU_PLAYBACK_CONTROL,
MAIN_MENU_EXIT,
};
enum {
@@ -551,7 +553,8 @@ enum {
MENUITEM_STRINGLIST(main_menu, "RockPaint", NULL,
"Resume", "New", "Load", "Save",
"Brush Size", "Brush Speed",
- "Choose Color", "Grid Size", "Exit");
+ "Choose Color", "Grid Size",
+ "Playback Control", "Exit");
MENUITEM_STRINGLIST(size_menu, "Choose Size", NULL,
"1x", "2x","4x", "8x");
MENUITEM_STRINGLIST(speed_menu, "Choose Speed", NULL,
@@ -2527,6 +2530,10 @@ static void goto_menu(void)
gridsize = gridsize_list[multi];
break;
+ case MAIN_MENU_PLAYBACK_CONTROL:
+ playback_control( NULL );
+ break;
+
case MAIN_MENU_EXIT:
restore_screen();
quit=true;
diff --git a/apps/plugins/snake.c b/apps/plugins/snake.c
index 739fce9a3e..8cba920840 100644
--- a/apps/plugins/snake.c
+++ b/apps/plugins/snake.c
@@ -34,6 +34,7 @@ dir is the current direction of the snake - 0=up, 1=right, 2=down, 3=left;
#include "plugin.h"
#ifdef HAVE_LCD_BITMAP
+#include "lib/playback_control.h"
PLUGIN_HEADER
@@ -393,7 +394,7 @@ void game (void) {
rb->sleep(HZ/level);
button=rb->button_get(false);
-
+
#ifdef HAS_BUTTON_HOLD
if (rb->button_hold())
button = SNAKE_PLAYPAUSE;
@@ -445,23 +446,28 @@ void game_init(void) {
apple=false;
snakelength=4;
score=0;
- board[11][7]=1;
-
- MENUITEM_STRINGLIST(menu,"Snake Menu",NULL,"Start New Game","Starting Level",
- "Quit");
-
+ board[11][7]=1;
+
+ MENUITEM_STRINGLIST(menu, "Snake Menu", NULL,
+ "Start New Game", "Starting Level",
+ "Playback Control", "Quit");
+
while (!menu_quit) {
switch(rb->do_menu(&menu, &selection, NULL, false))
{
case 0:
menu_quit = true; /* start playing */
break;
-
+
case 1:
rb->set_int("Starting Level", "", UNIT_INT, &level, NULL,
1, 1, 9, NULL );
break;
-
+
+ case 2:
+ playback_control(NULL);
+ break;
+
default:
dead=1; /* quit program */
menu_quit = true;
diff --git a/apps/plugins/star.c b/apps/plugins/star.c
index 1a27f51f54..118a18227c 100644
--- a/apps/plugins/star.c
+++ b/apps/plugins/star.c
@@ -21,6 +21,7 @@
#include "plugin.h"
#ifdef HAVE_LCD_BITMAP
#include "lib/display_text.h"
+#include "lib/playback_control.h"
PLUGIN_HEADER
@@ -424,8 +425,6 @@ static char board[STAR_HEIGHT][STAR_WIDTH];
#define STAR 3
#define BALL 4
-#define MENU_START 0
-
/* char font size */
static int char_width = -1;
static int char_height = -1;
@@ -1051,18 +1050,21 @@ static int star_menu(void)
{
int selection, level=1;
bool menu_quit = false;
- /* get the size of char */
- rb->lcd_getstringsize("a", &char_width, &char_height);
- MENUITEM_STRINGLIST(menu,"Star Menu",NULL,"Start Game","Choose Level",
- "Help", "Quit");
+ MENUITEM_STRINGLIST(menu, "Star Menu", NULL,
+ "Start Game","Choose Level",
+ "Help", "Playback Control", "Quit");
while(!menu_quit)
{
switch(rb->do_menu(&menu, &selection, NULL, false))
{
case 0:
- menu_quit = true;
+ /* use system font and get the size of char */
+ rb->lcd_setfont(FONT_SYSFIXED);
+ rb->lcd_getstringsize("a", &char_width, &char_height);
+ star_run_game(level-1);
+ rb->lcd_setfont(FONT_UI);
break;
case 1:
rb->set_int("Level", "", UNIT_INT, &level,
@@ -1072,19 +1074,17 @@ static int star_menu(void)
if(star_help())
usb_detected = true;
break;
- default:
+ case 3:
+ playback_control(NULL);
+ break;
+ case 4:
menu_quit = true;
break;
}
+ if(usb_detected)
+ return PLUGIN_USB_CONNECTED;
}
- if (selection == MENU_START)
- {
- rb->lcd_setfont(FONT_SYSFIXED);
- rb->lcd_getstringsize("a", &char_width, &char_height);
- level--;
- star_run_game(level);
- }
return PLUGIN_OK;
}