CHDK script - inconsistencies with ALT mode - page 2 - General Discussion and Assistance - CHDK Forum  

CHDK script - inconsistencies with ALT mode

  • 31 Replies
  • 5449 Views
*

Offline reyalp

  • ******
  • 14082
Re: CHDK script - inconsistencies with ALT mode
« Reply #10 on: 08 / May / 2021, 13:31:45 »
Advertisements
The broader question might be whether anyone has done anything dependent on the behaviour of enter_alt(  ) being diffferent than pressing the <ALT> key when a script is running outside of <ALT> mode?  I don't think so FWIW.
Yeah, I think that's the right question, and probably the right answer.

IMHO, it really doesn't make sense to have a weird "script running in alt mode but with the alt gui handler" state you can only access with key presses. If someone was relying on this behavior, they can complain, and we can try to accommodate whatever the actual use case was.

Quote
I believe @reyalp 's usual advice is that many scripted actions when the camera is not in <ALT> mode are indeterminate?
Yes, and I stand by that, but it's also a lazy cop-out. It's been 10+ years, if it's undefined, we should define it in some way that is useful (edit: Or at least unambiguous).


In ML scripts always run outside of ALT mode, ie there is no ALT mode, other than by hijacking one button to access ML’s menu.

For whatever reason, and this is my ignorance, in CHDK we must start a script in ALT mode, where access to camera functionality is limited.

So I guess the question, to address my ignorance, is, does CHDK require to start a script in ALT mode, or is it a legacy matter, ie CHDK scripts could be allowed to start outside of ALT mode, ie running in the background.
In CHDK, alt mode is, by definition, how you access CHDK functionality (except for a few shortcuts which are a different problem for a different day). So you need to be in alt mode to *start* a script.

AFAIK, what happens if you leave alt mode with a script running was never specifically defined. The ability to do it exists because the code doesn't prevent it, and the resulting state is just however those bits of code happen to interact. It's possible there was some intended behavior at some point, but if so, it certainly hasn't been maintained in all the time I've been involved.

In the meantime, the code has gotten more complicated. "Alt mode" actually involves several different pieces of state: How keys are handled, what the GUI handler is and so on.   

This area has been an ongoing source of bugs and confusion (most recently https://chdk.setepontos.com/index.php?topic=14130.msg144400#msg144400 but also been a involving PTP)

Alt mode itself is somewhat poorly defined, in the sense that there's the initial state when you press alt (the alt GUI handler), and the various sub states of using menus, running script and so on which are described as running "in" alt mode.


FWIW, there is an alternate approach to accessing "normal" camera functionality with a script running: You can forward the keys presses and releases, like https://chdk.fandom.com/wiki/Lua/Scripts:_Continuous_Autoexposure does. However, this is definitely clunkier than working directly in the Canon UI, and doesn't work for any keys that aren't known to the script.
Don't forget what the H stands for.

Re: CHDK script - inconsistencies with ALT mode
« Reply #11 on: 08 / May / 2021, 13:38:59 »
@reyalp

Once again, thanks for your insight, however, I’m not sure I personally am any more educated  ;)

The bottom line is, as long as I can continue to move between ALT and non AlLT modes in my script, I’ll be happy.

*

Offline reyalp

  • ******
  • 14082
Re: CHDK script - inconsistencies with ALT mode
« Reply #12 on: 08 / May / 2021, 14:13:17 »
The bottom line is, as long as I can continue to move between ALT and non AlLT modes in my script, I’ll be happy.
You're welcome to use it if it works for you, but as long as the behavior is undefined, you shouldn't be surprised if it changes or does unexpected things.

It would be helpful to define what we mean by running a script outside of alt mode:
1) Does script execution continue? Currently it does, and it seems like it should. If it wants to do nothing outside of alt, it can just sit in a loop sleeping and checking alt.

2) Does the script see key presses? Apparently does. Again, script could detect alt and ignore keys it doesn't care about

3) Does the Canon firmware see key presses. Again yes, and there wouldn't be much point in leaving alt if it didn't

4) Can the script send key presses? Guessing it currently can't? Mixing scripted and human key presses would probably be confusing, so OK? Script could post levents

5) OSD behavior / drawing behavior. Should there be an indication the script is running? Do script drawings still work?

Regarding 2 and 3, it might be desirable for script to be able to consume certain keys without the canon firmware seeing them, but I don't think the current kbd code would easily support this. Scripts that want this kind of behavior should probably use the forwarding approach instead.
Don't forget what the H stands for.

