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.
This commit is contained in:
parent
c40dc5ee75
commit
67d07e84b0
@ -36,18 +36,23 @@ destroy: wl.Listener(*wlr.InputDevice) = wl.Listener(*wlr.InputDevice).init(hand
|
|||||||
identifier: []const u8,
|
identifier: []const u8,
|
||||||
|
|
||||||
pub fn init(self: *InputDevice, device: *wlr.InputDevice) !void {
|
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(
|
const identifier = try std.fmt.allocPrint(
|
||||||
util.gpa,
|
util.gpa,
|
||||||
"{s}-{}-{}-{s}",
|
"{s}-{}-{}-{s}",
|
||||||
.{
|
.{
|
||||||
@tagName(device.type),
|
device_type,
|
||||||
device.vendor,
|
device.vendor,
|
||||||
device.product,
|
device.product,
|
||||||
mem.trim(u8, mem.span(device.name), &ascii.spaces),
|
mem.trim(u8, mem.span(device.name), &ascii.spaces),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
for (identifier) |*char| {
|
for (identifier) |*char| {
|
||||||
if (char.* == ' ' or !ascii.isPrint(char.*)) {
|
if (!ascii.isGraph(char.*)) {
|
||||||
char.* = '_';
|
char.* = '_';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user