Skip to main content
TypesCapability types

The types that say what the connected camera is and can do now: what getCapabilities() returns, what setControl takes, and which model was identified. This is one of the 5 pages of the types reference, which names every type. A field ending in ? may be absent: Slate leaves out what a camera does not report, and never guesses it.

import type { CameraCapabilities, CameraControlState } from '@darkgrade/slate'

Capabilities and controls

What getCapabilities() returns and setControl takes.

CameraRecordingState

What getRecordingState resolves to. unknown never counts as idle.

type CameraRecordingState =
    | 'idle'
    | 'recording'
    | 'starting'
    | 'stopping'
    | 'unknown'

OperationAvailability

One operation's availability now: an unsupported one says why, in words a user can act on. options covers optional parts of an operation, such as a live-view overlay.

interface OperationAvailability {
    supported: boolean
    reason?: string
    options?: Partial<Record<string, OperationAvailability>>
}
Show OperationAvailability fields
supportedboolean

Whether the operation can run now.

reason?string

Why not, when it cannot.

options?Partial<Record<string, OperationAvailability>>

The same for the operation's optional parts, by name.

CameraCapabilities

What getCapabilities resolves to: every setting, the lens, and which operations work now.

interface CameraCapabilities {
    observedAt: number
    controls: Partial<Record<CameraControlId, CameraControlState>>
    advertisedOperations: number[] | null
    lens?: CameraLens
    operations?: Partial<
        Record<CameraOperationName, OperationAvailability>
    >
}
Show CameraCapabilities fields
observedAtnumber

When the camera was read, in milliseconds since the Unix epoch (Date.now()).

controlsPartial<Record<CameraControlId, CameraControlState>>

Every setting the camera has now, by id. It is what the camera reports at this moment, not a promise for the model: a mode, lens or card change can add or remove one.

See CameraControlId, CameraControlState.

advertisedOperationsnumber[] | null

The PTP operation codes the camera lists in its DeviceInfo, or null when it gives none. A listed code does not prove the operation works: operations says what does.

lens?CameraLens

The attached lens, from the same observation as controls; absent when the camera reports neither field.

See CameraLens.

operations?Partial<Record<CameraOperationName, OperationAvailability>>

Whether each public operation is possible right now, with the reason when it is not. Camera fills this from its driver's capability groups; an operation absent here has no availability report yet, and a call still answers CameraUnsupportedError when it cannot run.

See OperationAvailability.

CameraControlId

A setting id, such as iso or shutterSpeed. The settings reference lists every one.

type CameraControlId = keyof typeof cameraControlDefinitions

Every value (33)

shutterSpeed aperture iso exposureMode exposureCompensation meteringMode photoVideoMode driveMode whiteBalance colorTemperature pictureStyle pictureProfile focusMode focusArea subjectDetection continuousAutofocus imageStabilization audioLevel shutterType detectionSubject eyeSelection photoFormat photoSize aspectRatio jpegQuality rawCompression flashMode videoFormat videoQuality frameRate audioRecording digitalZoom liveViewQuality

CameraControlInputs

What setControl accepts as a value, by setting id: an ExposureTimeInput for shutterSpeed, a number for colorTemperature and audioLevel, and a string for every other setting.

type CameraControlInputs = {
    [Id in CameraControlId]: Id extends 'shutterSpeed'
        ? ExposureTimeInput
        : Id extends NumericControlId
        ? number
        : string
}

Uses CameraControlId.

CameraControlState

One setting as the camera reports it now: its value, the values it offers, and whether it can be written.

interface CameraControlState {
    id: CameraControlId
    label: string
    aliases: readonly string[]
    source: {
        name: string
        code: number
        protocol: 'ptp' | 'sony-sdk'
    }
    value?: string
    allowedValues?: string[]
    writable: boolean
    enabled: boolean
    range?: {
        minimum: number
        maximum: number
        step: number
    }
    exposureTime?: ExposureTime
    unrecognized?: UnrecognizedValues
}
Show CameraControlState fields
idCameraControlId

The setting's id.

See CameraControlId.

