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

Allowing scripts to trap full & half press shutter button activations

  • 57 Replies
  • 10405 Views
Re: Allowing scripts to trap full & half press shutter button activations
« Reply #30 on: 25 / August / 2013, 13:02:00 »
Advertisements
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.
Each script "might" have a different exit key.  It's up the script author - just like the use of other keys in scripts.

Also,  I'm working on msl's & reyalps other suggestion to change the <ALT> string while the script is running to an exit key message.  Stay tuned.

Quite frankly,  I would expect a limited number of scripts to ever use this - the use case is fairly specialized.

Quote
2. It requires an extra key for script exit. I don't have an extra key on the D20 available.
Use "no_key" then.  Or control exit by using set_key_exit() with the <ALT> key if my patch to disable its functionality while scripts are running is accepted.

Quote
3. The <alt> key is presumably disabled and wasted. Instead of disabling <alt>, why not just make it always be the exit key?
So if you accidentally double click it, or hold a little too long, it terminates the script and throws you out of <ALT> mode too ?

Quote
I prefer that it require a long press to avoid accidental exits.
reyalp made the point earlier that sometimes you want to stop a script RFN.    I suppose I could add the "long press" option to set_key_exit() as a second parameter that takes a mSec value ?

Quote
The shutter press exit is redundant, but can be retained as a menu option if people think that's important.
Menu options for this have been discourage in every comment post so far.

Quote
Personally, I think people would quickly learn to use the <alt> key to exit.
Huge source of confusion between 1.2.0 and 1.3.0 would exist though.
« Last Edit: 25 / August / 2013, 13:07:01 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Allowing scripts to trap full & half press shutter button activations
« Reply #31 on: 25 / August / 2013, 13:17:42 »
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>
Done :



Patch file attached - same as v4 but it modifies the <ALT> text.  Its an admitted hack as I don't want to work too hard at this point give everyone's opinions about the best way to do this.  Again,  I added stuff to conf.c as a convenient place to put it for demo purposes.

Modified test script :
Code: [Select]
--[[
@title ShootFull
@param k Key
 @default k 0
 @values k shoot_full display menu set no_key
 --]]
  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"}

  if k==0 then kstr="shoot_full" end
  if k==1 then kstr="display" end
  if k==2 then kstr="menu" end
  if k==3 then kstr="set" end
  if k==4 then kstr="no_key" end
  set_exit_key(kstr)
  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

Update : figured out how to link global variables into flt module code. Still ugly, just less ugly.
« Last Edit: 25 / August / 2013, 15:08:05 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: Allowing scripts to trap full & half press shutter button activations
« Reply #32 on: 25 / August / 2013, 14:42:13 »
Quote
2. It requires an extra key for script exit. I don't have an extra key on the D20 available.
Use "no_key" then.  Or control exit by using set_key_exit() with the <ALT> key if my patch to disable its functionality while scripts are running is accepted.
If you had these options, it would do what I want, at least:
set_key_exit("alt")
set_key_exit("long_alt")
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>
Done :
That is pretty cool! But I'm also hoping to be able to turn off the <ALT> indicator from the script for a completely blank screen. With my time lapse program in continuous mode, the <ALT> indicator flashes on  and off at the bottom of the image display, which is very distracting. An option to turn off the entire CHDK OSD display, which also flashes, would be nice too, perhaps in the same new function. Right now, I have to turn off all the individual OSD items from the CHDK menu.

I still like my idea of always having the <ALT> key be the exit key. Instead of a menu function, then, you could have this script function:

alt_key_exit(0 or 1)  maybe 2 would require a long press?

With this function, you could still keep the current <alt> key behavior of pausing and restarting the script. I don't use it, but someone might be using it. The function would make the shoot_full key work in scripts, and switch the exit key to <alt> or <long_alt>.

You should be able to code it to require the <ALT> key to be released after script exit before CHDK recognizes it. As for a double click, I don't see a problem there. You could just press it again after the script exits to go back to <ALT> mode if that happens. Or you could code it so the key has to be down 50 msec to exit, or some other double click detector if it's a real problem.
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 #33 on: 25 / August / 2013, 14:48:55 »
If you had these options, it would do what I want, at least:
set_key_exit("alt")
set_key_exit("long_alt")
Not consistent with key usage in is_key()  or wait_key().   If we want to add "alt" as an additional meta-key then that should probably go in a seperate patch.

