Add list-inputs
command
This commit is contained in:
parent
c9c9901c5b
commit
3f4fd97b6e
@ -269,6 +269,9 @@ A complete list may be found in _/usr/include/linux/input-event-codes.h_
|
|||||||
|
|
||||||
## INPUT CONFIGURATION
|
## INPUT CONFIGURATION
|
||||||
|
|
||||||
|
*list-inputs*
|
||||||
|
List all input devices.
|
||||||
|
|
||||||
The _input_ command can be used to create a configuration rule for an input
|
The _input_ command can be used to create a configuration rule for an input
|
||||||
device identified by its _name_.
|
device identified by its _name_.
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ const str_to_impl_fn = [_]struct {
|
|||||||
.{ .name = "focus-output", .impl = @import("command/focus_output.zig").focusOutput },
|
.{ .name = "focus-output", .impl = @import("command/focus_output.zig").focusOutput },
|
||||||
.{ .name = "focus-view", .impl = @import("command/focus_view.zig").focusView },
|
.{ .name = "focus-view", .impl = @import("command/focus_view.zig").focusView },
|
||||||
.{ .name = "input", .impl = @import("command/input.zig").input },
|
.{ .name = "input", .impl = @import("command/input.zig").input },
|
||||||
|
.{ .name = "list-inputs", .impl = @import("command/input.zig").listInputs },
|
||||||
.{ .name = "map", .impl = @import("command/map.zig").map },
|
.{ .name = "map", .impl = @import("command/map.zig").map },
|
||||||
.{ .name = "map-pointer", .impl = @import("command/map.zig").mapPointer },
|
.{ .name = "map-pointer", .impl = @import("command/map.zig").mapPointer },
|
||||||
.{ .name = "mod-layout-value", .impl = @import("command/layout.zig").modLayoutValue },
|
.{ .name = "mod-layout-value", .impl = @import("command/layout.zig").modLayoutValue },
|
||||||
|
@ -27,6 +27,37 @@ const Seat = @import("../Seat.zig");
|
|||||||
const InputConfig = @import("../InputConfig.zig");
|
const InputConfig = @import("../InputConfig.zig");
|
||||||
const InputManager = @import("../InputManager.zig");
|
const InputManager = @import("../InputManager.zig");
|
||||||
|
|
||||||
|
pub fn listInputs(
|
||||||
|
allocator: *mem.Allocator,
|
||||||
|
seat: *Seat,
|
||||||
|
args: []const []const u8,
|
||||||
|
out: *?[]const u8,
|
||||||
|
) Error!void {
|
||||||
|
var input_list = std.ArrayList(u8).init(allocator);
|
||||||
|
const writer = input_list.writer();
|
||||||
|
var prev = false;
|
||||||
|
|
||||||
|
var it = server.input_manager.input_devices.first;
|
||||||
|
while (it) |node| : (it = node.next) {
|
||||||
|
const configured = for (server.input_manager.input_configs.items) |*input_config| {
|
||||||
|
if (mem.eql(u8, input_config.identifier, mem.sliceTo(node.data.identifier, 0))) {
|
||||||
|
break true;
|
||||||
|
}
|
||||||
|
} else false;
|
||||||
|
|
||||||
|
if (prev) try input_list.appendSlice("\n");
|
||||||
|
prev = true;
|
||||||
|
|
||||||
|
try writer.print("{s}\n\ttype: {s}\n\tconfigured: {s}\n", .{
|
||||||
|
node.data.identifier,
|
||||||
|
@tagName(node.data.device.type),
|
||||||
|
configured,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
out.* = input_list.toOwnedSlice();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn input(
|
pub fn input(
|
||||||
allocator: *mem.Allocator,
|
allocator: *mem.Allocator,
|
||||||
seat: *Seat,
|
seat: *Seat,
|
||||||
|
Loading…
Reference in New Issue
Block a user