aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <mail@isaacfreund.com>2022-06-20 19:51:34 +0200
committerIsaac Freund <mail@isaacfreund.com>2022-06-20 19:51:34 +0200
commit67d07e84b01191a5c48d3f2e797a831e75895ce2 (patch)
treee323ae916fd020ed775925e43eff0216df1776e9
parentc40dc5ee75d46f461b4b5cb96169cf492ac255b1 (diff)
downloadriver-67d07e84b01191a5c48d3f2e797a831e75895ce2.tar.gz
river-67d07e84b01191a5c48d3f2e797a831e75895ce2.tar.xz
InputDevice: use "switch" in input device names
Currently we use "switch_device" because that's what the enum variant happens to be named in zig-wlroots so that it doesn't conflict with the switch keyword. This however wasn't really thought through and "switch" makes more sense to expose to the user.
-rw-r--r--river/InputDevice.zig9
1 files changed, 7 insertions, 2 deletions
diff --git a/river/InputDevice.zig b/river/InputDevice.zig
index 5781a14..413e8f8 100644
--- a/river/InputDevice.zig
+++ b/river/InputDevice.zig
@@ -36,18 +36,23 @@ destroy: wl.Listener(*wlr.InputDevice) = wl.Listener(*wlr.InputDevice).init(hand
identifier: []const u8,
pub fn init(self: *InputDevice, device: *wlr.InputDevice) !void {
+ const device_type: []const u8 = switch (device.type) {
+ .switch_device => "switch",
+ else => @tagName(device.type),
+ };
+
const identifier = try std.fmt.allocPrint(
util.gpa,
"{s}-{}-{}-{s}",
.{
- @tagName(device.type),
+ device_type,
device.vendor,
device.product,
mem.trim(u8, mem.span(device.name), &ascii.spaces),
},
);
for (identifier) |*char| {
- if (char.* == ' ' or !ascii.isPrint(char.*)) {
+ if (!ascii.isGraph(char.*)) {
char.* = '_';
}
}