Open sh0 opened 4 years ago
Thanks, I'll need more time to check this. This part of the code is a mess, definitely, it would be great to clean this up.
I checked a few things and the history of this fields:
pslr_exposure_mode_t
but the values are the same as the pslr_gui_exposure_mode_t
in pkTriggerCord https://sourceforge.net/p/pkremote/code/HEAD/tree/pslr.hpslr_exposure_mode_t
.The values of pslr_exposure_mode_t
are rather similar to the PictureMode exif field ( https://exiftool.org/TagNames/Pentax.html ) the values of pslr_gui_exposure_mode_t
more resembles the values printed on the camera.
So why was this conversion added by me when I added the support for K-x? I don't really remember, but probably I realised that when I set the camera to M mode I read the value 8 instead of the expected 6. Setting exposure values was not possible for K-x, so I couldn't check that part.
Why do we need this at all? I tested the exposure mode setting using K-70. It only works if I set the camera to user mode. Let's say I want to change to Sv mode. The value is 15 in pslr_exposure_mode_t
and 2 in pslr_gui_exposure_mode_t
. I have to send the value 2 to the camera (I turned off all the conversions for the test). The camera will change to Sv mode, and reading back will get me the value of 15. So it seems to me, the camera has different values for reading or writing this field (but why?).
So it means that pslr_set_exposure_mode
should either get the gui value or convert the non-gui value before sending the value to the camera. It is clearly wrong that in case of the GUI we have a double conversion. It is also true that it's better to store the non-gui version values in pslr.c
since it has more values.
Thanks for taking a look. I'm also not quite sure what the best option is here.
I don't known how to handle all the user mode value conversions, but it feels to me that having only pslr_exposure_mode_t
in pslr.c
would at least simplify the API. Last time I looked, it seemed like libgphoto2
was also using the exposure mode settings incorrectly because it was mixing GUI and non-GUI enum values. So some clarity from the user-facing aspects would be nice.
For K-30 camera the issue #52 was somewhat promising that my patch allowed the exposure mode to be correctly recognized. I don't really remember all the details though.
There are some weird things going on with
pslr_exposure_mode_t
andpslr_gui_exposure_mode_t
.My understanding is that there was a commit
582e03f7926314ee6fbec4f1b053e222d96cb6e0
(Wed May 29 18:04:27 2013 +0000) which added separate GUI exposure mode enumpslr_gui_exposure_mode_t
, but the conversion between enums was forgotten inuser_mode_combo_changed_cb
and/orpslr_set_exposure_mode
. Then recently this issue was discovered and commitf9e23edcf88bfc5ca356bbfce91ca085aef56e54
(Sun Mar 22 14:03:39 2020 +0100) tried to fix it by adding enum conversion topslr_set_exposure_mode
. However the conversion is done in the wrong direction.To try to summarize, currently:
pktriggercord.c
callspslr_set_exposure_mode
withpslr_gui_exposure_mode_t
argument.pktriggercord-cli.c
callspslr_set_exposure_mode
withpslr_exposure_mode_t
argument.pslr.c
functionpslr_set_exposure_mode
incorrectly convertspslr_exposure_mode_t
topslr_gui_exposure_mode_t
. In CLI case this is incorrect as the enum should be left topslr_exposure_mode_t
and in GUI case the mode is already inpslr_gui_exposure_mode_t
type so it does the conversion twice.I think the whole mode switching code was buggy before
need_exposure_mode_conversion
flag was added for K-30 camera. This can also be seen from the issue #52 that something is wrong. So I think that the K-30 handling was probably not needed in the first place.My experimental fix is as follows:
pslr.c
keeps track of camera mode only usingpslr_exposure_mode_t
type. This is preferred overpslr_gui_exposure_mode_t
as it has more entries and is more accurate.pktriggercord-cli.c
code mostly operates withpslr_exposure_mode_t
type except fewPSLR_GUI_EXPOSURE_MODE_B
compares which were changed.pktriggercord.c
now converts betweenpslr_gui_exposure_mode_t
andpslr_exposure_mode_t
as needed.pslr.c
has new functionspslr_convert_exposure_mode_to_gui
andpslr_convert_exposure_mode_from_gui
instead of singleexposure_mode_conversion
function.need_exposure_mode_conversion
structure entry andpslr_get_model_need_exposure_conversion
function are removed.I don't have Pentax cameras so someone else would need to do tesing.