26 lines
504 B
C++
26 lines
504 B
C++
#pragma once
|
|
#include <unordered_map>
|
|
#include <functional>
|
|
|
|
enum class InputAction {
|
|
MOVE_UP,
|
|
MOVE_DOWN,
|
|
MOVE_LEFT,
|
|
MOVE_RIGHT,
|
|
};
|
|
|
|
class InputComponent {
|
|
public:
|
|
InputComponent() = default;
|
|
|
|
void BindKey(InputAction action, int key);
|
|
|
|
void Update();
|
|
|
|
void SetActionCallback(InputAction action, std::function<void()> callback);
|
|
|
|
private:
|
|
std::unordered_map<InputAction, int> keyBindings;
|
|
std::unordered_map<InputAction, std::function<void()>> actionCallbacks;
|
|
};
|