Quote
That is pretty cool! But I'm also hoping to be able to turn off the <ALT> indicator from the script for a completely blank screen. With my time lapse program in continuous mode, the <ALT> indicator flashes on  and off at the bottom of the image display, which is very distracting. An option to turn off the entire CHDK OSD display, which also flashes, would be nice too, perhaps in the same new function. Right now, I have to turn off all the individual OSD items from the CHDK menu.
One thing at a time - start another thread for that.  At a minimum, it will be a completely seperate patch from what I've done here.

Quote
I still like my idea of always having the <ALT> key be the exit key.
You've said that before - we get it that you like it.  I don't favor it for reasons I have also stated.  Let's see what anyone else has to say?
« Last Edit: 25 / August / 2013, 15:07:41 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline philmoz

  • *****
  • 3155
    • Photos
Re: Allowing scripts to trap full & half press shutter button activations
« Reply #34 on: 25 / August / 2013, 15:57:05 »
Update : figured out how to link global variables into flt module code. Still ugly, just less ugly.

Would be better in either 'conf' or 'camera_info' - avoids the overhead of exporting the names.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)

Re: Allowing scripts to trap full & half press shutter button activations
« Reply #35 on: 25 / August / 2013, 16:31:40 »
Update : figured out how to link global variables into flt module code. Still ugly, just less ugly.
Would be better in either 'conf' or 'camera_info' - avoids the overhead of exporting the names.
Thanks.   I had it in conf but figured that was probably a "no no" and I was just being a lazy.  At least I learned how to do it properly now.  Conf seems to be tightly tied to configuration stuff stored on the SD card.  Is camera_info a better choice when all you want is a couple of shared variables?  (I suppose I could wrap it in a function call - but that adds export overhead too.)
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3155
    • Photos
Re: Allowing scripts to trap full & half press shutter button activations
« Reply #36 on: 25 / August / 2013, 16:58:26 »
Update : figured out how to link global variables into flt module code. Still ugly, just less ugly.
Would be better in either 'conf' or 'camera_info' - avoids the overhead of exporting the names.
Thanks.   I had it in conf but figured that was probably a "no no" and I was just being a lazy.  At least I learned how to do it properly now.  Conf seems to be tightly tied to configuration stuff stored on the SD card.  Is camera_info a better choice when all you want is a couple of shared variables?  (I suppose I could wrap it in a function call - but that adds export overhead too.)

There are a number of entries on 'conf' that aren't saved to the SD card; but either place should be fine.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)

Re: Allowing scripts to trap full & half press shutter button activations
« Reply #37 on: 25 / August / 2013, 21:25:38 »
Update : moved variable storage back to conf  (shootful_disable_v7.patch) and added uBASIC support (shootful_disable_v8.patch).

Test uBASIC script :

Code: [Select]
@title ShootFull
@param k Key
@default k 0
@values k shoot_full display menu set no_key
if k=0 then set_exit_key "shoot_full"
if k=1 then set_exit_key "display"
if k=2 then set_exit_key "menu"
if k=3 then set_exit_key "set"
if k=4 then set_exit_key "no_key"
:loop
    wait_click 0
    if is_key "shoot_full" then print "key press : shoot_full"
    if is_key "display" then print "key press : display"
    if is_key "menu" then print "key press : menu"
    if is_key "set" then print "key press : set"
    if is_key "no_key" then print "key press : no_key"
goto "loop" 
Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline lapser

  • *****
  • 1093
Re: Allowing scripts to trap full & half press shutter button activations
« Reply #38 on: 26 / August / 2013, 01:11:57 »
Update : moved variable storage back to conf  (shootful_disable_v7.patch) and added uBASIC support (shootful_disable_v8.patch).
Great work, Mr. wingz. I didn't test it, but I looked at the v8 patch file. I saw the reset exit key to shoot_full after the script is terminated by pressing the exit key, but I didn't see a reset after a normal script exit. Do you need to add that to script.c, or the 2 script modules?

Thanks again for all your work on this.
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 #39 on: 26 / August / 2013, 08:18:19 »
Do you need to add that to script.c, or the 2 script modules?
Apparently not.  Try it and see.
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics