diff -ru libgphoto2-2.4.9/camlibs/ptp2/config.c libgphoto2//camlibs/ptp2/config.c --- libgphoto2-2.4.9/camlibs/ptp2/config.c 2010-04-11 14:17:51.000000000 +0200 +++ libgphoto2//camlibs/ptp2/config.c 2010-06-17 17:05:11.989020000 +0200 @@ -510,6 +524,7 @@ static int _get_Generic16Table(CONFIG_GET_ARGS, struct deviceproptableu16* tbl, int tblsize) { int i, j; + int isset = FALSE, isset2 = FALSE; if (!(dpd->FormFlag & (PTP_DPFF_Enumeration|PTP_DPFF_Range))) { gp_log (GP_LOG_DEBUG, "ptp/get_generic16", "no enumeration/range in 16bit table code"); @@ -537,16 +552,16 @@ return GP_OK; } for (i = 0; iFORM.Enum.NumberOfValues; i++) { - int isset = FALSE; - for (j=0;jFORM.Enum.SupportedValue[i].u16) && ((tbl[j].vendor_id == 0) || (tbl[j].vendor_id == camera->pl->params.deviceinfo.VendorExtensionID)) ) { gp_widget_add_choice (*widget, _(tbl[j].label)); - if (tbl[j].value == dpd->CurrentValue.u16) + if (tbl[j].value == dpd->CurrentValue.u16) { + isset2 = TRUE; gp_widget_set_value (*widget, _(tbl[j].label)); + } isset = TRUE; break; } @@ -555,8 +570,10 @@ char buf[200]; sprintf(buf, _("Unknown value %04x"), dpd->FORM.Enum.SupportedValue[i].u16); gp_widget_add_choice (*widget, buf); - if (dpd->FORM.Enum.SupportedValue[i].u16 == dpd->CurrentValue.u16) + if (dpd->FORM.Enum.SupportedValue[i].u16 == dpd->CurrentValue.u16) { + isset2 = TRUE; gp_widget_set_value (*widget, buf); + } } } } @@ -565,16 +582,16 @@ i<=dpd->FORM.Range.MaximumValue.u16; i+= dpd->FORM.Range.StepSize.u16 ) { - int isset = FALSE; - for (j=0;jpl->params.deviceinfo.VendorExtensionID)) ) { gp_widget_add_choice (*widget, _(tbl[j].label)); - if (i == dpd->CurrentValue.u16) + if (i == dpd->CurrentValue.u16) { + isset2 = TRUE; gp_widget_set_value (*widget, _(tbl[j].label)); + } isset = TRUE; break; } @@ -583,11 +600,19 @@ char buf[200]; sprintf(buf, _("Unknown value %04d"), i); gp_widget_add_choice (*widget, buf); - if (i == dpd->CurrentValue.u16) + if (i == dpd->CurrentValue.u16) { + isset2 = TRUE; gp_widget_set_value (*widget, buf); + } } } } + if (!isset2) { + char buf[200]; + sprintf(buf, _("Unknown value %04x"), dpd->CurrentValue.u16); + gp_widget_add_choice (*widget, buf); + gp_widget_set_value (*widget, buf); + } return (GP_OK); } @@ -634,6 +659,7 @@ static int _get_GenericI16Table(CONFIG_GET_ARGS, struct deviceproptablei16* tbl, int tblsize) { int i, j; + int isset = FALSE, isset2 = FALSE; if (!(dpd->FormFlag & (PTP_DPFF_Range|PTP_DPFF_Enumeration))) { gp_log (GP_LOG_DEBUG, "ptp/get_generici16", "no enumeration/range in 16bit table code"); @@ -661,16 +687,16 @@ return GP_OK; } for (i = 0; iFORM.Enum.NumberOfValues; i++) { - int isset = FALSE; - for (j=0;jFORM.Enum.SupportedValue[i].i16) && ((tbl[j].vendor_id == 0) || (tbl[j].vendor_id == camera->pl->params.deviceinfo.VendorExtensionID)) ) { gp_widget_add_choice (*widget, _(tbl[j].label)); - if (tbl[j].value == dpd->CurrentValue.i16) + if (tbl[j].value == dpd->CurrentValue.i16) { gp_widget_set_value (*widget, _(tbl[j].label)); + isset2 = TRUE; + } isset = TRUE; break; } @@ -694,8 +720,10 @@ (tbl[j].vendor_id == camera->pl->params.deviceinfo.VendorExtensionID)) ) { gp_widget_add_choice (*widget, _(tbl[j].label)); - if (i == dpd->CurrentValue.i16) + if (i == dpd->CurrentValue.i16) { + isset2 = TRUE; gp_widget_set_value (*widget, _(tbl[j].label)); + } isset = TRUE; break; } @@ -704,11 +732,19 @@ char buf[200]; sprintf(buf, _("Unknown value %04d"), i); gp_widget_add_choice (*widget, buf); - if (i == dpd->CurrentValue.i16) + if (i == dpd->CurrentValue.i16) { + isset2 = TRUE; gp_widget_set_value (*widget, buf); + } } } } + if (!isset2) { + char buf[200]; + sprintf(buf, _("Unknown value %04x"), dpd->CurrentValue.i16); + gp_widget_add_choice (*widget, buf); + gp_widget_set_value (*widget, buf); + } return (GP_OK); } @@ -755,6 +791,7 @@ static int _get_Generic8Table(CONFIG_GET_ARGS, struct deviceproptableu8* tbl, int tblsize) { int i, j; + int isset = FALSE, isset2 = FALSE; if (dpd->FormFlag & PTP_DPFF_Enumeration) { if (dpd->DataType != PTP_DTC_UINT8) @@ -762,16 +799,16 @@ gp_widget_new (GP_WIDGET_RADIO, _(menu->label), widget); gp_widget_set_name (*widget, menu->name); for (i = 0; iFORM.Enum.NumberOfValues; i++) { - int isset = FALSE; - for (j=0;jFORM.Enum.SupportedValue[i].u8) && ((tbl[j].vendor_id == 0) || (tbl[j].vendor_id == camera->pl->params.deviceinfo.VendorExtensionID)) ) { gp_widget_add_choice (*widget, _(tbl[j].label)); - if (tbl[j].value == dpd->CurrentValue.u8) + if (tbl[j].value == dpd->CurrentValue.u8) { + isset2 = TRUE; gp_widget_set_value (*widget, _(tbl[j].label)); + } isset = TRUE; break; } @@ -784,6 +821,12 @@ gp_widget_set_value (*widget, buf); } } + if (!isset2) { + char buf[200]; + sprintf(buf, _("Unknown value %04x"), dpd->CurrentValue.u8); + gp_widget_add_choice (*widget, buf); + gp_widget_set_value (*widget, buf); + } return (GP_OK); } if (dpd->FormFlag & PTP_DPFF_Range) { @@ -795,16 +838,16 @@ i <= dpd->FORM.Range.MaximumValue.u8; i+= dpd->FORM.Range.StepSize.u8 ) { - int isset = FALSE; - for (j=0;jpl->params.deviceinfo.VendorExtensionID)) ) { gp_widget_add_choice (*widget, _(tbl[j].label)); - if (tbl[j].value == dpd->CurrentValue.u8) + if (tbl[j].value == dpd->CurrentValue.u8) { + isset2 = TRUE; gp_widget_set_value (*widget, _(tbl[j].label)); + } isset = TRUE; break; } @@ -813,10 +856,18 @@ char buf[200]; sprintf(buf, _("Unknown value %04x"), i); gp_widget_add_choice (*widget, buf); - if (i == dpd->CurrentValue.u8) + if (i == dpd->CurrentValue.u8) { + isset2 = TRUE; gp_widget_set_value (*widget, buf); + } } } + if (!isset2) { + char buf[200]; + sprintf(buf, _("Unknown value %04x"), dpd->CurrentValue.u8); + gp_widget_add_choice (*widget, buf); + gp_widget_set_value (*widget, buf); + } return (GP_OK); } return (GP_ERROR); @@ -3367,7 +3418,12 @@ return GP_ERROR; } /* Get the next set of event data */ - return _ptp_check_eos_events (params); + ret = _ptp_check_eos_events (params); + if (ret != PTP_RC_OK) { + gp_log (GP_LOG_ERROR,"ptp2/canon_eos_afdrive", "getevent failed!"); + return translate_ptp_result (ret); + } + return GP_OK; } static int @@ -3450,7 +3506,92 @@ return GP_ERROR; } /* Get the next set of event data */ - return _ptp_check_eos_events (params); + ret = _ptp_check_eos_events (params); + if (ret != PTP_RC_OK) { + gp_log (GP_LOG_ERROR,"ptp2/canon_eos_mfdrive", "getevent failed!"); + return translate_ptp_result (ret); + } + return GP_OK; +} + + +static int +_get_Canon_EOS_Zoom(CONFIG_GET_ARGS) { + gp_widget_new (GP_WIDGET_TEXT, _(menu->label), widget); + gp_widget_set_name (*widget, menu->name); + + gp_widget_set_value (*widget, "0"); + return (GP_OK); +} + +/* Only 1 and 5 seem to work on the EOS 1000D */ +static int +_put_Canon_EOS_Zoom(CONFIG_PUT_ARGS) { + uint16_t ret; + const char* val; + unsigned int xval; + PTPParams *params = &(camera->pl->params); + + if (!ptp_operation_issupported(params, PTP_OC_CANON_EOS_Zoom)) + return (GP_ERROR_NOT_SUPPORTED); + + gp_widget_get_value(widget, &val); + if (!sscanf (val, "%d", &xval)) { + gp_log (GP_LOG_DEBUG, "ptp2/canon_eos_zoom", "Could not parse %s", val); + return GP_ERROR; + } + ret = ptp_canon_eos_zoom (params, xval); + if (ret != PTP_RC_OK) { + gp_log (GP_LOG_DEBUG, "ptp2/canon_eos_zoom", "Canon zoom 0x%x failed: 0x%x", xval, ret); + return GP_ERROR; + } + /* Get the next set of event data */ + ret = _ptp_check_eos_events (params); + if (ret != PTP_RC_OK) { + gp_log (GP_LOG_ERROR,"ptp2/canon_eos_zoom", "getevent failed!"); + return translate_ptp_result (ret); + } + return GP_OK; +} + +/* EOS Zoom. Works in approx 64 pixel steps on the EOS 1000D, but just accept + * all kind of pairs */ +static int +_get_Canon_EOS_ZoomPosition(CONFIG_GET_ARGS) { + gp_widget_new (GP_WIDGET_TEXT, _(menu->label), widget); + gp_widget_set_name (*widget, menu->name); + + gp_widget_set_value (*widget, "0,0"); + return (GP_OK); +} + +static int +_put_Canon_EOS_ZoomPosition(CONFIG_PUT_ARGS) { + uint16_t ret; + const char* val; + unsigned int x,y; + PTPParams *params = &(camera->pl->params); + + if (!ptp_operation_issupported(params, PTP_OC_CANON_EOS_ZoomPosition)) + return (GP_ERROR_NOT_SUPPORTED); + + gp_widget_get_value(widget, &val); + if (2!=sscanf (val, "%d,%d", &x,&y)) { + gp_log (GP_LOG_DEBUG, "ptp2/canon_eos_zoomposition", "Could not parse %s (expected 'x,y')", val); + return GP_ERROR; + } + ret = ptp_canon_eos_zoomposition (params, x,y); + if (ret != PTP_RC_OK) { + gp_log (GP_LOG_DEBUG, "ptp2/canon_eos_zoomposition", "Canon zoom position %d,%d failed: 0x%x", x, y, ret); + return GP_ERROR; + } + /* Get the next set of event data */ + ret = _ptp_check_eos_events (params); + if (ret != PTP_RC_OK) { + gp_log (GP_LOG_ERROR,"ptp2/canon_eos_zoomposition", "getevent failed!"); + return translate_ptp_result (ret); + } + return GP_OK; } @@ -4241,6 +4382,8 @@ { N_("Drive Canon DSLR Autofocus"), "autofocusdrive", 0, PTP_VENDOR_CANON, PTP_OC_CANON_EOS_DoAf, _get_Canon_EOS_AFDrive, _put_Canon_EOS_AFDrive }, { N_("Drive Nikon DSLR Manual focus"), "manualfocusdrive", 0, PTP_VENDOR_NIKON, PTP_OC_NIKON_MfDrive, _get_Nikon_MFDrive, _put_Nikon_MFDrive }, { N_("Drive Canon DSLR Manual focus"), "manualfocusdrive", 0, PTP_VENDOR_CANON, PTP_OC_CANON_EOS_DriveLens, _get_Canon_EOS_MFDrive, _put_Canon_EOS_MFDrive }, + { N_("Canon EOS Zoom "), "eoszoom", 0, PTP_VENDOR_CANON, PTP_OC_CANON_EOS_Zoom, _get_Canon_EOS_Zoom, _put_Canon_EOS_Zoom}, + { N_("Canon EOS Zoom Position"), "eoszoomposition", 0, PTP_VENDOR_CANON, PTP_OC_CANON_EOS_ZoomPosition, _get_Canon_EOS_ZoomPosition, _put_Canon_EOS_ZoomPosition}, { 0,0,0,0,0,0,0 }, }; diff -ru libgphoto2-2.4.9/camlibs/ptp2/library.c libgphoto2//camlibs/ptp2/library.c --- libgphoto2-2.4.9/camlibs/ptp2/library.c 2010-04-11 14:13:03.000000000 +0200 +++ libgphoto2//camlibs/ptp2/library.c 2010-06-17 17:05:11.958020000 +0200 @@ -2031,7 +2031,8 @@ /* delete last / or we get confused later. */ path->folder[ strlen(path->folder)-1 ] = '\0'; gp_filesystem_append (camera->fs, path->folder, path->name, context); - continue; /* for RAW+JPG mode capture, we just return the last image for now. */ + break;/* for RAW+JPG mode capture, we just return the first image for now, and + * let wait_for_event get the rest. */ } if (newobject) break; @@ -2466,6 +2467,8 @@ init_ptp_fs (camera, context); + *eventtype = GP_EVENT_TIMEOUT; + *eventdata = NULL; gettimeofday (&event_start,NULL); if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) && ptp_operation_issupported(params, PTP_OC_CANON_EOS_RemoteRelease) @@ -2474,7 +2477,6 @@ if (!params->eos_captureenabled) camera_prepare_capture (camera, context); - *eventtype = GP_EVENT_TIMEOUT; while (1) { PTPCanon_changes_entry entry; @@ -2589,10 +2591,8 @@ int isevent; while (1) { - if (_timeout_passed(&event_start, timeout)) { - *eventtype = GP_EVENT_TIMEOUT; + if (_timeout_passed(&event_start, timeout)) break; - } gp_context_idle (context); ret = ptp_canon_checkevent (params,&event,&isevent); if (ret!=PTP_RC_OK) @@ -2609,7 +2609,6 @@ ) { uint32_t newobject, hasc101; - *eventtype = GP_EVENT_TIMEOUT; while (1) { int evtcnt; PTPContainer *nevent = NULL; diff -ru libgphoto2-2.4.9/camlibs/ptp2/usb.c libgphoto2//camlibs/ptp2/usb.c --- libgphoto2-2.4.9/camlibs/ptp2/usb.c 2009-12-15 09:28:43.000000000 +0100 +++ libgphoto2//camlibs/ptp2/usb.c 2010-06-17 17:05:12.019025000 +0200 @@ -506,6 +506,7 @@ gp_port_get_timeout (camera->port, &timeout); gp_port_set_timeout (camera->port, PTP2_FAST_TIMEOUT); result = gp_port_check_int (camera->port, (char*)&usbevent, sizeof(usbevent)); + if (result <= 0) result = gp_port_check_int (camera->port, (char*)&usbevent, sizeof(usbevent)); gp_port_set_timeout (camera->port, timeout); break; default: diff -ru libgphoto2-2.4.9/libgphoto2/gphoto2-camera.c libgphoto2//libgphoto2/gphoto2-camera.c --- libgphoto2-2.4.9/libgphoto2/gphoto2-camera.c 2010-04-11 14:30:03.000000000 +0200 +++ libgphoto2//libgphoto2/gphoto2-camera.c 2010-06-17 17:05:13.489925000 +0200 @@ -1035,8 +1035,6 @@ CHECK_INIT (camera, context); if (!camera->functions->wait_for_event) { - gp_context_error (context, _("This camera does " - "not support event handling.")); CAMERA_UNUSED (camera, context); return (GP_ERROR_NOT_SUPPORTED); }