Implement input configuration loading from i32
This commit is contained in:
parent
174c247e43
commit
3477be28e8
|
@ -21,8 +21,21 @@ pub const Input = struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn loadConfig() void {
|
pub fn loadConfig() void {
|
||||||
for (comptime getInputNames()) |name| {
|
var iter = config.getConfigIterator("input.ini") catch {
|
||||||
std.debug.print("{s}\n", .{name});
|
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});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue