diff options
author | HampusM <hampus@hampusmat.com> | 2022-03-05 13:26:55 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:56:54 +0200 |
commit | 6119f1428b3615e4738a121c6acf343942107fd9 (patch) | |
tree | 47eb5537674fe58ae8ad388521203b92bfb43529 /src/game/input_configurator.cpp | |
parent | d27f1a89266e141a944f88e9080bdeca95c49da3 (diff) |
refactor: move input config to own file & improve cleanup
Diffstat (limited to 'src/game/input_configurator.cpp')
-rw-r--r-- | src/game/input_configurator.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/game/input_configurator.cpp b/src/game/input_configurator.cpp new file mode 100644 index 0000000..4daee21 --- /dev/null +++ b/src/game/input_configurator.cpp @@ -0,0 +1,33 @@ +#include "input_configurator.hpp" + +namespace InputActions +{ + +void exit_success() +{ + exit(EXIT_SUCCESS); +} + +} // namespace InputActions + +InputConfigurator::InputConfigurator(std::shared_ptr<CursorController> cursor_controller) + : _cursor_controller(std::move(cursor_controller)) +{ +} + +void InputConfigurator::configure(IInputHandler &input_handler) +{ + input_handler.attach('q', InputActions::exit_success); + + input_handler.attach('k', + InputActions::move_cursor<Direction::UP>(*_cursor_controller)); + + input_handler.attach('j', + InputActions::move_cursor<Direction::DOWN>(*_cursor_controller)); + + input_handler.attach('h', + InputActions::move_cursor<Direction::LEFT>(*_cursor_controller)); + + input_handler.attach( + 'l', InputActions::move_cursor<Direction::RIGHT>(*_cursor_controller)); +} |