From 549d6a1fa923e5b10475b6c61e69a3319cfb3e3f Mon Sep 17 00:00:00 2001 From: William Edwards Date: Tue, 26 Mar 2024 13:11:15 -0700 Subject: [PATCH] feat(DeviceProfile): add device profile schema --- .../share/inputplumber/profiles/default.yaml | 141 ++++++++---- .../schema/device_profile_v1.json | 216 ++++++++++++++++++ .../schema/virtual_device_profile_v1.json | 86 ------- 3 files changed, 318 insertions(+), 125 deletions(-) create mode 100644 rootfs/usr/share/inputplumber/schema/device_profile_v1.json delete mode 100644 rootfs/usr/share/inputplumber/schema/virtual_device_profile_v1.json diff --git a/rootfs/usr/share/inputplumber/profiles/default.yaml b/rootfs/usr/share/inputplumber/profiles/default.yaml index 1d75cd7..d4a1f70 100644 --- a/rootfs/usr/share/inputplumber/profiles/default.yaml +++ b/rootfs/usr/share/inputplumber/profiles/default.yaml @@ -1,50 +1,113 @@ -# yaml-language-server: $schema=../schema/virtual_device_profile_v1.json +# yaml-language-server: $schema=../schema/device_profile_v1.json # Schema version number version: 1 # The type of configuration schema -kind: VirtualDeviceProfile +kind: DeviceProfile # Name of the device profile name: Default -# Type of gamepad to emulate. -# "auto" will copy the name/vendor from the source devices -# Options: ["auto", "xb360", "ps3", "ps4", "ps5", "switchpro"] -gamepad_type: "ps5" - # Profile mappings mapping: + # Button to button - name: Guide Button - output_behavior: sequence - source_event: - code: mode - output_events: - - code: mode - - - name: Quick Menu Button - output_behavior: sequence - source_event: - type: EV_KEY - code: BTN_BASE - kind: evdev - output_events: - - code: open_quick_menu - kind: dbus - - - name: Keyboard Button - output_behavior: sequence - source_event: - type: EV_KEY - code: KEY_KEYBOARD - kind: evdev - output_events: - - code: open_keyboard - kind: dbus - - - name: West Button - output_behavior: sequence - source_event: - code: west_button - output_events: - - code: north_button + source_event: + keyboard: KeyRightCtrl + target_events: + - gamepad: + button: Guide + + # Button to axis direction + - name: A to axis + source_event: + keyboard: KeyA + target_events: + - gamepad: + axis: + name: Hat1 + direction: left + + # Axis direction to button + - name: A + source_event: + gamepad: + axis: + name: LeftStick + direction: left + deadzone: 0.3 # defaults to 0.3 + target_events: + - keyboard: KeyA + + # Axis to mouse + - name: Joystick Mouse + source_event: + gamepad: + axis: + name: RightStick + target_events: + - mouse: + motion: continuous + + # Gyro to mouse + - name: Gyro Mouse + source_event: + gamepad: + gyro: + name: Gyro1 + target_events: + - mouse: + motion: continuous + + # Gyro to axis + - name: Gyro Stick + source_event: + gamepad: + gyro: + name: Gyro1 + target_events: + - gamepad: + axis: + name: RightStick + + # Gyro to key press + - name: Gyro Key + source_event: + gamepad: + gyro: + name: Gyro1 + axis: yaw + direction: positive + deadzone: 0.3 + target_events: + - keyboard: KeyW + + # Key to input chord + - name: Steam QuickAccess Chord + source_event: + gamepad: + button: QuickAccess + target_events: + - gamepad: + button: Guide + - gamepad: + button: South + + # Key to DBus event + - name: DBus QuickAccess + source_event: + gamepad: + button: QuickAccess + target_events: + - dbus: Quick + + # Trigger to button + - name: Trigger to button + source_event: + gamepad: + trigger: + name: LeftTrigger + deadzone: 0.4 + target_events: + - gamepad: + button: South diff --git a/rootfs/usr/share/inputplumber/schema/device_profile_v1.json b/rootfs/usr/share/inputplumber/schema/device_profile_v1.json new file mode 100644 index 0000000..f7ec367 --- /dev/null +++ b/rootfs/usr/share/inputplumber/schema/device_profile_v1.json @@ -0,0 +1,216 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$ref": "#/definitions/DeviceProfile", + "definitions": { + "DeviceProfile": { + "title": "DeviceProfile", + "type": "object", + "additionalProperties": false, + "properties": { + "version": { + "type": "integer" + }, + "kind": { + "type": "string" + }, + "name": { + "type": "string" + }, + "mapping": { + "type": "array", + "items": { + "$ref": "#/definitions/Mapping" + } + } + }, + "required": [ + "kind", + "mapping", + "name", + "version" + ] + }, + "Mapping": { + "title": "Mapping", + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "source_event": { + "$ref": "#/definitions/Event" + }, + "target_events": { + "type": "array", + "items": { + "$ref": "#/definitions/Event" + } + } + }, + "required": [ + "name", + "source_event", + "target_events" + ] + }, + "Event": { + "title": "Event", + "type": "object", + "additionalProperties": false, + "properties": { + "keyboard": { + "type": "string" + }, + "mouse": { + "$ref": "#/definitions/MouseEvent" + }, + "dbus": { + "type": "string" + }, + "gamepad": { + "$ref": "#/definitions/GamepadEvent" + } + }, + "required": [] + }, + "MouseEvent": { + "title": "MouseEvent", + "type": "object", + "additionalProperties": false, + "properties": { + "motion": { + "type": "string", + "enum": [ + "continuous" + ] + }, + "button": { + "type": "string" + } + }, + "required": [] + }, + "GamepadEvent": { + "title": "GamepadEvent", + "type": "object", + "additionalProperties": false, + "properties": { + "axis": { + "$ref": "#/definitions/AxisEvent" + }, + "gyro": { + "$ref": "#/definitions/GyroEvent" + }, + "trigger": { + "$ref": "#/definitions/TriggerEvent" + }, + "button": { + "type": "string" + } + }, + "required": [] + }, + "GyroEvent": { + "title": "GyroEvent", + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "enum": [ + "Gyro1", + "Gyro2", + "Gyro3" + ] + }, + "direction": { + "type": "string", + "enum": [ + "positive", + "negative" + ] + }, + "deadzone": { + "type": "number", + "default": 0.3, + "description": "Optional deadzone from 0.0 - 1.0. When this deadzone threshold is crossed, this input is considered 'pressed'." + }, + "axis": { + "type": "string", + "description": "Pitch, roll, or yaw", + "enum": [ + "pitch", + "roll", + "yaw" + ] + } + }, + "required": [ + "name" + ] + }, + "TriggerEvent": { + "title": "TriggerEvent", + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "enum": [ + "LeftTrigger", + "LeftTouchpadForce", + "LeftStickForce", + "RightTrigger", + "RightTouchpadForce", + "RightStickForce" + ] + }, + "deadzone": { + "type": "number", + "default": 0.3, + "description": "Optional deadzone from 0.0 - 1.0. When this deadzone threshold is crossed, this input is considered 'pressed'." + } + }, + "required": [ + "name" + ] + }, + "AxisEvent": { + "title": "AxisEvent", + "type": "object", + "description": "Axis events such as LeftStick, RightStick, etc.", + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "enum": [ + "LeftStick", + "RightStick", + "Hat1", + "Hat2", + "Hat3" + ] + }, + "direction": { + "type": "string", + "description": "Optional direction of the axis. Used when converting axis events into button events.", + "enum": [ + "left", + "right", + "up", + "down" + ] + }, + "deadzone": { + "type": "number", + "default": 0.3, + "description": "Optional deadzone from 0.0 - 1.0. When this deadzone threshold is crossed, this input is considered 'pressed'." + } + }, + "required": [ + "name" + ] + } + } +} diff --git a/rootfs/usr/share/inputplumber/schema/virtual_device_profile_v1.json b/rootfs/usr/share/inputplumber/schema/virtual_device_profile_v1.json deleted file mode 100644 index fbf020e..0000000 --- a/rootfs/usr/share/inputplumber/schema/virtual_device_profile_v1.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-06/schema#", - "$ref": "#/definitions/VirtualDeviceProfile", - "definitions": { - "VirtualDeviceProfile": { - "type": "object", - "additionalProperties": false, - "properties": { - "version": { - "type": "integer" - }, - "kind": { - "type": "string" - }, - "name": { - "type": "string" - }, - "gamepad_type": { - "type": "string" - }, - "mapping": { - "type": "array", - "items": { - "$ref": "#/definitions/Mapping" - } - } - }, - "required": [ - "gamepad_type", - "kind", - "mapping", - "name", - "version" - ], - "title": "VirtualDeviceProfile" - }, - "Mapping": { - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "output_behavior": { - "type": "string" - }, - "source_event": { - "$ref": "#/definitions/Event" - }, - "output_events": { - "type": "array", - "items": { - "$ref": "#/definitions/Event" - } - } - }, - "required": [ - "name", - "output_behavior", - "output_events", - "source_event" - ], - "title": "Mapping" - }, - "Event": { - "type": "object", - "additionalProperties": false, - "properties": { - "type": { - "type": "string" - }, - "code": { - "type": "string" - }, - "kind": { - "type": "string" - } - }, - "required": [ - "code", - "kind" - ], - "title": "Event" - } - } -}