Thanks for all your work on this. My patch evolved entirely from what you started, and what others suggested based on what you started.
My patch is best for me because it is the easiest to understand, use, and code. I'm no longer invested in getting any changes in the trunk. I'll be using my own CHDK mods anyway, so I can always just put this in my version.
One thing that could be done is to activate my patch with a menu option, i.e. "Use <alt> as script abort key." That's all that needs to be done to resolve all the issues that you brought up. I'll be happy to write that in if everyone agrees.
Regarding your concern about pressing the <alt> key in a script having undesired effects, I solved that problem by changing where the <alt> key check goes in kbd.process.c. "key_pressed" is the counter for how long the <alt> key is down. Setting it to 0 when a script is running means the next if test is always false., and the <ALT> key starts out normally after the script is aborted by pressing and releasing the <ALT> key.
if( camera_info.state.state_kbd_script_run != SCRIPT_STATE_INACTIVE )
key_pressed=0; //disables <alt> key in scripts
if ( key_pressed && !usb_remote_active)
This is the entire patch:
Index: core/gui.c
=============================================================================
--- core/gui.c (revision )
+++ core/gui.c (working copy)
@@ -2292,7 +2292,10 @@
{
#ifdef CAM_DISP_ALT_TEXT
gui_draw_alt_helper();
- draw_string(((CAM_SCREEN_WIDTH/2)-(FONT_WIDTH*5/2)), (CAM_SCREEN_HEIGHT-FONT_HEIGHT), "<ALT>", MAKE_COLOR(COLOR_RED, COLOR_WHITE));
+ char* salt="Press <ALT> to abort";
+ if( camera_info.state.state_kbd_script_run == SCRIPT_STATE_INACTIVE )
+ salt="<ALT>";
+ draw_string(((CAM_SCREEN_WIDTH/2)-(FONT_WIDTH*5/2)), (CAM_SCREEN_HEIGHT-FONT_HEIGHT), salt, MAKE_COLOR(COLOR_RED, COLOR_WHITE));
#else
gui_draw_osd();
#endif
Index: core/kbd_process.c
=============================================================================
--- core/kbd_process.c (revision )
+++ core/kbd_process.c (working copy)
@@ -129,8 +129,10 @@
// While running Alt. mode shoot key will start a script execution.
// alt-mode switch and delay emulation
-
- if ( key_pressed && !usb_remote_active )
+
+ if( camera_info.state.state_kbd_script_run != SCRIPT_STATE_INACTIVE )
+ key_pressed=0; //disables <alt> key in scripts
+ if ( key_pressed && !usb_remote_active)
{
if (kbd_is_key_pressed(conf.alt_mode_button)
|| ((key_pressed >= CAM_EMUL_KEYPRESS_DELAY)
Index: core/script.c
=============================================================================
--- core/script.c (revision )
+++ core/script.c (working copy)
@@ -134,8 +134,10 @@
// Main button processing for CHDK Script mode
static int gui_script_kbd_process()
{
- // Stop a script if the shutter button pressed in Script mode
- if (kbd_is_key_clicked(KEY_SHOOT_FULL))
+ // Stop a script if the ALT button pressed in Script mode
+// if (kbd_is_key_clicked(KEY_SHOOT_FULL))
+
+ if (camera_info.state.kbd_last_clicked==conf.alt_mode_button)
{
script_console_add_line(LANG_CONSOLE_TEXT_INTERRUPTED);
if (camera_info.state.state_kbd_script_run == SCRIPT_STATE_INTERRUPTED)