Skip to content

Commit

Permalink
canon imageformat: emit the current value even if we have no enum. #1060
Browse files Browse the repository at this point in the history
  • Loading branch information
msmeissn committed Nov 21, 2024
1 parent d2d9dbe commit 662745e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion camlibs/ptp2/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand Down

0 comments on commit 662745e

Please sign in to comment.