should the Alt key be disabled while a script is active ?

  • 21 Replies
  • 3480 Views
Re: should the Alt key be disabled while a script is active ?
« Reply #10 on: 26 / August / 2013, 23:12:40 »
Advertisements
I'd argue that running scripts in alt mode is a design flaw and by default scripts should always run in normal mode.
YES!  I like that.  But the only real difference seems to be which menu system is active ( Canon or CHDK ) and who gets the key presses (Canon or CHDK ).   Clearly CHDK (& the running script) should get the key presses when the script is running.  Does anything else change ?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3070
    • Photos
Re: should the Alt key be disabled while a script is active ?
« Reply #11 on: 26 / August / 2013, 23:21:05 »
I'd argue that running scripts in alt mode is a design flaw and by default scripts should always run in normal mode.
YES!  I like that.  But the only real difference seems to be which menu system is active ( Canon or CHDK ) and who gets the key presses (Canon or CHDK ).   Clearly CHDK (& the running script) should get the key presses when the script is running.  Does anything else change ?

Scripts should pause when either Canon or CHDK menu is open. At other times a running script should see key presses first. This would probably need some extensions to allow the script to use the key press and block it from being seen by CHDK or the Canon firmware, or allow it through (like CHDK does now to stop the firmware responding).

This would not be a small change and may break some scripts; but that's why we have a new version :)

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)

Re: should the Alt key be disabled while a script is active ?
« Reply #12 on: 26 / August / 2013, 23:34:37 »
Scripts should pause when either Canon or CHDK menu is open.
Do "we" know when the Canon UI has a menu open?  If so, blocking entry to <ALT> mode seems like a logical thing to add regardless of our current conversation.   If only to avoid the stunning array of weird UI colors that result.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: should the Alt key be disabled while a script is active ?
« Reply #13 on: 27 / August / 2013, 00:26:51 »
Interesting comments. My perspective is as a script writer, and my priority is to give scripts complete control while they're running. To that end, I don't want users pausing the script and doing things unless I write it into the script, i.e. with exit_alt().

Also, a better way to disable the <alt> button with scripts running is like this:

   // alt-mode switch and delay emulation
  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 allows using the <alt> key to abort scripts correctly in script.c like I did in my patch. It's too bad nobody likes this. It works great, and avoids a lot of complexity compared to the other ideas.

EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos


*

Offline reyalp

  • ******
  • 11495
Re: should the Alt key be disabled while a script is active ?
« Reply #14 on: 28 / August / 2013, 22:05:30 »
I'd argue that running scripts in alt mode is a design flaw and by default scripts should always run in normal mode.
I don't really agree. The defining characteristic of "non-alt" mode is that you interact with the canon firmware normally. It doesn't make sense for this to be the script mode, since a major feature of script is the ability to interact with the script instead.

