From 0c8d78fe49b0da81b45706b8e1cebe310eed32ac Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Tue, 28 Feb 2023 15:52:09 -0600 Subject: [PATCH] a/bindings: JSON schema for bindings --- src/xrt/auxiliary/bindings/bindings.json | 1 + .../auxiliary/bindings/bindings.schema.json | 218 ++++++++++++++++++ .../bindings/bindings.schema.json.license | 3 + 3 files changed, 222 insertions(+) create mode 100644 src/xrt/auxiliary/bindings/bindings.schema.json create mode 100644 src/xrt/auxiliary/bindings/bindings.schema.json.license diff --git a/src/xrt/auxiliary/bindings/bindings.json b/src/xrt/auxiliary/bindings/bindings.json index d85822a3e..87945d30d 100644 --- a/src/xrt/auxiliary/bindings/bindings.json +++ b/src/xrt/auxiliary/bindings/bindings.json @@ -1,4 +1,5 @@ { + "$schema": "./bindings.schema.json", "profiles": { "/interaction_profiles/khr/simple_controller": { "title": "Khronos Simple Controller", diff --git a/src/xrt/auxiliary/bindings/bindings.schema.json b/src/xrt/auxiliary/bindings/bindings.schema.json new file mode 100644 index 000000000..e4156e31b --- /dev/null +++ b/src/xrt/auxiliary/bindings/bindings.schema.json @@ -0,0 +1,218 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "definitions": { + "profileType": { + "title": "Type of device", + "type": "string", + "enum": [ + "tracked_controller", + "untracked_controller", + "tracked_hmd" + ] + }, + "subpathType": { + "title": "Type of an input/output sub-path", + "type": "string", + "enum": [ + "button", + "joystick", + "pose", + "trackpad", + "trigger", + "vibration" + ] + }, + "componentNames": { + "title": "Name of an input/output component", + "type": "string", + "enum": [ + "click", + "touch", + "position", + "value", + "haptic", + "force", + "pose" + ] + }, + "subActionPathName": { + "title": "Sub-action path", + "type": "string", + "enum": [ + "/user/hand/left", + "/user/hand/right", + "/user/head", + "/user/gamepad" + ] + }, + "steamVrControllerType": { + "title": "Controller type constant for SteamVR", + "type": "string", + "enum": [ + "gamepad", + "holographic_controller", + "khr_simple_controller", + "knuckles", + "oculus_touch", + "vive_controller", + "vive_pro" + ] + }, + "monadoDeviceName": { + "type": "string", + "pattern": "^XRT_DEVICE_([A-Z0-9_]+)$" + }, + "monadoBindingDefine": { + "type": "string", + "pattern": "^XRT_(INPUT|OUTPUT)_([A-Z0-9_]+)$" + }, + "monadoBindings": { + "title": "Components and their Monado define", + "description": "The keys/property names here must match the list of components on this path", + "type": "object", + "$comment": "Keep properties in sync with #/definitions/componentNames - not using that in propertyNames for the sake of json-editor", + "properties": { + "click": { + "$ref": "#/definitions/monadoBindingDefine" + }, + "touch": { + "$ref": "#/definitions/monadoBindingDefine" + }, + "position": { + "$ref": "#/definitions/monadoBindingDefine" + }, + "value": { + "$ref": "#/definitions/monadoBindingDefine" + }, + "haptic": { + "$ref": "#/definitions/monadoBindingDefine" + }, + "force": { + "$ref": "#/definitions/monadoBindingDefine" + }, + "pose": { + "$ref": "#/definitions/monadoBindingDefine" + } + } + }, + "dpadEmulation": { + "title": "Controlling input mapping to d-pad", + "type": "object", + "required": [ + "position", + "center" + ], + "properties": { + "position": { + "title": "The input component to associate with dpad position", + "$ref": "#/definitions/componentNames" + }, + "center": { + "title": "Provide center zone in dpad?", + "description": "True for touchpads, false for joysticks", + "type": "boolean" + }, + "activate": { + "allOf": [ + { + "title": "The input component to associate with dpad activation" + }, + { + "$ref": "#/definitions/componentNames" + } + ] + } + } + }, + "subpathData": { + "description": "Data for a single sub-path of an interaction profile", + "type": "object", + "properties": { + "type": { + "$ref": "#/definitions/subpathType" + }, + "localized_name": { + "type": "string", + "title": "Human-readable string for this input/output" + }, + "components": { + "type": "array", + "title": "Components on this path", + "items": { + "$ref": "#/definitions/componentNames" + }, + "minItems": 1 + }, + "monado_bindings": { + "$ref": "#/definitions/monadoBindings" + }, + "dpad_emulation": { + "$ref": "#/definitions/dpadEmulation" + }, + "steamvr_path": { + "title": "Path in SteamVR for this data", + "type": "string" + } + } + }, + "profileData": { + "title": "Interaction Profile Data", + "type": "object", + "required": [ + "title", + "type", + "monado_device", + "subaction_paths", + "subpaths" + ], + "properties": { + "title": { + "title": "Name of the device", + "type": "string" + }, + "type": { + "$ref": "#/definitions/profileType" + }, + "monado_device": { + "title": "Monado define corresponding to this profile", + "$ref": "#/definitions/monadoDeviceName" + }, + "extension": { + "title": "OpenXR extension required to expose this profile", + "type": "string" + }, + "steamvr_controllertype": { + "$ref": "#/definitions/steamVrControllerType" + }, + "subaction_paths": { + "title": "Subaction paths accepted for this profile", + "type": "array", + "items": { + "$ref": "#/definitions/subActionPathName" + } + }, + "subpaths": { + "type": "object", + "title": "Paths provided by this profile", + "propertyNames": { + "pattern": "^(/input/(select|menu|grip|aim|trackpad|system|squeeze|trigger|volume_up|volume_down|mute_mic|thumbrest|home|start|([a-z]+)_mndx|[1-4]|thumbstick(_left|_right)?|view|a|b|x|y|dpad_(up|down|left|right)|shoulder(_left|_right)?))|(/output/haptic(_left|_right|_left_trigger|_right_trigger)?)$" + }, + "additionalProperties": { + "$ref": "#/definitions/subpathData" + } + } + } + } + }, + "type": "object", + "properties": { + "profiles": { + "type": "object", + "patternProperties": { + "^/interaction_profiles/([a-z0-9_]+)/([a-z0-9_]+)$": { + "$ref": "#/definitions/profileData" + } + } + } + } +} diff --git a/src/xrt/auxiliary/bindings/bindings.schema.json.license b/src/xrt/auxiliary/bindings/bindings.schema.json.license new file mode 100644 index 000000000..ce02bd9ed --- /dev/null +++ b/src/xrt/auxiliary/bindings/bindings.schema.json.license @@ -0,0 +1,3 @@ +Copyright 2020-2023, Collabora, Ltd. + +SPDX-License-Identifier: BSL-1.0