use format::ini;
use fs;
use io;
use os;
use sdl2;
fn config(
keybindings: *[](sdl2::keycode, action),
cfg: io::handle,
) (void | ini::error | sdl2::error) = {
let sc = ini::scan(cfg);
defer ini::finish(&sc);
for (true) match (ini::next(&sc)?) {
case io::EOF =>
break;
case let e: ini::entry =>
switch (e.0) {
case "keyboard" =>
const action = switch (e.1) {
case "commit" =>
yield action::COMMIT;
case "down" =>
yield action::DOWN;
case "left" =>
yield action::LEFT;
case "right" =>
yield action::RIGHT;
case "rotleft" =>
yield action::ROTLEFT;
case "rotright" =>
yield action::ROTRIGHT;
case =>
continue;
};
let keycode = sdl2::get_key_from_name(e.2)?;
for (let i = 0z; i < len(keybindings); i += 1) {
if (keybindings[i].0 == keycode) {
delete(keybindings[i]);
i -= 1;
};
};
append(keybindings, (keycode, action));
case => void;
};
};
};