I'll probably start a thread...
playing with this, I can get well behaved trigger in Y mode (using modified code), BUT..
after a random number of triggers (1-8 shots) it stops responding.
I checked with modified chdkptp liveview, and it confirms that at this point, the active buffer is changed. Live view uses the same logic to get the view, and it just shows a totally dark screen when motion_detect stops triggering so we are processing the wrong buffer at this point and it seems to stay that way for quite awhile (since the camera isn't doing anything much).
So we may be back to square one unless we can find the correct live buffer, or do some hack to force the live buffer back to the first one, or check all the buffers....
If I quickly scanned the buffer candidates, presumably, the dark ones are not live?