I agree there is a use case scripts that essentially sit in the background and let you interact with the canon firmware. I'm less convinced it should be the default, for users trying to do something simple with a script having it the current behavior is probably quite a bit clearer, the script is either running the camera or not.
Quote
Entering alt mode should pause the script so you can change CHDK settings. This would also allow for script menu options to abort/pause/restart the currently running script.
It sounds to me like you are saying script mode should effectively be a third mode, that is neither alt nor normal. I don't necessarily disagree.
Quote
Scripts should pause when either Canon or CHDK menu is open.
If initiated by the user maybe, but remember that manipulating the canon menu is something that is frequently done from script, and the ability to manipulate the CHDK menu is strongly desired (mostly for PTP control where the physical keyboard is inaccessible but I'm sure people would find other uses)
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3070
    • Photos
Re: should the Alt key be disabled while a script is active ?
« Reply #15 on: 28 / August / 2013, 23:35:59 »
I'd argue that running scripts in alt mode is a design flaw and by default scripts should always run in normal mode.
I don't really agree. The defining characteristic of "non-alt" mode is that you interact with the canon firmware normally. It doesn't make sense for this to be the script mode, since a major feature of script is the ability to interact with the script instead.

I agree there is a use case scripts that essentially sit in the background and let you interact with the canon firmware. I'm less convinced it should be the default, for users trying to do something simple with a script having it the current behavior is probably quite a bit clearer, the script is either running the camera or not.
Quote
Entering alt mode should pause the script so you can change CHDK settings. This would also allow for script menu options to abort/pause/restart the currently running script.
It sounds to me like you are saying script mode should effectively be a third mode, that is neither alt nor normal. I don't necessarily disagree.
Quote
Scripts should pause when either Canon or CHDK menu is open.
If initiated by the user maybe, but remember that manipulating the canon menu is something that is frequently done from script, and the ability to manipulate the CHDK menu is strongly desired (mostly for PTP control where the physical keyboard is inaccessible but I'm sure people would find other uses)

Good points - this is a complex topic and I don't think there will be many simple solutions.

The interactive VS background script concept is nice - although it raise the further problem of do you allow at least one of each to be running at the same time (could cause memory issues with Lua).

I think there is also a use case for allowing access to the CHDK and Canon menus while an interactive script is running; but I'm struggling to see how this could be done cleanly.

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)

*

Offline reyalp

  • ******
  • 11495
Re: should the Alt key be disabled while a script is active ?
« Reply #16 on: 29 / August / 2013, 00:03:10 »
The interactive VS background script concept is nice - although it raise the further problem of do you allow at least one of each to be running at the same time (could cause memory issues with Lua).
An alternative is to default to something like the current behavior (script gets all key presses except abort and/or alt mode) and allow scripts to specify which keys "pass through".

You can still only run one script at a time, but a script that sets all or almost all to "pass through" to the canon firmware. Or even just "forward" them by generating the corresponding press and release calls, but that would probably be fairly fragile. We could make the second option somewhat better by exposing the key state in a more sophisticated way to lua, the current functions are built around the limitations of ubasic.

You could do the reverse where the default was pass-through, but that seems like a needless change from the current behavior, and probably more confusing to newbies trying to write their first script.

As an aside, being able to run more than one script at once would be nice for PTP where you want to be able to say, read a value when something else is going on. But it opens up several cans of worms...

Quote
I think there is also a use case for allowing access to the CHDK and Canon menus while an interactive script is running; but I'm struggling to see how this could be done cleanly.
Like a "macro" kind of thing where you do something with the script and it does something with the canon (or chdk) menus?

Related to this topic and the discussion in http://chdk.setepontos.com/index.php?topic=10580.40 what if pressing the "alt" key while  a script was running brought up a special menu? This is sort of what you suggested earlier, but the script would still run as it does now in alt mode (the ability to "pass through" could still be implemented). The menu could have things like
"Kill script"
"Pause script" (or maybe it's just implicitly paused?)
"alt mode"
"exit alt"

This would essentially solve the problem of wanting to re-map the shutter button, because you'd always have the alt key. It would also make accidentally leaving alt more obvious, since the menu would pop up.
Don't forget what the H stands for.

Re: should the Alt key be disabled while a script is active ?
« Reply #17 on: 29 / August / 2013, 00:39:37 »
This would essentially solve the problem of wanting to re-map the shutter button, because you'd always have the alt key. It would also make accidentally leaving alt more obvious, since the menu would pop up.
It would solve some of the problems.   I pointed out some additional concerns in that other thread.
Ported :   A1200    SD940   G10    Powershot N    G16


Re: should the Alt key be disabled while a script is active ?
« Reply #18 on: 29 / August / 2013, 10:17:40 »
It sounds to me like you are saying script mode should effectively be a third mode, that is neither alt nor normal. I don't necessarily disagree.
In looking at the whole key remapping project from a high level,  its seems likely that we might even want four seperate modes :   Canon, <ALT>, CHDK_Menus, Script_Active

  • Canon :  allow any key to be remapped to any other key - covers the "my xyz button is broken"  and the "I don't like where the xyz button is located" or "interchange front and rear jog dial" cases.  CHDK script launch on the press of an assigned button
  • <ALT> :  <ALT> key mapping,  half press short cut keys and other short cut keys enable/disable/reassign.  Script launch on the press of an assigned button.
  • CHDK_Menus : shortcut keys disabled
  • Script_Active : remap shutter button and ALT button actions - allow zoom keys to be "passed through" - allow every key to be used under script control,  etc

I'll keep collecting stuff for this list.  I'm sure its not done yet.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: should the Alt key be disabled while a script is active ?
« Reply #19 on: 30 / August / 2013, 16:53:30 »
I guess it's clear that there is little support for disabling the <ALT> key while a script is running.

That being the case,  I wonder what people think about keyboard handling when a script is running outside of <ALT> mode?

Working on something today,  I realized that when I accidentally exited <ALT> with a script running,  both the Canon firmware and my script were receiving the same key presses. 

Is this a good thing?  Obviously, it messed up what my script was trying to do and made it unusable.  Not too hard to understand what a new user might think when finding himself in this situation.

Even if I wanted to, I'm not sure how I would add defensive code to detect or prevent this ?   Keep hammering out enter_alt() calls in my script's main loop?  Nasty.
« Last Edit: 30 / August / 2013, 17:03:22 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics