import { Processor } from '../util/runProcessors'; import EventEmitter from '../util/EventEmitter'; import { Device } from '../Device'; type InputControlEvents = { change: unknown; }; export interface InputControlOptions> { name?: string; parent?: InputControl; enabled?: boolean; device?: DeviceType; processors?: Processor[]; children?: Map | [string, InputControl][] | { [k: string]: InputControl; }; /** * callback function to check control's state and determine * whether it's currently "active". * * By default, a control is active if the magnitude of the current * value is greater than zero. */ active?: (ic: InputControl) => boolean; } /** * Base class from which all controls are derived. */ export default class InputControl> extends EventEmitter { static defaultValue: any; name: string; parent: InputControl; enabled: boolean; children: Map>>; device: DeviceType; processors: Processor[]; /** * InputControl constructor * @param readRaw (optional) callback function to read unprocessed value. overrides read method * @param options options object */ constructor(readRaw?: (() => T), options?: InputControlOptions); /** * InputControl constructor * @param options options object */ constructor(options?: InputControlOptions); /** * Find a descendent control * @param path slash ('/') delimited list of keys to follow through descendent controls * @returns a descendent control. null it not found */ find(path?: string): InputControl | null; /** * @returns The control's current value */ read(): T; /** * Determines the magnitude of the given value * * @param val (optional) defaults to control's current value * @returns the magnitude of the given value */ magnitude(val?: T): number; active(): boolean; } export {};