Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions rootfs/usr/share/inputplumber/capability_maps/gpd_hid_type1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/ShadowBlip/InputPlumber/main/rootfs/usr/share/inputplumber/schema/capability_map_v2.json
# Schema version number
version: 2

# The type of configuration schema
kind: CapabilityMap

# Name for the device event map
name: GPD HID Type 1

id: gpd_hid_type1

# GPD Win 5 vendor HID report (VID 0x2f24, PID 0x0137, Usage Page 0xFF00)
# Idle: 01 a5 00 5a ff 00 01 09 00 00 00 00
# BUF[8] = 0x68 mode switch, 0x00 released
# BUF[9] = 0x69 left back, 0x00 released
# BUF[10] = 0x6a right back, 0x00 released
mapping:
- name: Mode Switch
source_events:
- hidraw:
value_type: bool
byte_start: 8
target_event:
gamepad:
button: QuickAccess

- name: Left Back
source_events:
- hidraw:
value_type: bool
byte_start: 9
target_event:
gamepad:
button: LeftPaddle1

- name: Right Back
source_events:
- hidraw:
value_type: bool
byte_start: 10
target_event:
gamepad:
button: RightPaddle1
6 changes: 6 additions & 0 deletions rootfs/usr/share/inputplumber/devices/50-gpd_win5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ source_devices:
name: " Keyboard for Windows"
handler: event*
phys_path: usb-0000:66:00.0-5.3/input0
- group: keyboard
hidraw:
vendor_id: 0x2f24
product_id: 0x0137
interface_num: 0
capability_map_id: gpd_hid_type1
- group: keyboard
evdev:
name: AT Translated Set 2 keyboard
Expand Down
172 changes: 161 additions & 11 deletions rootfs/usr/share/inputplumber/schema/capability_map_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,21 @@
"name"
]
},
"Endianness": {
"description": "Endianness is the order in which a multi-byte number is represented.",
"oneOf": [
{
"description": "Least significant byte ordering",
"type": "string",
"const": "lsb"
},
{
"description": "Most significant byte ordering",
"type": "string",
"const": "msb"
}
]
},
"EvdevConfig": {
"description": "An [EvdevConfig] defines a matching evdev input event",
"type": "object",
Expand Down Expand Up @@ -1191,30 +1206,66 @@
"type": "object",
"properties": {
"bit_offset": {
"type": "integer",
"description": "Optional bit offset to start reading from",
"type": [
"integer",
"null"
],
"format": "uint8",
"maximum": 255,
"minimum": 0
},
"byte_start": {
"description": "The byte where the data begins",
"type": "integer",
"format": "uint64",
"format": "uint",
"minimum": 0
},
"input_type": {
"type": "string"
"endian": {
"description": "Optional endianness of the value being decoded. Defaults to LSB.",
"anyOf": [
{
"$ref": "#/$defs/Endianness"
},
{
"type": "null"
}
]
},
"max_value": {
"description": "Optional maximum value used for normalizing the value. InputPlumber\ntypically normalizes input values from 0.0 - 1.0 or from -1.0 - 1.0.",
"type": [
"integer",
"null"
],
"format": "int64"
},
"min_value": {
"description": "Optional minimum value used for normalizing the value. InputPlumber\ntypically normalizes input values from 0.0 - 1.0 or from -1.0 - 1.0.",
"type": [
"integer",
"null"
],
"format": "int64"
},
"report_id": {
"type": "integer",
"format": "uint32",
"description": "Optional report ID of the input report. This is typically the first byte\nof the input report.",
"type": [
"integer",
"null"
],
"format": "uint8",
"maximum": 255,
"minimum": 0
},
"value_type": {
"description": "Data type of the input. This is used to decode the value of the input\nreport.",
"$ref": "#/$defs/ValueType2"
}
},
"required": [
"report_id",
"input_type",
"byte_start",
"bit_offset"
"value_type",
"byte_start"
]
},
"MappingType": {
Expand Down Expand Up @@ -1444,6 +1495,105 @@
"imu_y",
"imu_z"
]
},
"ValueType2": {
"oneOf": [
{
"description": "Bool values take up 1 bit in the input report",
"type": "string",
"const": "bool"
},
{
"description": "Uint8 values take up 1 byte in the input report",
"type": "string",
"const": "uint8"
},
{
"description": "Uint16 values take up 2 bytes in the input report",
"type": "string",
"const": "uint16"
},
{
"description": "Uint32 values take up 4 bytes in the input report",
"type": "string",
"const": "uint32"
},
{
"description": "Int8 values take up 1 byte in the input report",
"type": "string",
"const": "int8"
},
{
"description": "Int16 values take up 2 bytes in the input report",
"type": "string",
"const": "int16"
},
{
"description": "Int32 values take up 4 bytes in the input report",
"type": "string",
"const": "int32"
},
{
"description": "UInt8Vector2 values take up 2 bytes in the input report",
"type": "string",
"const": "vector2_uint8"
},
{
"description": "UInt16Vector2 values take up 4 bytes in the input report",
"type": "string",
"const": "vector2_uint16"
},
{
"description": "UInt32Vector2 values take up 8 bytes in the input report",
"type": "string",
"const": "vector2_uint32"
},
{
"description": "Int8Vector2 values take up 2 bytes in the input report",
"type": "string",
"const": "vector2_int8"
},
{
"description": "Int16Vector2 values take up 4 bytes in the input report",
"type": "string",
"const": "vector2_int16"
},
{
"description": "Int32Vector2 values take up 8 bytes in the input report",
"type": "string",
"const": "vector2_int32"
},
{
"description": "UInt8Vector3 values take up 3 bytes in the input report",
"type": "string",
"const": "vector3_uint8"
},
{
"description": "UInt16Vector3 values take up 6 bytes in the input report",
"type": "string",
"const": "vector3_uint16"
},
{
"description": "UInt32Vector3 values take up 12 bytes in the input report",
"type": "string",
"const": "vector3_uint32"
},
{
"description": "Int8Vector3 values take up 3 bytes in the input report",
"type": "string",
"const": "vector3_int8"
},
{
"description": "Int16Vector3 values take up 6 bytes in the input report",
"type": "string",
"const": "vector3_int16"
},
{
"description": "Int32Vector3 values take up 12 bytes in the input report",
"type": "string",
"const": "vector3_int32"
}
]
}
}
}
}
103 changes: 99 additions & 4 deletions src/config/capability_map/hidraw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,103 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Clone, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
pub struct HidrawConfig {
pub report_id: u32,
pub input_type: String,
pub byte_start: u64,
pub bit_offset: u8,
/// Optional report ID of the input report. This is typically the first byte
/// of the input report.
#[serde(skip_serializing_if = "Option::is_none")]
pub report_id: Option<u8>,
/// Data type of the input. This is used to decode the value of the input
/// report.
pub value_type: ValueType,
/// The byte where the data begins
pub byte_start: usize,
/// Optional maximum value used for normalizing the value. InputPlumber
/// typically normalizes input values from 0.0 - 1.0 or from -1.0 - 1.0.
#[serde(skip_serializing_if = "Option::is_none")]
pub max_value: Option<i64>,
/// Optional minimum value used for normalizing the value. InputPlumber
/// typically normalizes input values from 0.0 - 1.0 or from -1.0 - 1.0.
#[serde(skip_serializing_if = "Option::is_none")]
pub min_value: Option<i64>,
/// Optional bit offset to start reading from
#[serde(skip_serializing_if = "Option::is_none")]
pub bit_offset: Option<u8>,
/// Optional endianness of the value being decoded. Defaults to LSB.
#[serde(skip_serializing_if = "Option::is_none")]
pub endian: Option<Endianness>,
}

