aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeon Henrik Plickat <leonhenrik.plickat@stud.uni-goettingen.de>2022-02-03 11:39:20 +0100
committerIsaac Freund <mail@isaacfreund.com>2022-02-05 18:52:46 +0100
commit422cd3e01fd51564a78070a45edaa8998da3e1df (patch)
tree9a66325c8130328c281668a7c8fc6173704f5015
parent53f84b76f36a12a50b7978158408bf61833e7b8f (diff)
downloadriver-422cd3e01fd51564a78070a45edaa8998da3e1df.tar.gz
river-422cd3e01fd51564a78070a45edaa8998da3e1df.tar.xz
input: Improve input device name format
The name now includes the type, for the case of a physical device advertising more than one logical device.
-rw-r--r--doc/riverctl.1.scd2
-rw-r--r--river/InputManager.zig10
2 files changed, 9 insertions, 3 deletions
diff --git a/doc/riverctl.1.scd b/doc/riverctl.1.scd
index c1d86f1..32be2a1 100644
--- a/doc/riverctl.1.scd
+++ b/doc/riverctl.1.scd
@@ -293,6 +293,8 @@ A complete list may be found in _/usr/include/linux/input-event-codes.h_
The _input_ command can be used to create a configuration rule for an input
device identified by its _name_.
+The _name_ of an input device consists of its type, its numerical vendor id,
+its numerical product id and finally its self-advertised name, separated by -.
A list of all device properties that can be configured maybe found below.
However note that not every input device supports every property.
diff --git a/river/InputManager.zig b/river/InputManager.zig
index e08b02d..5df6448 100644
--- a/river/InputManager.zig
+++ b/river/InputManager.zig
@@ -46,11 +46,15 @@ pub const InputDevice = struct {
identifier: []const u8,
pub fn init(self: *InputDevice, device: *wlr.InputDevice) !void {
- // The identifier is formatted exactly as in Sway
const identifier = try std.fmt.allocPrint(
util.gpa,
- "{}:{}:{s}",
- .{ device.vendor, device.product, mem.trim(u8, mem.span(device.name), &ascii.spaces) },
+ "{s}-{}-{}-{s}",
+ .{
+ @tagName(device.type),
+ device.vendor,
+ device.product,
+ mem.trim(u8, mem.span(device.name), &ascii.spaces),
+ },
);
for (identifier) |*char| {
if (char.* == ' ' or !std.ascii.isPrint(char.*)) {