Skip to content

Commit

Permalink
Support the SetModeDialDisable opcode for Canon cameras (#991)
Browse files Browse the repository at this point in the history
* Add PTP_OC_CANON_SetModeDialDisable opcode

* Unlock software setting of modedial for supported canon cameras in camera_init,  re-enable the modedial in camera_exit

* Add "disablemodedial" command to camera actions  for supported canon cameras
  • Loading branch information
jensanjo authored Aug 9, 2024
1 parent 2879242 commit c58709d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
21 changes: 21 additions & 0 deletions camlibs/ptp2/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -10221,6 +10221,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 @@ -10823,6 +10843,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 @@ -3245,6 +3245,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 @@ -10097,6 +10101,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 @@ -8971,6 +8971,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 @@ -4290,6 +4291,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

0 comments on commit c58709d

Please sign in to comment.