From 662745e4288d350fa224ee6e3d4b062676c1d7c3 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Thu, 21 Nov 2024 14:20:00 +0100 Subject: [PATCH] canon imageformat: emit the current value even if we have no enum. https://github.com/gphoto/libgphoto2/issues/1060 --- camlibs/ptp2/config.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/camlibs/ptp2/config.c b/camlibs/ptp2/config.c index 8e5f831cb..7b0afd364 100644 --- a/camlibs/ptp2/config.c +++ b/camlibs/ptp2/config.c @@ -2737,6 +2737,8 @@ _single_EOS_ImageFormat_name(uint8_t val) static int _get_Canon_EOS_ImageFormat(CONFIG_GET_ARGS) { + int defaultset = 0; + gp_widget_new (GP_WIDGET_RADIO, _(menu->label), widget); gp_widget_set_name (*widget, menu->name); @@ -2755,8 +2757,26 @@ _get_Canon_EOS_ImageFormat(CONFIG_GET_ARGS) gp_widget_add_choice (*widget, buf); - if (val == dpd->CurrentValue.u16) + if (val == dpd->CurrentValue.u16) { + defaultset = 1; gp_widget_set_value (*widget, buf); + } + } + if (!defaultset) { + uint16_t val = dpd->CurrentValue.u16; + uint8_t val1 = (val >> 8) & 0xFF; + uint8_t val2 = (val >> 0) & 0xFF; + + const char* name1 = _single_EOS_ImageFormat_name(val1); + const char* name2 = _single_EOS_ImageFormat_name(val2); + + char buf[12] = { 0 }; + strcpy (buf, name1); + if (val2 != 0xFF) + sprintf (buf + strlen(buf), " + %s", name2); + + gp_widget_add_choice (*widget, buf); + gp_widget_set_value (*widget, buf); } return GP_OK;