From 295835aad3c0c9867edf8dd47d6a2d8811585dc3 Mon Sep 17 00:00:00 2001 From: Baku Hashimoto Date: Wed, 12 Jun 2024 13:07:16 +0900 Subject: [PATCH] Add Tethr.getConfigName methods --- src/Tethr.ts | 160 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 151 insertions(+), 9 deletions(-) diff --git a/src/Tethr.ts b/src/Tethr.ts index 1f45223..e7ee1e1 100644 --- a/src/Tethr.ts +++ b/src/Tethr.ts @@ -72,6 +72,12 @@ type ConfigSetters = { ) => Promise } +type ConfigGetters = { + [N in ConfigName as `get${Capitalize}`]: () => Promise< + ConfigType[N] | null + > +} + type ConfigDescGetters = { [N in ConfigName as `get${Capitalize}Desc`]: () => Promise< ConfigDesc @@ -96,7 +102,7 @@ export function readonlyConfigDesc(value: T): ConfigDesc { export abstract class Tethr extends EventEmitter - implements ConfigSetters, ConfigDescGetters + implements ConfigSetters, ConfigGetters, ConfigDescGetters { constructor() { super() @@ -200,6 +206,9 @@ export abstract class Tethr async setAperture(value: Aperture): Promise { return UnsupportedOperationResult } + async getAperture() { + return (await this.getApertureDesc()).value + } async getApertureDesc(): Promise> { return UnsupportedConfigDesc } @@ -208,6 +217,9 @@ export abstract class Tethr async setAutoFocusFrameCenter(value: vec2): Promise { return UnsupportedOperationResult } + async getAutoFocusFrameCenter() { + return (await this.getAutoFocusFrameCenterDesc()).value + } async getAutoFocusFrameCenterDesc(): Promise> { return UnsupportedConfigDesc } @@ -216,6 +228,9 @@ export abstract class Tethr async setAutoFocusFrameSize(value: string): Promise { return UnsupportedOperationResult } + async getAutoFocusFrameSize() { + return (await this.getAutoFocusFrameSizeDesc()).value + } async getAutoFocusFrameSizeDesc(): Promise> { return UnsupportedConfigDesc } @@ -224,6 +239,9 @@ export abstract class Tethr async setBatteryLevel(value: BatteryLevel): Promise { return UnsupportedOperationResult } + async getBatteryLevel() { + return (await this.getBatteryLevelDesc()).value + } async getBatteryLevelDesc(): Promise> { return UnsupportedConfigDesc } @@ -232,6 +250,9 @@ export abstract class Tethr async setBurstInterval(value: number): Promise { return UnsupportedOperationResult } + async getBurstInterval() { + return (await this.getBurstIntervalDesc()).value + } async getBurstIntervalDesc(): Promise> { return UnsupportedConfigDesc } @@ -240,6 +261,9 @@ export abstract class Tethr async setBurstNumber(value: number): Promise { return UnsupportedOperationResult } + async getBurstNumber() { + return (await this.getBurstNumberDesc()).value + } async getBurstNumberDesc(): Promise> { return UnsupportedConfigDesc } @@ -248,6 +272,9 @@ export abstract class Tethr async setCanRunAutoFocus(value: boolean): Promise { return UnsupportedOperationResult } + async getCanRunAutoFocus() { + return (await this.getCanRunAutoFocusDesc()).value + } async getCanRunAutoFocusDesc(): Promise> { return UnsupportedConfigDesc } @@ -256,6 +283,9 @@ export abstract class Tethr async setCanRunManualFocus(value: boolean): Promise { return UnsupportedOperationResult } + async getCanRunManualFocus() { + return (await this.getCanRunManualFocusDesc()).value + } async getCanRunManualFocusDesc(): Promise> { return UnsupportedConfigDesc } @@ -264,6 +294,9 @@ export abstract class Tethr async setCanStartLiveview(value: boolean): Promise { return UnsupportedOperationResult } + async getCanStartLiveview() { + return (await this.getCanStartLiveviewDesc()).value + } async getCanStartLiveviewDesc(): Promise> { return UnsupportedConfigDesc } @@ -272,6 +305,9 @@ export abstract class Tethr async setCanTakePhoto(value: boolean): Promise { return UnsupportedOperationResult } + async getCanTakePhoto() { + return (await this.getCanTakePhotoDesc()).value + } async getCanTakePhotoDesc(): Promise> { return UnsupportedConfigDesc } @@ -280,6 +316,9 @@ export abstract class Tethr async setCaptureDelay(value: number): Promise { return UnsupportedOperationResult } + async getCaptureDelay() { + return (await this.getCaptureDelayDesc()).value + } async getCaptureDelayDesc(): Promise> { return UnsupportedConfigDesc } @@ -288,6 +327,9 @@ export abstract class Tethr async setColorMode(value: string): Promise { return UnsupportedOperationResult } + async getColorMode() { + return (await this.getColorModeDesc()).value + } async getColorModeDesc(): Promise> { return UnsupportedConfigDesc } @@ -296,6 +338,9 @@ export abstract class Tethr async setColorTemperature(value: number): Promise { return UnsupportedOperationResult } + async getColorTemperature() { + return (await this.getColorTemperatureDesc()).value + } async getColorTemperatureDesc(): Promise> { return UnsupportedConfigDesc } @@ -304,6 +349,9 @@ export abstract class Tethr async setCompressionSetting(value: number): Promise { return UnsupportedOperationResult } + async getCompressionSetting() { + return (await this.getCompressionSettingDesc()).value + } async getCompressionSettingDesc(): Promise> { return UnsupportedConfigDesc } @@ -312,6 +360,9 @@ export abstract class Tethr async setContrast(value: number): Promise { return UnsupportedOperationResult } + async getContrast() { + return (await this.getContrastDesc()).value + } async getContrastDesc(): Promise> { return UnsupportedConfigDesc } @@ -320,6 +371,9 @@ export abstract class Tethr async setDateTime(value: Date): Promise { return UnsupportedOperationResult } + async getDateTime() { + return (await this.getDateTimeDesc()).value + } async getDateTimeDesc(): Promise> { return UnsupportedConfigDesc } @@ -328,6 +382,9 @@ export abstract class Tethr async setDestinationToSave(value: string): Promise { return UnsupportedOperationResult } + async getDestinationToSave() { + return (await this.getDestinationToSaveDesc()).value + } async getDestinationToSaveDesc(): Promise> { return UnsupportedConfigDesc } @@ -336,6 +393,9 @@ export abstract class Tethr async setDigitalZoom(value: number): Promise { return UnsupportedOperationResult } + async getDigitalZoom() { + return (await this.getDigitalZoomDesc()).value + } async getDigitalZoomDesc(): Promise> { return UnsupportedConfigDesc } @@ -344,6 +404,9 @@ export abstract class Tethr async setDriveMode(value: DriveMode): Promise { return UnsupportedOperationResult } + async getDriveMode() { + return (await this.getDriveModeDesc()).value + } async getDriveModeDesc(): Promise> { return UnsupportedConfigDesc } @@ -352,6 +415,9 @@ export abstract class Tethr async setExposureComp(value: string): Promise { return UnsupportedOperationResult } + async getExposureComp() { + return (await this.getExposureCompDesc()).value + } async getExposureCompDesc(): Promise> { return UnsupportedConfigDesc } @@ -360,6 +426,9 @@ export abstract class Tethr async setExposureMeteringMode(value: string): Promise { return UnsupportedOperationResult } + async getExposureMeteringMode() { + return (await this.getExposureMeteringModeDesc()).value + } async getExposureMeteringModeDesc(): Promise< ConfigDesc > { @@ -370,6 +439,9 @@ export abstract class Tethr async setExposureMode(value: ExposureMode): Promise { return UnsupportedOperationResult } + async getExposureMode() { + return (await this.getExposureModeDesc()).value + } async getExposureModeDesc(): Promise> { return UnsupportedConfigDesc } @@ -378,6 +450,9 @@ export abstract class Tethr async setFacingMode(value: string): Promise { return UnsupportedOperationResult } + async getFacingMode() { + return (await this.getFacingModeDesc()).value + } async getFacingModeDesc(): Promise> { return UnsupportedConfigDesc } @@ -386,6 +461,9 @@ export abstract class Tethr async setFlashMode(value: FlashMode): Promise { return UnsupportedOperationResult } + async getFlashMode() { + return (await this.getFlashModeDesc()).value + } async getFlashModeDesc(): Promise> { return UnsupportedConfigDesc } @@ -394,13 +472,20 @@ export abstract class Tethr async setFocalLength(value: FocalLength): Promise { return UnsupportedOperationResult } + async getFocalLength() { + return (await this.getFocalLengthDesc()).value + } async getFocalLengthDesc(): Promise> { return UnsupportedConfigDesc } + // eslint-disable-next-line @typescript-eslint/no-unused-vars async setFocusDistance(value: number): Promise { return UnsupportedOperationResult } + async getFocusDistance() { + return (await this.getFocusDistanceDesc()).value + } async getFocusDistanceDesc(): Promise> { return UnsupportedConfigDesc } @@ -411,6 +496,9 @@ export abstract class Tethr ): Promise { return UnsupportedOperationResult } + async getFocusMeteringMode() { + return (await this.getFocusMeteringModeDesc()).value + } async getFocusMeteringModeDesc(): Promise> { return UnsupportedConfigDesc } @@ -419,28 +507,31 @@ export abstract class Tethr async setFocusMode(value: FocusMode): Promise { return UnsupportedOperationResult } + async getFocusMode() { + return (await this.getFocusModeDesc()).value + } async getFocusModeDesc(): Promise> { - return { - writable: false, - value: null, - } + return UnsupportedConfigDesc } // eslint-disable-next-line @typescript-eslint/no-unused-vars async setFocusPeaking(value: FocusPeaking): Promise { return UnsupportedOperationResult } + async getFocusPeaking() { + return (await this.getFocusPeakingDesc()).value + } async getFocusPeakingDesc(): Promise> { - return { - writable: false, - value: null, - } + return UnsupportedConfigDesc } // eslint-disable-next-line @typescript-eslint/no-unused-vars async setFunctionalMode(value: FunctionalMode): Promise { return UnsupportedOperationResult } + async getFunctionalMode() { + return (await this.getFunctionalModeDesc()).value + } async getFunctionalModeDesc(): Promise> { return UnsupportedConfigDesc } @@ -449,6 +540,9 @@ export abstract class Tethr async setImageAspect(value: string): Promise { return UnsupportedOperationResult } + async getImageAspect() { + return (await this.getImageAspectDesc()).value + } async getImageAspectDesc(): Promise> { return UnsupportedConfigDesc } @@ -457,6 +551,9 @@ export abstract class Tethr async setImageQuality(value: string): Promise { return UnsupportedOperationResult } + async getImageQuality() { + return (await this.getImageQualityDesc()).value + } async getImageQualityDesc(): Promise> { return UnsupportedConfigDesc } @@ -465,6 +562,9 @@ export abstract class Tethr async setImageSize(value: string): Promise { return UnsupportedOperationResult } + async getImageSize() { + return (await this.getImageSizeDesc()).value + } async getImageSizeDesc(): Promise> { return UnsupportedConfigDesc } @@ -473,6 +573,9 @@ export abstract class Tethr async setIso(value: ISO): Promise { return UnsupportedOperationResult } + async getIso() { + return (await this.getIsoDesc()).value + } async getIsoDesc(): Promise> { return UnsupportedConfigDesc } @@ -481,6 +584,9 @@ export abstract class Tethr async setLiveviewEnabled(value: boolean): Promise { return UnsupportedOperationResult } + async getLiveviewEnabled() { + return (await this.getLiveviewEnabledDesc()).value + } async getLiveviewEnabledDesc(): Promise> { return UnsupportedConfigDesc } @@ -489,6 +595,9 @@ export abstract class Tethr async setLiveviewMagnifyRatio(value: number): Promise { return UnsupportedOperationResult } + async getLiveviewMagnifyRatio() { + return (await this.getLiveviewMagnifyRatioDesc()).value + } async getLiveviewMagnifyRatioDesc(): Promise> { return UnsupportedConfigDesc } @@ -497,6 +606,9 @@ export abstract class Tethr async setLiveviewSize(value: string): Promise { return UnsupportedOperationResult } + async getLiveviewSize() { + return (await this.getLiveviewSizeDesc()).value + } async getLiveviewSizeDesc(): Promise> { return UnsupportedConfigDesc } @@ -507,6 +619,9 @@ export abstract class Tethr ): Promise { return UnsupportedOperationResult } + async getManualFocusOptions() { + return (await this.getManualFocusOptionsDesc()).value + } async getManualFocusOptionsDesc(): Promise> { return UnsupportedConfigDesc } @@ -515,6 +630,9 @@ export abstract class Tethr async setManufacturer(value: string): Promise { return UnsupportedOperationResult } + async getManufacturer() { + return (await this.getManufacturerDesc()).value + } async getManufacturerDesc(): Promise> { return UnsupportedConfigDesc } @@ -523,6 +641,9 @@ export abstract class Tethr async setModel(value: string): Promise { return UnsupportedOperationResult } + async getModel() { + return (await this.getModelDesc()).value + } async getModelDesc(): Promise> { return UnsupportedConfigDesc } @@ -531,6 +652,9 @@ export abstract class Tethr async setSerialNumber(value: string): Promise { return UnsupportedOperationResult } + async getSerialNumber() { + return (await this.getSerialNumberDesc()).value + } async getSerialNumberDesc(): Promise> { return UnsupportedConfigDesc } @@ -539,6 +663,9 @@ export abstract class Tethr async setSharpness(value: number): Promise { return UnsupportedOperationResult } + async getSharpness() { + return (await this.getSharpnessDesc()).value + } async getSharpnessDesc(): Promise> { return UnsupportedConfigDesc } @@ -547,6 +674,9 @@ export abstract class Tethr async setShutterSpeed(value: string): Promise { return UnsupportedOperationResult } + async getShutterSpeed() { + return (await this.getShutterSpeedDesc()).value + } async getShutterSpeedDesc(): Promise> { return UnsupportedConfigDesc } @@ -555,6 +685,9 @@ export abstract class Tethr async setShutterSound(value: number): Promise { return UnsupportedOperationResult } + async getShutterSound() { + return (await this.getShutterSoundDesc()).value + } async getShutterSoundDesc(): Promise> { return UnsupportedConfigDesc } @@ -563,6 +696,9 @@ export abstract class Tethr async setTimelapseInterval(value: number): Promise { return UnsupportedOperationResult } + async getTimelapseInterval() { + return (await this.getTimelapseIntervalDesc()).value + } async getTimelapseIntervalDesc(): Promise> { return UnsupportedConfigDesc } @@ -571,6 +707,9 @@ export abstract class Tethr async setTimelapseNumber(value: number): Promise { return UnsupportedOperationResult } + async getTimelapseNumber() { + return (await this.getTimelapseNumberDesc()).value + } async getTimelapseNumberDesc(): Promise> { return UnsupportedConfigDesc } @@ -579,6 +718,9 @@ export abstract class Tethr async setWhiteBalance(value: WhiteBalance): Promise { return UnsupportedOperationResult } + async getWhiteBalance() { + return (await this.getWhiteBalanceDesc()).value + } async getWhiteBalanceDesc(): Promise> { return UnsupportedConfigDesc }