labelstring

Its name for a person, such as Shutter speed.

aliasesreadonly string[]

Other words for it, for search.

source{ name: string; code: number; protocol: 'ptp' | 'sony-sdk' }

The protocol property behind this setting on the connected camera, kept for diagnostics. Write by id, never by this.

value?string

The current value in Slate's spelling. Absent when the control does not apply now (enabled: false, no choices, the raw reading in unrecognized.value): colour temperature under a white balance preset, Sony drive mode in movie mode.

allowedValues?string[]

The values the camera offers now, in Slate's spelling. Only these can be written.

writableboolean

Whether the camera accepts a write to it now.

enabledboolean

Whether it applies in the camera's current mode.

range?{ minimum: number; maximum: number; step: number }

For a numeric setting: the lowest and highest value and the step between them.

exposureTime?ExposureTime

Shutter speed only: the value as a duration or an angle.

See ExposureTime.

unrecognized?UnrecognizedValues

Raw values the camera reported that Slate has no name for.

See UnrecognizedValues.

CameraControlSession

The same control contract on an already-connected native PTP or vendor SDK session, including one typed getter and setter per typed setting (getShutterSpeed, setShutterSpeed, ...).

interface CameraControlSession extends TypedSettingMethods {
    getCapabilities: () => Promise<CameraCapabilities>
    setControl: <Id extends CameraControlId>(
        id: Id,
        value: CameraControlInputs[Id],
        context?: ExposureContext,
    ) => Promise<CameraControlState>
}
Show CameraControlSession fields
getCapabilities() => Promise<CameraCapabilities>
setControl<Id extends CameraControlId>(id: Id, value: CameraContro…

Extends TypedSettingMethods.

UnrecognizedValues

Raw values the camera reported that Slate has no name for. They are shown and never written.

interface UnrecognizedValues {
    value?: string
    choices?: string[]
}
Show UnrecognizedValues fields
value?string

The current raw value. The control is then read-only and its value reads Unrecognized (<raw>), or, when it does not apply now, has no value at all.

choices?string[]

Advertised choices left out of allowedValues; they are never writable.

CameraLens

The attached lens as the camera reports it. Each field is null when the camera does not report it.

interface CameraLens {
    name: string | null
    focalLengthMillimetres: number | null
}
Show CameraLens fields
namestring | null

The lens's name.

focalLengthMillimetresnumber | null

The current focal length, in millimetres.

Identification

Which model a camera is, and whether Slate has validated it.

VerifiedFeature

A vendor feature confirmed on specific bodies on Darkgrade's benches, for isVerifiedFeature.

type VerifiedFeature = keyof typeof verifiedFeatureModels

Every value (3)

sony-wireless sony-card-fallback nikon-wireless-status

CameraIdentification

What identifyCamera makes of a USB vendor and product ID, without opening the device. Recognising an ID proves no control.

interface CameraIdentification {
    usb: { vendorId: number; productId: number }
  status: 'unknown'
    | 'matched'
    | 'ambiguous'
    | 'identity-mismatch'
    candidates: CameraIdentityCandidate[]
}
Show CameraIdentification fields
usb{ vendorId: number; productId: number }

The USB vendor and product ID that were asked about.

status'unknown' | 'matched' | 'ambiguous' | 'identity-mismatch'

matched: one camera line is known for the ID. ambiguous: several share it. identity-mismatch: a model was given and none of them names it. unknown: the ID is not in Slate's list.

candidatesCameraIdentityCandidate[]

The camera lines known for the ID; when a model was given and matched, only those that name it.

See CameraIdentityCandidate.

CameraIdentityCandidate

A camera line and model aliases that a cited source associates with one USB vendor/product ID.

interface CameraIdentityCandidate {
    manufacturer: string
    line: string
    models: string[]
    sources: string[]
}
Show CameraIdentityCandidate fields
manufacturerstring

The make.

linestring

The camera line, as the source names it.

modelsstring[]

The model names and aliases of the line.

sourcesstring[]

The sources that associate the line with the USB ID.

Other types

⌘I