Skip to content

Commit

Permalink
feat(Touchscreen): add support for generic touchscreen devices
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowApex committed Feb 5, 2025
1 parent 7e2cc6d commit 7a6a1ee
Show file tree
Hide file tree
Showing 15 changed files with 825 additions and 29 deletions.
11 changes: 11 additions & 0 deletions rootfs/usr/share/inputplumber/devices/50-ayaneo_2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ source_devices:
x: [0, -1, 0]
y: [-1, 0, 0]
z: [0, 0, -1]
#- group: touchscreen
# udev:
# properties:
# - name: ID_INPUT_TOUCHSCREEN
# value: "1"
# sys_name: "event*"
# subsystem: input
# config:
# touchscreen:
# orientation: "right"

# Optional configuration for the composite device
options:
Expand All @@ -60,6 +70,7 @@ target_devices:
- xbox-elite
- mouse
- keyboard
#- touchscreen

# The ID of a device event mapping in the 'event_maps' folder
capability_map_id: aya4
11 changes: 11 additions & 0 deletions rootfs/usr/share/inputplumber/devices/50-ayaneo_2s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ source_devices:
x: [0, -1, 0]
y: [-1, 0, 0]
z: [0, 0, -1]
#- group: touchscreen
# udev:
# properties:
# - name: ID_INPUT_TOUCHSCREEN
# value: "1"
# sys_name: "event*"
# subsystem: input
# config:
# touchscreen:
# orientation: "right"

# Optional configuration for the composite device
options:
Expand All @@ -60,6 +70,7 @@ target_devices:
- xbox-elite
- mouse
- keyboard
#- touchscreen

# The ID of a device event mapping in the 'event_maps' folder
capability_map_id: aya4
19 changes: 19 additions & 0 deletions rootfs/usr/share/inputplumber/devices/50-ayaneo_flip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ source_devices:
x: [0, -1, 0]
y: [-1, 0, 0]
z: [0, 0, -1]
- group: touchscreen
udev:
properties:
- name: ID_INPUT_TOUCHSCREEN
value: "1"
attributes:
- name: id/vendor
value: "0416"
- name: id/product
value: "1001"
sys_name: "event*"
subsystem: input
config:
touchscreen:
orientation: "left"
override_source_size: true
width: 1920
height: 1080

# Optional configuration for the composite device
options:
Expand All @@ -60,6 +78,7 @@ target_devices:
- xbox-elite
- mouse
- keyboard
- touchscreen

# The ID of a device event mapping in the 'event_maps' folder
capability_map_id: aya4
13 changes: 13 additions & 0 deletions rootfs/usr/share/inputplumber/devices/50-legion_go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ source_devices:
y: [-1, 0, 0]
z: [0, 0, -1]

# Touchscreen
#- group: touchscreen
# udev:
# properties:
# - name: ID_INPUT_TOUCHSCREEN
# value: "1"
# sys_name: "event*"
# subsystem: input
# config:
# touchscreen:
# orientation: "left"

# Block all evdev devices; mouse, touchpad, gamepad, keyboard
- group: gamepad
blocked: true
Expand All @@ -160,3 +172,4 @@ target_devices:
- mouse
- keyboard
- touchpad
#- touchscreen
10 changes: 10 additions & 0 deletions rootfs/usr/share/inputplumber/devices/50-msi_claw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ source_devices:
y: [-1, 0, 0]
z: [0, 0, -1]

# Touchscreen
#- group: touchscreen
# udev:
# properties:
# - name: ID_INPUT_TOUCHSCREEN
# value: "1"
# sys_name: "event*"
# subsystem: input

# Optional configuration for the composite device
options:
# If true, InputPlumber will automatically try to manage the input device. If
Expand All @@ -65,6 +74,7 @@ target_devices:
- xbox-elite
- mouse
- keyboard
#- touchscreen

# The ID of a device event mapping in the 'event_maps' folder
capability_map_id: claw1
8 changes: 8 additions & 0 deletions rootfs/usr/share/inputplumber/devices/50-rog_ally.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ source_devices:
x: [1, 0, 0]
y: [0, -1, 0]
z: [0, 0, -1]
#- group: touchscreen
# udev:
# properties:
# - name: ID_INPUT_TOUCHSCREEN
# value: "1"
# sys_name: "event*"
# subsystem: input

# Optional configuration for the composite device
options:
Expand All @@ -66,6 +73,7 @@ target_devices:
- xbox-elite
- mouse
- keyboard
#- touchscreen

# The ID of a device event mapping in the 'event_maps' folder
capability_map_id: aly1
8 changes: 8 additions & 0 deletions rootfs/usr/share/inputplumber/devices/50-rog_ally_x.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ source_devices:
x: [1, 0, 0]
y: [0, -1, 0]
z: [0, 0, -1]
#- group: touchscreen
# udev:
# properties:
# - name: ID_INPUT_TOUCHSCREEN
# value: "1"
# sys_name: "event*"
# subsystem: input

# Optional configuration for the composite device
options:
Expand All @@ -65,6 +72,7 @@ target_devices:
- xbox-elite
- mouse
- keyboard
#- touchscreen

