Skip to content

Commit

Permalink
feat(DeviceProfile): add device profile schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowApex committed Mar 31, 2024
1 parent c0c0c6b commit 549d6a1
Show file tree
Hide file tree
Showing 3 changed files with 318 additions and 125 deletions.
141 changes: 102 additions & 39 deletions rootfs/usr/share/inputplumber/profiles/default.yaml
Original file line number Diff line number Diff line change
@@ -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
216 changes: 216 additions & 0 deletions rootfs/usr/share/inputplumber/schema/device_profile_v1.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}
Loading

0 comments on commit 549d6a1

Please sign in to comment.