/// Endianness is the order in which a multi-byte number is represented.
#[derive(Default, Debug, Deserialize, Serialize, Clone, JsonSchema, PartialEq)]
pub enum Endianness {
/// Least significant byte ordering
#[default]
#[serde(rename = "lsb")]
Lsb,
/// Most significant byte ordering
#[serde(rename = "msb")]
Msb,
}

#[derive(Debug, Deserialize, Serialize, Clone, JsonSchema, PartialEq)]
pub enum ValueType {
/// Bool values take up 1 bit in the input report
#[serde(rename = "bool")]
Bool,

/// Uint8 values take up 1 byte in the input report
#[serde(rename = "uint8")]
UInt8,
/// Uint16 values take up 2 bytes in the input report
#[serde(rename = "uint16")]
UInt16,
/// Uint32 values take up 4 bytes in the input report
#[serde(rename = "uint32")]
UInt32,
/// Int8 values take up 1 byte in the input report
#[serde(rename = "int8")]
Int8,
/// Int16 values take up 2 bytes in the input report
#[serde(rename = "int16")]
Int16,
/// Int32 values take up 4 bytes in the input report
#[serde(rename = "int32")]
Int32,

/// UInt8Vector2 values take up 2 bytes in the input report
#[serde(rename = "vector2_uint8")]
UInt8Vector2,
/// UInt16Vector2 values take up 4 bytes in the input report
#[serde(rename = "vector2_uint16")]
UInt16Vector2,
/// UInt32Vector2 values take up 8 bytes in the input report
#[serde(rename = "vector2_uint32")]
UInt32Vector2,
/// Int8Vector2 values take up 2 bytes in the input report
#[serde(rename = "vector2_int8")]
Int8Vector2,
/// Int16Vector2 values take up 4 bytes in the input report
#[serde(rename = "vector2_int16")]
Int16Vector2,
/// Int32Vector2 values take up 8 bytes in the input report
#[serde(rename = "vector2_int32")]
Int32Vector2,

/// UInt8Vector3 values take up 3 bytes in the input report
#[serde(rename = "vector3_uint8")]
UInt8Vector3,
/// UInt16Vector3 values take up 6 bytes in the input report
#[serde(rename = "vector3_uint16")]
UInt16Vector3,
/// UInt32Vector3 values take up 12 bytes in the input report
#[serde(rename = "vector3_uint32")]
UInt32Vector3,
/// Int8Vector3 values take up 3 bytes in the input report
#[serde(rename = "vector3_int8")]
Int8Vector3,
/// Int16Vector3 values take up 6 bytes in the input report
#[serde(rename = "vector3_int16")]
Int16Vector3,
/// Int32Vector3 values take up 12 bytes in the input report
#[serde(rename = "vector3_int32")]
Int32Vector3,
}
3 changes: 3 additions & 0 deletions src/input/event/hidraw.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod translator;
#[cfg(test)]
pub mod translator_test;
Loading
Loading