diff --git a/src/input.zig b/src/input.zig index d529ab0..9c473b6 100644 --- a/src/input.zig +++ b/src/input.zig @@ -21,8 +21,21 @@ pub const Input = struct { }; pub fn loadConfig() void { - for (comptime getInputNames()) |name| { - std.debug.print("{s}\n", .{name}); + var iter = config.getConfigIterator("input.ini") catch { + std.debug.print("Error loading input config, using defaults...\n", .{}); + return; + }; + + while (iter.next()) |option| { + inline for (comptime getInputNames()) |name| { + if (std.mem.eql(u8, option.key, name)) { + if (std.fmt.parseInt(i32, option.value, 10) catch null) |value| { + @field(Self, name).code = value; + } else { + std.debug.print("Invalid input value '{s}' in config, ignoring.", .{option.value}); + } + } + } } }