diff --git a/src/cp.c b/src/cp.c
index c210f48..7b35f9b 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -15,12 +15,14 @@
* along with this program. If not, see .
*/
+#include
#include
#include
#include "performance.h"
#include "keyboard.h"
#include "ir.h"
+#include "fb.h"
#include "audio.h"
#include "midi.h"
#include "oscsettings.h"
@@ -176,10 +178,10 @@ static void cp_callback(mtk_event *e, void *arg)
open_firstpatch_window();
break;
case CP_ITEM_START:
- start_performance();
+ start_performance(false);
break;
case CP_ITEM_STARTSIMPLE:
- printf("TODO\n");
+ start_performance(true);
break;
case CP_ITEM_FILEMANAGER:
@@ -371,12 +373,26 @@ void cp_autostart()
{
char autostart[256];
- sysconfig_get_autostart(autostart);
- if(autostart[0] == 0) return;
- if(!config_load(autostart)) {
- messagebox("Autostart failed", "Unable to load the specified performance file.\nCheck the 'Autostart' section in the 'System settings' dialog box.");
- return;
+ switch(sysconfig_get_autostart_mode()) {
+ case SC_AUTOSTART_NONE:
+ break;
+ case SC_AUTOSTART_SIMPLE:
+ start_performance(true);
+ break;
+ case SC_AUTOSTART_FILE:
+ sysconfig_get_autostart(autostart);
+ if(autostart[0] == 0) {
+ messagebox("Autostart failed", "No performance file specified.");
+ fb_unblank();
+ return;
+ }
+ if(!config_load(autostart)) {
+ messagebox("Autostart failed", "Unable to load the specified performance file.\nCheck the 'Autostart' section in the 'System settings' dialog box.");
+ fb_unblank();
+ return;
+ }
+ on_config_change();
+ start_performance(false);
+ break;
}
- on_config_change();
- start_performance();
}
diff --git a/src/main.c b/src/main.c
index ec8fcb5..f0ef3ca 100644
--- a/src/main.c
+++ b/src/main.c
@@ -78,17 +78,9 @@
#include "flash.h"
#include "filedialog.h"
-static int has_autostart()
-{
- char autostart[256];
-
- sysconfig_get_autostart(autostart);
- return autostart[0] != 0;
-}
-
static rtems_task gui_task(rtems_task_argument argument)
{
- init_fb_mtk(has_autostart());
+ init_fb_mtk(sysconfig_get_autostart_mode() != SC_AUTOSTART_NONE);
sysconfig_set_mtk_wallpaper();
sysconfig_set_mtk_keyboard_layout();
init_input();
diff --git a/src/performance.c b/src/performance.c
index 56bfd9b..26b2ee8 100644
--- a/src/performance.c
+++ b/src/performance.c
@@ -16,9 +16,11 @@
*/
#include
+#include
#include
#include
-#include
+#include
+#include
#include
#include
@@ -42,6 +44,8 @@ struct patch_info {
static int npatches;
static struct patch_info patches[MAX_PATCHES];
+static bool simple_mode;
+static int simple_current;
static int add_patch(const char *filename)
{
@@ -141,6 +145,33 @@ static void add_osc_patches()
}
}
+#define SIMPLE_PATCHES_FOLDER "/flash/"
+
+static void add_simple_patches()
+{
+ DIR *d;
+ struct dirent *entry;
+ struct stat s;
+ char fullname[384];
+ char *c;
+
+ d = opendir(SIMPLE_PATCHES_FOLDER);
+ if(!d)
+ return;
+ while((entry = readdir(d))) {
+ if(entry->d_name[0] == '.') continue;
+ strncpy(fullname, SIMPLE_PATCHES_FOLDER, sizeof(fullname));
+ strncat(fullname, entry->d_name, sizeof(fullname));
+ lstat(fullname, &s);
+ if(!S_ISDIR(s.st_mode)) {
+ c = strrchr(entry->d_name, '.');
+ if((c != NULL) && (strcmp(c, ".fnp") == 0))
+ add_patch(fullname);
+ }
+ }
+ closedir(d);
+}
+
static int appid;
static int started;
@@ -260,27 +291,38 @@ static void event_callback(mtk_event *e, int count)
int i;
int index;
- for(i=0;i> 8) == midi_channel) {
- index = e[i].press.code & 0x7f;
- index = midi_patches[index];
+ index = -1;
+ if(simple_mode) {
+ for(i=0;i> 8) == midi_channel) {
+ index = e[i].press.code & 0x7f;
+ index = midi_patches[index];
+ }
+ } else if(e[i].type == EVENT_TYPE_OSC) {
+ index = e[i].press.code & 0x3f;
+ index = osc_patches[index];
}
- } else if(e[i].type == EVENT_TYPE_OSC) {
- index = e[i].press.code & 0x3f;
- index = osc_patches[index];
}
- if(index != -1)
- renderer_set_patch(patches[index].p);
}
+ if(index != -1)
+ renderer_set_patch(patches[index].p);
}
static void stop_callback()
@@ -303,7 +345,8 @@ static void refresh_callback(mtk_event *e, int count)
input_delete_callback(refresh_callback);
input_add_callback(event_callback);
mtk_cmd(appid, "l_text.set(-text \"Done.\")");
- if(!guirender(appid, patches[firstpatch].p, stop_callback))
+ if(!guirender(appid, patches[simple_mode ? simple_current : firstpatch].p,
+ stop_callback))
stop_callback();
return;
}
@@ -324,7 +367,7 @@ static void refresh_callback(mtk_event *e, int count)
static rtems_id comp_task_id;
-void start_performance()
+void start_performance(bool simple)
{
rtems_status_code sc;
@@ -332,18 +375,30 @@ void start_performance()
started = 1;
/* build patch list */
+ simple_mode = simple;
npatches = 0;
- add_firstpatch();
- if(npatches < 1) {
- messagebox("Error", "No first patch defined!\n");
- started = 0;
- fb_unblank();
- return;
+ simple_current = 0;
+ if(simple) {
+ add_simple_patches();
+ if(npatches < 1) {
+ messagebox("Error", "No patches found!\n");
+ started = 0;
+ fb_unblank();
+ return;
+ }
+ } else {
+ add_firstpatch();
+ if(npatches < 1) {
+ messagebox("Error", "No first patch defined!\n");
+ started = 0;
+ fb_unblank();
+ return;
+ }
+ add_keyboard_patches();
+ add_ir_patches();
+ add_midi_patches();
+ add_osc_patches();
}
- add_keyboard_patches();
- add_ir_patches();
- add_midi_patches();
- add_osc_patches();
/* start patch compilation task */
compiled_patches = 0;
diff --git a/src/performance.h b/src/performance.h
index e9a004b..9be1112 100644
--- a/src/performance.h
+++ b/src/performance.h
@@ -1,6 +1,6 @@
/*
* Flickernoise
- * Copyright (C) 2010 Sebastien Bourdeauducq
+ * Copyright (C) 2010, 2011 Sebastien Bourdeauducq
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,6 +19,6 @@
#define __PERFORMANCE_H
void init_performance();
-void start_performance();
+void start_performance(bool simple);
#endif /* __PERFORMANCE_H */