SX40HS. Don't work press/release zoom_in/out from CHDKPTP - General Help and Assistance on using CHDK stable releases - CHDK Forum supplierdeeply

SX40HS. Don't work press/release zoom_in/out from CHDKPTP

  • 2 Replies
  • 4240 Views
SX40HS. Don't work press/release zoom_in/out from CHDKPTP
« on: 17 / September / 2012, 12:42:24 »
Advertisements
Code: [Select]
con1>=press(zoom_in)Don't work and there are no any error or warning messages. Is it true?

Camera    Canon SX40HS
Firmware  100I
CHDK        2033
CHDKPTP  278

Re: SX40HS. Don't work press/release zoom_in/out from CHDKPTP
« Reply #1 on: 17 / September / 2012, 12:48:32 »
click("zoom_in/out") is working.

*

Offline reyalp

  • ******
  • 14082
Re: SX40HS. Don't work press/release zoom_in/out from CHDKPTP
« Reply #2 on: 17 / September / 2012, 16:07:49 »
This is an artifact of the way scripting works. Each = command runs a script. When a script ends, any keys pressed by the script are implicitly released. This is because scripting was originally designed for scripts run through the script menu. For PTP, it would make sense to have a way to override this behavior.

If you do something like =press('zoom_in'); sleep(n) to hold the key for a specific time.

If you want to be able to press/release under your own control instead of a fixed wait, there are some other options
1) Use a long running script like the msg_shell rlib (see lua/rlibs.lua). This runs indefinitely and listens for messages, which you can send by putm. Not that while this script is running, any other chdkptp functions that expect to run a script will not work.
2) Use post_levent_to_ui (see http://chdk.wikia.com/wiki/LogicalEvent) to send Canon keypress events. These should be called something like "PressWideButton", "UnpressWideButton", "PressTeleButton" etc.  You can use get_levent_def_by_index(index) (described at http://chdk.wikia.com/wiki/Lua/Lua_Reference/Levent ) to iterate over the levents available on your camera.
Don't forget what the H stands for.

 

Related Topics