Add list-input-configs command

This commit is contained in:
Leon Henrik Plickat 2021-06-12 11:58:58 +00:00 committed by Isaac Freund
parent 3f4fd97b6e
commit a267262a17
3 changed files with 67 additions and 0 deletions

View File

@ -272,6 +272,9 @@ A complete list may be found in _/usr/include/linux/input-event-codes.h_
*list-inputs* *list-inputs*
List all input devices. List all input devices.
*list-input-configs*
List all input configurations.
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_.

View File

@ -59,6 +59,7 @@ const str_to_impl_fn = [_]struct {
.{ .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 = "list-inputs", .impl = @import("command/input.zig").listInputs },
.{ .name = "list-input-configs", .impl = @import("command/input.zig").listInputConfigs},
.{ .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 },

View File

@ -58,6 +58,69 @@ pub fn listInputs(
out.* = input_list.toOwnedSlice(); out.* = input_list.toOwnedSlice();
} }
pub fn listInputConfigs(
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();
for (server.input_manager.input_configs.items) |*input_config, i| {
if (i > 0) try input_list.appendSlice("\n");
try writer.print("{s}\n", .{input_config.identifier});
if (input_config.event_state) |event_state| {
try writer.print("\tevents: {s}\n", .{@tagName(event_state)});
}
if (input_config.accel_profile) |accel_profile| {
try writer.print("\taccel-profile: {s}\n", .{@tagName(accel_profile)});
}
if (input_config.click_method) |click_method| {
try writer.print("\tclick-method: {s}\n", .{@tagName(click_method)});
}
if (input_config.drag_state) |drag_state| {
try writer.print("\tdrag: {s}\n", .{@tagName(drag_state)});
}
if (input_config.drag_lock) |drag_lock| {
try writer.print("\tdrag-lock: {s}\n", .{@tagName(drag_lock)});
}
if (input_config.dwt_state) |dwt_state| {
try writer.print("\tdisable-while-typing: {s}\n", .{@tagName(dwt_state)});
}
if (input_config.middle_emulation) |middle_emulation| {
try writer.print("\tmiddle-emulation: {s}\n", .{@tagName(middle_emulation)});
}
if (input_config.natural_scroll) |natural_scroll| {
try writer.print("\tnatual-scroll: {s}\n", .{@tagName(natural_scroll)});
}
if (input_config.left_handed) |left_handed| {
try writer.print("\tleft-handed: {s}\n", .{@tagName(left_handed)});
}
if (input_config.tap_state) |tap_state| {
try writer.print("\ttap: {s}\n", .{@tagName(tap_state)});
}
if (input_config.tap_button_map) |tap_button_map| {
try writer.print("\ttap-button-map: {s}\n", .{@tagName(tap_button_map)});
}
if (input_config.pointer_accel) |pointer_accel| {
try writer.print("\tpointer-accel: {d}\n", .{pointer_accel.value});
}
if (input_config.scroll_method) |scroll_method| {
try writer.print("\tscroll-method: {s}\n", .{scroll_method});
}
if (input_config.scroll_button) |scroll_button| {
try writer.print("\tscroll-button: {s}\n", .{
mem.sliceTo(c.libevdev_event_code_get_name(c.EV_KEY, scroll_button.button), 0),
});
}
}
out.* = input_list.toOwnedSlice();
}
pub fn input( pub fn input(
allocator: *mem.Allocator, allocator: *mem.Allocator,
seat: *Seat, seat: *Seat,