To understand this idea, you need to forget what the "H" means in CHDK, and think like like a Canon camera programmer. You're assigned the job of triggering the camera with the shutter button.
Unlike all the other buttons, the shutter button has 3 states. I'll call them UP, DOWN, and HALF.
Based on the shutter button, you are asked to trigger 2 camera actions. I'll call them SHOOT and METER
You have one extra input. I'll call it: IS_METERED. I believe this is the same as the current "get_shooting()," which probably should have been called, "get_metered()".
You have a function that is polled repeatedly that can check the status of the shutter button. You are notified when the camera is ready to shoot again after taking a shot.
This is they way I think the Canon programmer solved this problem:
boolean wasUP -- shutter has been UP since last shot
boolean wasHALF -- shutter button has been HALF since last shot
shutter=UP --starts in up position
1. wait until ready to shoot .. monitor shutter and set wasUP and wasHALF true if the shutter is ever in these states
2. if shutter is DOWN when ready to shoot, and wasUP is TRUE, then METER() & SHOOT()
if shutter is DOWN when ready to shoot, and wasHALF is TRUE, then wait for IS_METERED and SHOOT()
if shutter is DOWN when ready to shoot, and both wasUP and wasHALF are false, then do nothing
(continuous mode would shoot in some manner)
if shutter is HALF and IS_METERED is false, then METER()
3. SHOOT(), taking a picture, resets wasUP and wasHALF to false.
Anyway, I hope you get the idea of how I think the shutter works. Another way to look at it is that while the camera is busy shooting a picture, it is monitoring UP clicks and HALF UP clicks, not DOWN clicks. If you want the camera to shoot a picture immediately when it is ready, the shutter must be DOWN, and must have been either HALF way up, or fully UP since the last shot, for the camera to shoot another picture right away.
The current implementation of the function shoot() does a half press, waits for IS_METERED (get_shooting()), and then does a brief DOWN UP click. For this to work, the camera must be finished with the last shot, and ready to shoot again during this brief DOWN UP click. The camera will only shoot a picture if the shutter is DOWN at the time it becomes ready to shoot.
So the way to get the camera to shoot as soon as it finishes the last shot is to hold the shutter DOWN until the shot starts, which I detect when shutter_open_tick_count changes. Then, you have to release the shutter, to HALF if you want to skip metering, i.e. release("shoot_full_only"), or to UP and wait for IS_METERED to be false, if you want to meter the next shot.
I think the shoot() bug we've been talking about happens when get_shooting() becomes true, but the camera is still not ready to shoot, i.e. because it is still waiting for the flash to be ready, or a task is a little slow. So if the shutter goes back UP before the camera is ready for the shot, it won't take the shot. shoot() hangs because it waits for SHOOTING_PROGRESS_PROCESSING, which never happens. philmoz was able to fix the hang part by changing shoot() to wait for !get_shooting(), but it still misses shots. This is the link to the shoot() bug I've been talking about.
http://chdk.setepontos.com/index.php?topic=9118.msg95097#msg95097So if my theory is correct, this should be fixed by holding the shutter button down until the shutter opens, then letting it up so the camera will take another shot as soon as possible the next time it goes down, regardless of when that is.