Draft patch:
diff -r 1324f51b5e85 src/boot-hack.c
--- a/src/boot-hack.c
+++ b/src/boot-hack.c
@@ -462,2 +462,31 @@
_find_ml_card();
+
+ /* should we require SET for loading ML, or not? */
+ extern int _set_at_startup;
+ _set_at_startup = config_flag_file_setting_load("ML/SETTINGS/REQUIRE.SET");
+
+ // at this point, gui_main_task should be started and should be able to tell whether SET was pressed at startup
+ if (magic_off_request != _set_at_startup)
+ {
+ /* should we bypass loading ML? */
+ /* (pressing SET after this point will be ignored) */
+ magic_off = 1;
+
+ #if !defined(CONFIG_NO_ADDITIONAL_VERSION)
+ /* fixme: enable on all models */
+ extern char additional_version[];
+ additional_version[0] = '-';
+ additional_version[1] = 'm';
+ additional_version[2] = 'l';
+ additional_version[3] = '-';
+ additional_version[4] = 'o';
+ additional_version[5] = 'f';
+ additional_version[6] = 'f';
+ additional_version[7] = '\0';
+ #endif
+
+ /* do not continue loading ML */
+ return;
+ }
+
_load_fonts();
@@ -878,33 +907,8 @@
// wait for overriden gui_main_task (but use a timeout so it doesn't break if you disable that for debugging)
- for (int i = 0; i < 30; i++)
+ for (int i = 0; i < 50; i++)
{
if (ml_gui_initialized) break;
- msleep(100);
+ msleep(50);
}
- msleep(200);
-
- // at this point, gui_main_start should be started and should be able to tell whether SET was pressed at startup
- if (magic_off_request)
- {
- magic_off = 1; // magic off request might be sent later (until ml is fully started), but will be ignored
- for (int i = 0; i < 10; i++)
- {
- if (DISPLAY_IS_ON) break;
- msleep(100);
- }
- bmp_printf(FONT_CANON, 0, 0, "Magic OFF");
- info_led_off();
- #if !defined(CONFIG_NO_ADDITIONAL_VERSION)
- extern char additional_version[];
- additional_version[0] = '-';
- additional_version[1] = 'm';
- additional_version[2] = 'l';
- additional_version[3] = '-';
- additional_version[4] = 'o';
- additional_version[5] = 'f';
- additional_version[6] = 'f';
- additional_version[7] = '\0';
- #endif
- return ans;
- }
+ msleep(50);
diff -r 1324f51b5e85 src/config.c
--- a/src/config.c
+++ b/src/config.c
@@ -282,3 +282,3 @@
-int config_flag_file_setting_load(char* file)
+int config_flag_file_setting_load(const char * file)
{
@@ -288,3 +288,3 @@
-void config_flag_file_setting_save(char* file, int setting)
+void config_flag_file_setting_save(const char * file, int setting)
{
@@ -304,3 +304,2 @@
config_flag_file_setting_save(autosave_flag_file, !!config_autosave);
- msleep(50);
config_autosave = !config_flag_file_setting_load(autosave_flag_file);
@@ -858,5 +857,16 @@
+/* initialized and used in boot-hack.c */
+int _set_at_startup = 0;
+
+static MENU_SELECT_FUNC(set_at_startup_toggle)
+{
+ /* this one is a bit hard to integrate with config presets, so it's made global */
+ const char * flag_file = "ML/SETTINGS/REQUIRE.SET";
+ config_flag_file_setting_save(flag_file, !_set_at_startup);
+ _set_at_startup = config_flag_file_setting_load(flag_file);
+}
+
static struct menu_entry cfg_menus[] = {
{
- .name = "Config files",
+ .name = "Config options",
.select = menu_open_submenu,
@@ -867,2 +877,13 @@
{
+ .name = "SET at startup",
+ .priv = &_set_at_startup,
+ .max = 1,
+ .choices = CHOICES("Bypass loading ML", "Required to load ML"),
+ .select = set_at_startup_toggle,
+ .icon_type = IT_BOOL,
+ .help = "[GLOBAL] If you hold the SET button pressed at camera startup:",
+ .help2 = "Do not load ML if you start the camera with SET pressed (default)\n"
+ "Load ML only if SET is pressed at startup (optional)"
+ },
+ {
.name = "Config preset",
diff -r 1324f51b5e85 src/config.h
--- a/src/config.h
+++ b/src/config.h
@@ -149,4 +149,4 @@
/* simple boolean settings that live outside of config files (just by presence of a file) */
-int config_flag_file_setting_load(char* file);
-void config_flag_file_setting_save(char* file, int setting);
+int config_flag_file_setting_load(const char * file);
+void config_flag_file_setting_save(const char * file, int setting);
diff -r 1324f51b5e85 src/menuindex.c
--- a/src/menuindex.c
+++ b/src/menuindex.c
@@ -27,2 +27,5 @@
+/* config.c */
+extern int _set_at_startup;
+
static struct menu_entry help_menus[] = {
@@ -117,2 +120,11 @@
{
+ .select = menu_nav_help_open,
+ .name = "SET at startup",
+ .priv = &_set_at_startup,
+ .max = 1,
+ .icon_type = IT_ACTION,
+ .choices = CHOICES("Bypass loading ML", "Required to load ML"),
+ .help = "To change this setting: Prefs -> Config options",
+ },
+ {
.name = "Key Shortcuts",
Format card and keep Magic Lantern even though it was disabled? Good point, will think about it (would require a background task to monitor Canon menu).
[edit: it's not trivial, a lot of checks there require properties - hooks in Canon code; if we go that far, you may as well create a config preset with most of the stuff turned off]
Yeah, a better message could work, but didn't want to go to the trouble of loading the fonts just for that.