# The ID of a device event mapping in the 'event_maps' folder
capability_map_id: aly1
19 changes: 10 additions & 9 deletions rootfs/usr/share/inputplumber/devices/50-steam_deck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ source_devices:
product_id: 0x1205
interface_num: 2
# Touchscreen
- group: mouse
hidraw:
vendor_id: 0x2808
product_id: 0x1015
- group: mouse
- group: touchscreen
unique: false
blocked: true
evdev:
name: "FTS3528:00 2808:1015*"
handler: event*
udev:
properties:
- name: ID_INPUT_TOUCHSCREEN
value: "1"
sys_name: "event*"
subsystem: input
config:
touchscreen:
orientation: "right"
# Keyboard
- group: keyboard
evdev:
Expand Down
53 changes: 53 additions & 0 deletions rootfs/usr/share/inputplumber/schema/composite_device_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
"keyboard",
"mouse",
"gamepad",
"touchscreen",
"imu"
]
},
Expand All @@ -186,6 +187,9 @@
"iio": {
"$ref": "#/definitions/IIO"
},
"config": {
"$ref": "#/definitions/SourceDeviceConfig"
},
"unique": {
"description": "If false, any devices matching this description will be added to the existing composite device. Defaults to true.",
"type": "boolean"
Expand All @@ -196,6 +200,55 @@
],
"title": "SourceDevice"
},
"SourceDeviceConfig": {
"type": "object",
"additionalProperties": false,
"properties": {
"touchscreen": {
"$ref": "#/definitions/TouchscreenConfig"
},
"imu": {
"$ref": "#/definitions/ImuConfig"
}
}
},
"TouchscreenConfig": {
"type": "object",
"additionalProperties": false,
"properties": {
"orientation": {
"description": "Orientation of the touchscreen device. Defaults to normal.",
"type": "string",
"enum": [
"normal",
"left",
"right",
"upsidedown"
]
},
"width": {
"description": "Width of the touchscreen in pixels. If set, any virtual touchscreens will use this width instead of querying the source device for its size.",
"type": "integer"
},
"height": {
"description": "Height of the touchscreen in pixels. If set, any virtual touchscreens will use this height instead of querying the source device for its size.",
"type": "integer"
},
"override_source_size": {
"description": "If true, the source device will use the width/height defined in this configuration instead of the size advertised by the device itself. Defaults to false.",
"type": "boolean"
}
}
},
"ImuConfig": {
"type": "object",
"additionalProperties": false,
"properties": {
"mount_matrix": {
"$ref": "#/definitions/MountMatrix"
}
}
},
"Udev": {
"description": "Source device to manage. Properties support globbing patterns.",
"type": "object",
Expand Down
34 changes: 34 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,41 @@ pub struct SourceDevice {
pub hidraw: Option<Hidraw>,
pub iio: Option<IIO>,
pub udev: Option<Udev>,
pub config: Option<SourceDeviceConfig>,
pub unique: Option<bool>,
pub blocked: Option<bool>,
pub ignore: Option<bool>,
}

#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "snake_case")]
pub struct SourceDeviceConfig {
pub touchscreen: Option<TouchscreenConfig>,
pub imu: Option<ImuConfig>,
}

#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "snake_case")]
pub struct TouchscreenConfig {
/// Orientation of the touchscreen. Can be one of: ["normal", "left", "right", "upsidedown"]
pub orientation: Option<String>,
/// Width of the touchscreen. If set, any virtual touchscreens will use this width
/// instead of querying the source device for its size.
pub width: Option<u32>,
/// Height of the touchscreen. If set, any virtual touchscreens will use this height
/// instead of querying the source device for its size.
pub height: Option<u32>,
/// If true, the source device will use the width/height defined in this configuration
/// instead of the size advertised by the device itself.
pub override_source_size: Option<bool>,
}

#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "snake_case")]
pub struct ImuConfig {
pub mount_matrix: Option<MountMatrix>,
}

#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "snake_case")]
pub struct Evdev {
Expand Down Expand Up @@ -359,6 +389,10 @@ pub struct UdevAttribute {
pub struct IIO {
pub id: Option<String>,
pub name: Option<String>,
#[deprecated(
since = "0.43.0",
note = "please use `<SourceDevice>.config.imu.mount_matrix` instead"
)]
pub mount_matrix: Option<MountMatrix>,
}

Expand Down
5 changes: 4 additions & 1 deletion src/input/composite_device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,11 +1454,14 @@ impl CompositeDevice {

let source_device = match subsystem.as_str() {
"input" => {
// Get any defined config for the event device
let config = self.config.get_matching_device(&device);

log::debug!("Adding source device: {:?}", device.name());
if is_blocked {
is_blocked_evdev = true;
}
let device = EventDevice::new(device, self.client(), is_blocked)?;
let device = EventDevice::new(device, self.client(), config, is_blocked)?;
SourceDevice::Event(device)
}
"hidraw" => {
Expand Down
Loading

0 comments on commit 7a6a1ee

Please sign in to comment.