Some notes:
Attached is a list of focus related eventprocs registered by Mecha.Create (found via function at fc65fab8 in the 100c firmware)
There may be others registered by other functions called by Mecha.Create, but this group seemed to be the core focus related ones.
Of these, the following appear of interest:
GetFocusLensMoveMaxPosition
GetFocusLensMoveMinPosition
GetFocusLensCurrentPosition
MoveFocusLensWithPosition
The three Get functions take no arguments. From my testing on elph180, the Min and Max values do not change based on zoom. On that camera, they are 40 and 1840 respectively, and GetFocusLensCurrentPosition returns numbers in this range.
From observation with set_focus,
smaller position values correspond to
longer subject distances.
Moving on to MoveFocusLensWithPosition
WARNING: High risk of hardware damage ahead. You break it, you fix itThere was some previous experimentation with this function discussed in
the ixus160 thread but be warned not everything posted there is correct or safe, and even if it is correct on the camera discussed in that thread, it doesn't mean it's correct on yours.
As discussed in that thread, MoveFocusLensWithPosition takes three arguments. The first is a position, in the same units as the Get function discussed above.
The second is speed. Zero appears to be handled as a special case, and does a fast speed, similar to camera auto focus.
Contra the discussion in the ixus160, I found 100 was very slow (10 was imperceptibly slow and hit timeout errors). 1000 was still quite slow. It could perhaps be position units per second.
The third is unknown, but judging from firmware code (both elph180 and g5x) there are distinct cases for 1, 2, or any other value. I only tried 0, since the "any other value" case appeared simplest in the code.
I tested with the camera in MF mode (via set_mf(true)) since trying to set it with AF active seems like asking for trouble.
Generally speaking, it worked. Focus can be moved by position,
through full range specified by the Min and Max functions, at any focal length.
This means that the lens can be moved far outside the normal / useful SD range, which brings us to the fun part. In my final test, with the camera at max zoom, I set the position to 40, which worked, and made everything out of focus. Then I switched to play (which doesn't immediately retract the lens) and turned the camera off.
The lens started to retract, but didn't retract completely.
Crashing with the lens out is fairly common, and normally sorts itself on the next reboot, so I powered the camera back on… and the lens mechanism buzzed an twitched, and then the camera displayed "Lens Error" and shut down again, with the lens still out.
Powering cycling several more times failed to retract the lens.
Eventually with some light percussive maintenance (which may or may not have made any difference), I was able to boot into rec mode (again, unclear if attempting to boot into rec made any difference), and shut down cleanly, with the lens retracting normally.
Contra hacki's comment in this ixus160 thread, I strongly suspect this was triggered by having the lens in an abnormal position at shutdown
(since I don't think the camera crashed) (edit: see below), although I can't completely rule out other possibilities.
All that said, I would be quite reluctant to experiment with this on an expensive camera. If I did, I would try to restrict the "position" values used to something close to the range accessible via the Canon MF menu or set_focus().
edit:I
later determined that elph180 (sometimes?) crashes leaving MF mode, so there was likely a crash during shutdown. Whether the MoveFocusLensWithPosition was a factor is unclear.