Allowing scripts to trap full & half press shutter button activations - page 3 - General Discussion and Assistance - CHDK Forum

Allowing scripts to trap full & half press shutter button activations

  • 57 Replies
  • 22906 Views
Re: Allowing scripts to trap full & half press shutter button activations
« Reply #20 on: 24 / August / 2013, 20:38:07 »
Advertisements
I'm not saying we shouldn't use your solution in the end, but IMO this presents some usability issues that should be thought through.
Understood.  That's what we are doing here but its always a little painful debating with an online committee.  And I don't care whose code / solution we use as I can now see my way to completing this with only a script and its such a small code tweak to get there :


And I would probably autostart it !   8)

Quote
I probably wouldn't worry about this autostart case, except that a number of people have showed up on the forum with a script stuck on autostart. The script providing a way to exit is ok in theory, but it seems quite likely some published scripts would pick a button that doesn't exist on every camera.
I'm thinking that the odds of having a script stuck on autostart that also disables the shutter key is something I could live with.   Somebody posts on the forum and we tell them to deleted the script from their SD card.

Quote
Again, I'm not rejecting your idea. I just think it's worth exploring the options and issues.
Here's yet another option.   We make the "long press" delay adjustable from within the script - but its defaulted to zero.    That way you can set it to one second and use a click action to take shots and a press & hold to abort.  If someone really wants to have a press & hold for continious shooting,  make the delay longer ? Set it up so that when you set the delay in the script, it resets the timer.   Constantly poking 2 seconds to the delay while the script runs in continuous keeps the script from timing out.
« Last Edit: 24 / August / 2013, 20:47:06 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: Allowing scripts to trap full & half press shutter button activations
« Reply #21 on: 24 / August / 2013, 21:59:38 »
OK, let me put in my final 2 cents here. Let's keep it really simple.

Activate and deactivate it with a new script function. Deactivate on script exit or script error.

That's it. No menu options, no long press escapes, no nothing. If the script hangs, turn off the power. If you write a script that activates it, you gotta provide a clean script exit.

Once it's working this way, we can figure out how to get around any autostart problems and whatever else comes up, if needed. It's simple this way, and no old scripts are affected, so it seems safe to put in the trunk and go from there.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: Allowing scripts to trap full & half press shutter button activations
« Reply #22 on: 24 / August / 2013, 22:36:17 »
Activate and deactivate it with a new script function. Deactivate on script exit or script error.
So in other words, let's just do it the way you originally suggested?   :-[

But it might be more useful to do it as a script function, after we get it working.

I think the opinions expressed by others about having an "exit" mechanism for scripts that don't quite do what the author expected them to do  (no matter how well tested) is a good idea.

« Last Edit: 24 / August / 2013, 22:39:50 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: Allowing scripts to trap full & half press shutter button activations
« Reply #23 on: 25 / August / 2013, 02:06:03 »
I think the opinions expressed by others about having an "exit" mechanism for scripts that don't quite do what the author expected them to do  (no matter how well tested) is a good idea.
OK with me, but hopefully it will be hard to trigger an exit accidentally. That's my main problem at the moment.

Again, many thanks for working on this. I'm sure whatever you come up with will be fine with me.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos


*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Allowing scripts to trap full & half press shutter button activations
« Reply #24 on: 25 / August / 2013, 05:09:32 »
I think the discussion is on a good way. The 'shootfull_disable_v3' patch is a fine solution and works well with the restriction of the continuous shooting.

I still would prefer a script function as one and only option. The script author has the full responsibility and not CHDK. A solution for the 'exit mechanism' issue could be an option in the script function for the shutter button.
Code: [Select]
use_full_shutter(<0|1> [,<exit button>])A daring thought: The <ALT> indicator could be used as indicator for the alternative exit button.
- exit button not defined: <no exit>
- exit button defined, e.g. display button: <disp>

Btw., thanks to all, who trying tirelessly CHDK to improve.

msl
CHDK-DE:  CHDK-DE links

*

Offline lapser

  • *****
  • 1093
Re: Allowing scripts to trap full & half press shutter button activations
« Reply #25 on: 25 / August / 2013, 10:54:13 »
OK, here's another final 2 cents, but I think it may be the answer this time.

Let's just use the long press <alt> button as the only user-triggered script exit. The shutter button would always be a normal button in a script. No new menu items, and no new script functions needed.

Right now, we have 2 "magic" script exit buttons: "shoot_full" and <alt>. We really only need one. The current <alt> click pauses and restarts the script. That just messes my scripts up. Does anyone use it? I'd be in favor of eliminating it, but if we have to keep it, we could make <alt> click exit the script, and <alt> long press pause it.