Re: CHDK script - inconsistencies with ALT mode
« Reply #13 on: 08 / May / 2021, 14:28:27 »
@reyalp

The vision behind my bracketing script is that the user is presented, in real-time, DoF info to inform their manual focusing, eg setting infinity focus and focus bracketing, ie outside of ALT.

Outside of ALT you can access the normal camera functionality, eg setting ISO etc, which can’t be done (easily) in ALT mode.

The other requirement is to auto focus/exposure, and that is done from ALT mode.

Thus, being able to switch between the two mode, without the camera blowing up  :D is a critical need, IMHO

Bottom line: I guess there are two types of script, those that a user initiates to carry out a specific set of events/functions, which, having completed, the script will stop/exit. Then there are those scripts that run, in the background, that provide feedback to the user as long as the camera is on, or until the user terminates the script. My script does both  ;)


*

Offline reyalp

  • ******
  • 14082
Re: CHDK script - inconsistencies with ALT mode
« Reply #14 on: 08 / May / 2021, 15:06:28 »
Then there are those scripts that run, in the background, that provide feedback to the user as long as the camera is on, or until the user terminates the script.
What I'm trying to say is that this has never (at least for the last ~11 years) been a designed, intentionally supported use case. But it sounds like the current behavior at least mostly does what you want, so we can make it supported by identifying what it currently does, and defining that as the desired behavior.

Other potential areas of ambiguity are wheel and touch screen behavior.

Quote
Outside of ALT you can access the normal camera functionality, eg setting ISO etc, which can’t be done (easily) in ALT mode.
FWIW, forwarding normal key presses from alt mode is not particularly difficult, and works fine for most common cases.
Don't forget what the H stands for.

Re: CHDK script - inconsistencies with ALT mode
« Reply #15 on: 08 / May / 2021, 15:41:17 »
@reyalp

Thanks for the response and the recognition of ‘my’ use case ;-)

As you say, as long the current functionality is ‘protected’, I’ll be happy.

One point of clarification, if I may, I fully understand what you are saying about the key presses, ie in ALT mode, however, one key press is, I believed, denied to us in ALT, ie the full shutter press. The work around, I guess, being to hijack another key as the ‘full shutter’ stimulant.

Cheers

Garry

*

Offline reyalp

  • ******
  • 14082
Re: CHDK script - inconsistencies with ALT mode
« Reply #16 on: 08 / May / 2021, 15:46:50 »
One point of clarification, if I may, I fully understand what you are saying about the key presses, ie in ALT mode, however, one key press is, I believed, denied to us in ALT, ie the full shutter press. The work around, I guess, being to hijack another key as the ‘full shutter’ stimulant.
No, you can change the script exit key, including setting it to "no_key" https://chdk.fandom.com/wiki/Script_commands#set_exit_key
Don't forget what the H stands for.

Re: CHDK script - inconsistencies with ALT mode
« Reply #17 on: 08 / May / 2021, 15:49:08 »
@reyalp

Quote
No, you can change the script exit key, including setting it to "no_key" https://chdk.fandom.com/wiki/Script_commands#set_exit_key

 :) I need to do some thinking  ;)


Re: CHDK script - inconsistencies with ALT mode
« Reply #18 on: 08 / May / 2021, 17:18:39 »
@reyalp

Once again thanks for the education...it's never over ::)

I've recast my script to run nearly 100% in ALT mode, including taking images with the shutter and executing any bespoke bracketing requests, via a SET trigger. All looks OK at the moment, although I will maintain some in and out of ALT functionality, but it will be minimal.

I have seen some ALT/non-ALT weirdness, but @philmoz is looking at that I believe.

This leads me to a(nother) question.

What is the downside/risks, once Phil sorts out the weirdness, of switching back and forth between ALT and non-ALT, when a script is running.

Cheers

Garry

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: CHDK script - inconsistencies with ALT mode
« Reply #19 on: 08 / May / 2021, 17:23:45 »
Thanks for all the great feedback - lots to think about.

One thing that occurs to me is that the current behaviour (state 4) allows you to change CHDK settings while a script is running.

To allow consistency and maybe reduce confusion I'm thinking we should:
- change the <ALT> text at the bottom to something else when a script is running in alt mode - e.g. <SCR>
- if a script is running the alt button would cycle between <ALT>, <SCR> and normal modes.

That way you could return to the script mode and cancel the script, or alt mode to change CHDK settings.

The 'enter_alt' Lua function would always go to <SCR> mode.
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)
  g7x2 (1.01a, 1.01b, 1.10b)

 

Related Topics