diff --git a/camlibs/ptp2/config.c b/camlibs/ptp2/config.c index 578542ffb..eb5a50c9a 100644 --- a/camlibs/ptp2/config.c +++ b/camlibs/ptp2/config.c @@ -6230,6 +6230,7 @@ static struct submenu camera_settings_menu[] = { { N_("Clean Sensor"), "cleansensor", PTP_DPC_NIKON_CleanImageSensor, PTP_VENDOR_NIKON, PTP_DTC_UINT8, _get_Nikon_CleanSensor, _put_Nikon_CleanSensor }, { N_("Flicker Reduction"), "flickerreduction", PTP_DPC_NIKON_FlickerReduction, PTP_VENDOR_NIKON, PTP_DTC_UINT8, _get_Nikon_FlickerReduction, _put_Nikon_FlickerReduction }, { N_("Custom Functions Ex"), "customfuncex", PTP_DPC_CANON_EOS_CustomFuncEx, PTP_VENDOR_CANON, PTP_DTC_STR, _get_STR, _put_STR }, + { N_("Focus Info Ex"), "focusinfo", PTP_DPC_CANON_EOS_FocusInfoEx, PTP_VENDOR_CANON, PTP_DTC_STR, _get_STR, _put_None }, { N_("Auto Power Off"), "autopoweroff", PTP_DPC_CANON_EOS_AutoPowerOff, PTP_VENDOR_CANON, PTP_DTC_UINT16, _get_INT, _put_INT }, { N_("Depth of Field"), "depthoffield", PTP_DPC_CANON_EOS_DepthOfFieldPreview, PTP_VENDOR_CANON,PTP_DTC_UINT32, _get_INT, _put_INT }, { N_("Menus and Playback"), "menusandplayback", PTP_DPC_NIKON_MenusAndPlayback, PTP_VENDOR_NIKON, PTP_DTC_UINT8, _get_Nikon_MenusAndPlayback, _put_Nikon_MenusAndPlayback }, diff --git a/camlibs/ptp2/ptp-pack.c b/camlibs/ptp2/ptp-pack.c index f37a94a2f..0a2ecadac 100644 --- a/camlibs/ptp2/ptp-pack.c +++ b/camlibs/ptp2/ptp-pack.c @@ -1563,6 +1563,77 @@ ptp_unpack_EOS_CustomFuncEx (PTPParams* params, unsigned char** data ) return str; } +/* 32 bit size + * 16 bit subsize + * 16 bit version (?) + * 16 bit focus_points_in_struct + * 16 bit focus_points_in_use + * 16 bit sizex, 16 bit sizey + * 16 bit othersizex, 16 bit othersizey + * 16 bit array height[focus_points_in_struct] + * 16 bit array width[focus_points_in_struct] + * 16 bit array offsetheight[focus_points_in_struct] middle is 0 + * 16 bit array offsetwidth[focus_points_in_struct] middle is ? + * unknown stuff , likely which are active + * 16 bit 0xffff + * + * size=NxN,size2=NxN,points={NxNxNxN,NxNxNxN,...},selected={0,1,2} + */ +static inline char* +ptp_unpack_EOS_FocusInfoEx (PTPParams* params, unsigned char** data ) +{ + uint32_t size = dtoh32a( *data ); + uint32_t halfsize = dtoh16a( (*data) + 4); + uint32_t version = dtoh16a( (*data) + 6); + uint32_t focus_points_in_struct = dtoh16a( (*data) + 8); + uint32_t focus_points_in_use = dtoh16a( (*data) + 10); + uint32_t sizeX = dtoh16a( (*data) + 12); + uint32_t sizeY = dtoh16a( (*data) + 14); + uint32_t size2X = dtoh16a( (*data) + 16); + uint32_t size2Y = dtoh16a( (*data) + 18); + uint32_t i; + uint32_t maxlen; + char *str, *p; + + /* every focuspoint gets 4 (16 bit number and a x) and a ,*/ + /* inital things around lets say 100 chars at most. + * FIXME: check selected when we decode it */ + maxlen = focus_points_in_use*6*4 + focus_points_in_use + 100; + if (halfsize != size-4) { + ptp_error(params, "halfsize %d is not expected %d\n", halfsize, size-4); + return NULL; + } + if (focus_points_in_struct*2*4 + 32 + 8 > halfsize) { + ptp_error(params, "size %d is too small for fp in struct %d\n", focus_points_in_struct); + return NULL; + } + + str = (char*)malloc( maxlen ); + if (!str) + return str; + p = str; + + p += sprintf(p,"eosversion=%d,size=%dx%d, size2=%dx%d,points={", version, sizeX, sizeY, size2X, size2Y); + for (i=0;iCurrentValue.str = strdup( (char*)dpd->FactoryDefaultValue.str ); ptp_debug (params,"event %d: decoded custom function, currentvalue of %x is %s", i, proptype, dpd->CurrentValue.str); break; + case PTP_DPC_CANON_EOS_FocusInfoEx: + dpd->DataType = PTP_DTC_STR; + free (dpd->FactoryDefaultValue.str); + free (dpd->CurrentValue.str); + dpd->FactoryDefaultValue.str = ptp_unpack_EOS_FocusInfoEx( params, &data ); + dpd->CurrentValue.str = strdup( (char*)dpd->FactoryDefaultValue.str ); + ptp_debug (params,"event %d: decoded focus info, currentvalue of %x is %s", i, proptype, dpd->CurrentValue.str); + break; } break; diff --git a/camlibs/ptp2/ptp.c b/camlibs/ptp2/ptp.c index cbb2a7601..8670628f5 100644 --- a/camlibs/ptp2/ptp.c +++ b/camlibs/ptp2/ptp.c @@ -22,7 +22,7 @@ * Boston, MA 02110-1301 USA */ -#define _BSD_SOURCE +#define _DEFAULT_SOURCE #include "config.h" #include "ptp.h"