Proposed new <alt> button behavior
                               CHDK          //      Scripts       //        (Current script behavior)
<alt>_click              toggle <alt> mode  // Exit script // Pause and restart script
<alt>_long_press    trigger <alt> key camera function  // Pause and restart script // ?
shoot_full               normal function // normal script key // Exit script
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: Allowing scripts to trap full & half press shutter button activations
« Reply #26 on: 25 / August / 2013, 11:07:56 »
Let's just use the long press <alt> button as the only user-triggered script exit. The shutter button would always be a normal button in a script. No new menu items, and no new script functions needed.
The issue with that is the huge installed base of user and CHDK docs that expect a script to terminate when the shutter button is pressed.

Quote
The current <alt> click pauses and restarts the script.
I just posted a patch to disable that "feature".  And on my A1200,  I believe that pressing <alt> takes you out of ALT mode with the script still running.  Probably not a good thing.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: Allowing scripts to trap full & half press shutter button activations
« Reply #27 on: 25 / August / 2013, 11:57:27 »
The issue with that is the huge installed base of user and CHDK docs that expect a script to terminate when the shutter button is pressed.
I'd be OK with a menu option to disable the shoot_full script interrupt so the installed base could keep it if they want. I think you've already coded that.
Quote
Quote
The current <alt> click pauses and restarts the script.
I just posted a patch to disable that "feature".  And on my A1200,  I believe that pressing <alt> takes you out of ALT mode with the script still running.  Probably not a good thing.
So how about using a long <alt> press to exit the script if a script is running. That is, it would do the same thing as the current shutter button. It would then take the place of the shutter button for script exit if you disabled shutter script exit in the menu. I think the long <alt> press code is already in there, isn't it? This way, a script function wouldn't be needed, which should simplify things a lot.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos


Re: Allowing scripts to trap full & half press shutter button activations
« Reply #28 on: 25 / August / 2013, 12:25:19 »
I still would prefer a script function as one and only option. The script author has the full responsibility and not CHDK. A solution for the 'exit mechanism' issue could be an option in the script function for the shutter button.
Okay, a new patch file based on msl's suggestion.  I actually really like this one.

This patch simply adds one new function :   set_exit_key( "keyname" )   where keyname is the same as those used for is_key() & wait_key().   

Calling the function changes the key that will terminate the script.  If you are brave, you can use "no_key" as the passed parameter and then script exit is only when the script terminates or the camera is powered off.

The exit key reverts to the FULL_PRESS button at script termination.

Modified test script :
Code: [Select]
--[[
 @title ShootFull
 --]]
  set_console_layout(1, 0, 45, 12)
  key_table = {"up" , "down", "left", "right", "set", "shoot_half", "shoot_full", "shoot_full_only","zoom_in", "zoom_out",
             "menu", "display", "print", "erase", "iso", "flash", "mf", "macro", "video",
             "timer", "expo_corr", "fe","zoom_assist","ae_lock","metering_mode","no_key"}
  set_exit_key("display")
  repeat 
    wait_click()
    kstring="key press : "
    nf_flag=true
    for key_nr=1, table.getn(key_table) do
        if (is_key(key_table[key_nr])) then
            print(kstring..key_table[key_nr])
            nf_flag = false
        end
    end
    if ( nf_flag ) then print("no key name found") end
  until false
  --until is_key "menu"
  print("menu key = exit")

Implementation note :  I only cobbled together the Lua version pending further review of the general concept.  I'll add uBASIC prior to any formal submittal.   Also,  I added a current exit key code number variable to the global conf structure as I could not quickly figure out how to share a global variable with the luascript.c flt module.  There is almost certainly a better way to do this.
« Last Edit: 25 / August / 2013, 12:31:35 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: Allowing scripts to trap full & half press shutter button activations
« Reply #29 on: 25 / August / 2013, 12:49:59 »
This patch simply adds one new function :   set_exit_key( "keyname" )   where keyname is the same as those used for is_key() & wait_key().   
My problem with this is:

1. Each script will have a different exit key. It will be a challenge to figure out how to force a script exit. You'll have to remember a different key for each script.

2. It requires an extra key for script exit. I don't have an extra key on the D20 available.

3. The <alt> key is presumably disabled and wasted.

Instead of disabling <alt>, why not just make it always be the exit key? I prefer that it require a long press to avoid accidental exits. The shutter press exit is redundant, but can be retained as a menu option if people think that's important. Personally, I think people would quickly learn to use the <alt> key to exit.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

 

Related Topics