feat: Implement support for gesture-based PTZ control (#2378)
- Closes: #1839
This commit is contained in:
@@ -633,7 +633,9 @@ const ptzControlSettingsTransform = (data: unknown): unknown => {
|
||||
'hide_pan_tilt',
|
||||
'hide_zoom',
|
||||
'hide_home',
|
||||
'hide_type',
|
||||
'style',
|
||||
'type',
|
||||
];
|
||||
|
||||
const keys = Object.keys(data);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { z } from 'zod';
|
||||
import { PTZ_CONTROL_TYPES } from '../../common/controls/ptz';
|
||||
import { advancedCameraCardCustomActionsBaseSchema } from './base';
|
||||
|
||||
export const ptzControlsActionConfigSchema =
|
||||
advancedCameraCardCustomActionsBaseSchema.extend({
|
||||
advanced_camera_card_action: z.literal('ptz_controls'),
|
||||
enabled: z.boolean(),
|
||||
enabled: z.boolean().optional(),
|
||||
type: z.enum(PTZ_CONTROL_TYPES).optional(),
|
||||
});
|
||||
export type PTZControlsActionConfig = z.infer<typeof ptzControlsActionConfigSchema>;
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
import { z } from 'zod';
|
||||
import { advancedCameraCardCustomActionsBaseSchema } from './base';
|
||||
|
||||
export const PTZ_PAN_TILT_ACTIONS = ['up', 'right', 'down', 'left'] as const;
|
||||
const PTZ_PAN_ACTIONS = ['left', 'right'] as const;
|
||||
export type PTZPanAction = (typeof PTZ_PAN_ACTIONS)[number];
|
||||
|
||||
const PTZ_TILT_ACTIONS = ['up', 'down'] as const;
|
||||
export type PTZTiltAction = (typeof PTZ_TILT_ACTIONS)[number];
|
||||
|
||||
const PTZ_PAN_TILT_ACTIONS = [...PTZ_PAN_ACTIONS, ...PTZ_TILT_ACTIONS] as const;
|
||||
export type PTZPanTiltAction = (typeof PTZ_PAN_TILT_ACTIONS)[number];
|
||||
|
||||
const PTZ_ZOOM_ACTIONS = ['zoom_in', 'zoom_out'] as const;
|
||||
export type PTZZoomAction = (typeof PTZ_ZOOM_ACTIONS)[number];
|
||||
const PTZ_BASE_ACTIONS = [...PTZ_PAN_TILT_ACTIONS, ...PTZ_ZOOM_ACTIONS] as const;
|
||||
export type PTZBaseAction = (typeof PTZ_BASE_ACTIONS)[number];
|
||||
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const PTZ_CONTROL_TYPES = ['buttons', 'gestures'] as const;
|
||||
export type PTZControlType = (typeof PTZ_CONTROL_TYPES)[number];
|
||||
|
||||
export const ptzControlsDefaults = {
|
||||
orientation: 'horizontal' as const,
|
||||
mode: 'auto' as const,
|
||||
hide_pan_tilt: false,
|
||||
hide_zoom: false,
|
||||
hide_home: false,
|
||||
hide_type: false,
|
||||
position: 'bottom-right' as const,
|
||||
type: 'buttons' as const,
|
||||
};
|
||||
|
||||
export const ptzControlsConfigSchema = z.object({
|
||||
@@ -21,6 +26,9 @@ export const ptzControlsConfigSchema = z.object({
|
||||
hide_pan_tilt: z.boolean().default(ptzControlsDefaults.hide_pan_tilt),
|
||||
hide_zoom: z.boolean().default(ptzControlsDefaults.hide_zoom),
|
||||
hide_home: z.boolean().default(ptzControlsDefaults.hide_home),
|
||||
hide_type: z.boolean().default(ptzControlsDefaults.hide_type),
|
||||
|
||||
type: z.enum(PTZ_CONTROL_TYPES).default(ptzControlsDefaults.type),
|
||||
|
||||
style: z.looseObject({}).optional(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user