Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the SetModeDialDisable opcode for Canon cameras #991

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions camlibs/ptp2/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -10216,6 +10216,26 @@ _put_CHDK(CONFIG_PUT_ARGS) {
return GP_OK;
}

static int
_get_Canon_SetModeDialDisable(CONFIG_GET_ARGS) {
gp_widget_new (GP_WIDGET_TOGGLE, _(menu->label), widget);
gp_widget_set_name (*widget,menu->name);
int val = 0;
gp_widget_set_value (*widget, &val);
return GP_OK;
}

static int
_put_Canon_SetModeDialDisable(CONFIG_PUT_ARGS) {
PTPParams *params = &(camera->pl->params);
int val;
if (!ptp_operation_issupported(params, PTP_OC_CANON_SetModeDialDisable))
return (GP_ERROR_NOT_SUPPORTED);
CR (gp_widget_get_value(widget, &val));
C_PTP (ptp_canon_setmodedialdisable(params, val));
return GP_OK;
}

static struct {
char *name;
char *label;
Expand Down Expand Up @@ -10818,6 +10838,7 @@ static struct submenu camera_actions_menu[] = {
{ N_("Remote Key Down"), "remotekeydown", PTP_DPC_SONY_RemoteKeyDown, PTP_VENDOR_SONY, PTP_DTC_UINT16, _get_Sony_FocusMagnifyProp, _put_Sony_FocusMagnifyProp },
{ N_("Remote Key Left"), "remotekeyleft", PTP_DPC_SONY_RemoteKeyLeft, PTP_VENDOR_SONY, PTP_DTC_UINT16, _get_Sony_FocusMagnifyProp, _put_Sony_FocusMagnifyProp },
{ N_("Remote Key Right"), "remotekeyright",PTP_DPC_SONY_RemoteKeyRight, PTP_VENDOR_SONY, PTP_DTC_UINT16, _get_Sony_FocusMagnifyProp,_put_Sony_FocusMagnifyProp },
{ N_("Canon Disable Mode Dial"), "disablemodedial", 0, PTP_VENDOR_CANON, PTP_OC_CANON_SetModeDialDisable, _get_Canon_SetModeDialDisable, _put_Canon_SetModeDialDisable },
{ N_("PTP Opcode"), "opcode", 0, 0, PTP_OC_GetDeviceInfo, _get_Generic_OPCode, _put_Generic_OPCode },
{ 0,0,0,0,0,0,0 },
};
Expand Down
8 changes: 8 additions & 0 deletions camlibs/ptp2/library.c
Original file line number Diff line number Diff line change
Expand Up @@ -3241,6 +3241,10 @@ camera_exit (Camera *camera, GPContext *context)
if (ptp_operation_issupported(params, PTP_OC_CANON_EOS_SetRemoteMode)) {
C_PTP (ptp_canon_eos_setremotemode(params, 1));
}
/* re-enable the mode dial (it may fail with PTP general error 0x2002 )*/
if (ptp_operation_issupported(params, PTP_OC_CANON_SetModeDialDisable)) {
ptp_canon_setmodedialdisable(params, 0);
}
break;
case PTP_VENDOR_NIKON:
if (ptp_operation_issupported(params, PTP_OC_NIKON_EndLiveView))
Expand Down Expand Up @@ -10083,6 +10087,10 @@ camera_init (Camera *camera, GPContext *context)
C_PTP (ptp_canon_eos_setremotemode(params, 1));
}
}
/* enable software setting of the mode dial (ignore potential error) */
if (ptp_operation_issupported(params, PTP_OC_CANON_SetModeDialDisable)) {
ptp_canon_setmodedialdisable(params, 1);
}
break;
case PTP_VENDOR_NIKON:
if (ptp_operation_issupported(params, PTP_OC_NIKON_CurveDownload))
Expand Down
1 change: 1 addition & 0 deletions camlibs/ptp2/ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -8963,6 +8963,7 @@ ptp_opcode_trans_t ptp_opcode_canon_trans[] = {
{PTP_OC_CANON_EOS_NotifySaveComplete,"EOS_NotifySaveComplete"},
{PTP_OC_CANON_EOS_GetObjectURL,"EOS_GetObjectURL"},
{PTP_OC_CANON_SetRemoteShootingMode,"SetRemoteShootingMode"},
{PTP_OC_CANON_SetModeDialDisable,"SetModeDialDisable"},
{PTP_OC_CANON_EOS_SetFELock,"EOS_SetFELock"},
{PTP_OC_CANON_DeleteWebServiceData,"DeleteWebServiceData"},
{PTP_OC_CANON_GetGpsMobilelinkObjectInfo,"GetGpsMobilelinkObjectInfo"},
Expand Down
11 changes: 11 additions & 0 deletions camlibs/ptp2/ptp.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ typedef struct _PTPIPHeader PTPIPHeader;
#define PTP_OC_CANON_RequestTranscodeCancel 0x9079 /* 1 arg: oid? */

#define PTP_OC_CANON_SetRemoteShootingMode 0x9086
#define PTP_OC_CANON_SetModeDialDisable 0x9088

/* 9101: no args, 8 byte data (01 00 00 00 00 00 00 00), no resp data. */
#define PTP_OC_CANON_EOS_GetStorageIDs 0x9101
Expand Down Expand Up @@ -4280,6 +4281,16 @@ uint16_t ptp_canon_checkevent (PTPParams* params,
*
**/
#define ptp_canon_initiatecaptureinmemory(params) ptp_generic_no_data(params,PTP_OC_CANON_InitiateCaptureInMemory,0)
/**
* ptp_canon_setmodedialdisable:
*
* This operation allows software setting of the mode dial. THe software setting is disabled by default.
* The operation has one parameter, with the value 0 or 1.
* Parameter 0 disables the software setting of the mode dial, 1 allows software setting of the mode dial.
* When software setting is allowed the physical mode dial is disabled. This situation remains until the camera is
* powered off, or the camera is disconnected.
*/
#define ptp_canon_setmodedialdisable(params, onoff) ptp_generic_no_data(params,PTP_OC_CANON_SetModeDialDisable,1, onoff)
/**
* ptp_canon_eos_requestdevicepropvalue:
*
Expand Down
Loading