holesome/src/input_config.h

66 lines
3.1 KiB
C
Raw Normal View History

#ifndef HOLESOME_INPUT_CONFIG_H
#define HOLESOME_INPUT_CONFIG_H
#include <map>
2023-07-09 23:51:34 +02:00
#include <string>
#include "game/input/input_device_group.h"
#include "game/input/button_config.hpp"
#include "game/input/game_action_config.hpp"
#include "game/input/gamepad_buttons.hpp"
#define JOYSTICK_DEADZONE 0.1f
// Keys
const std::map<sf::Keyboard::Key, ButtonConfig> KEY_CONFIGS = {
2023-07-09 23:51:34 +02:00
{sf::Keyboard::Up, ButtonConfig(InputDeviceGroup::KEYBOARD_ARROWS, HardDirection::UP)},
{sf::Keyboard::Down, ButtonConfig(InputDeviceGroup::KEYBOARD_ARROWS, HardDirection::DOWN)},
{sf::Keyboard::Left, ButtonConfig(InputDeviceGroup::KEYBOARD_ARROWS, HardDirection::LEFT)},
{sf::Keyboard::Right, ButtonConfig(InputDeviceGroup::KEYBOARD_ARROWS, HardDirection::RIGHT)},
{sf::Keyboard::Space, ButtonConfig(InputDeviceGroup::KEYBOARD_ARROWS, {GameAction::CONFIRM})},
{sf::Keyboard::W, ButtonConfig(InputDeviceGroup::KEYBOARD_WASD, HardDirection::UP)},
{sf::Keyboard::S, ButtonConfig(InputDeviceGroup::KEYBOARD_WASD, HardDirection::DOWN)},
{sf::Keyboard::A, ButtonConfig(InputDeviceGroup::KEYBOARD_WASD, HardDirection::LEFT)},
{sf::Keyboard::D, ButtonConfig(InputDeviceGroup::KEYBOARD_WASD, HardDirection::RIGHT)},
{sf::Keyboard::Q, ButtonConfig(InputDeviceGroup::KEYBOARD_WASD, {GameAction::CONFIRM})},
{sf::Keyboard::E, ButtonConfig(InputDeviceGroup::KEYBOARD_WASD, {GameAction::CONFIRM})},
{sf::Keyboard::I, ButtonConfig(InputDeviceGroup::KEYBOARD_IJKL, HardDirection::UP)},
{sf::Keyboard::K, ButtonConfig(InputDeviceGroup::KEYBOARD_IJKL, HardDirection::DOWN)},
{sf::Keyboard::J, ButtonConfig(InputDeviceGroup::KEYBOARD_IJKL, HardDirection::LEFT)},
{sf::Keyboard::L, ButtonConfig(InputDeviceGroup::KEYBOARD_IJKL, HardDirection::RIGHT)},
{sf::Keyboard::U, ButtonConfig(InputDeviceGroup::KEYBOARD_IJKL, {GameAction::CONFIRM})},
{sf::Keyboard::O, ButtonConfig(InputDeviceGroup::KEYBOARD_IJKL, {GameAction::CONFIRM})}
};
// Gamepad buttons
const std::map<int, ButtonConfig> GAMEPAD_BUTTON_CONFIGS = {
2023-07-09 23:51:34 +02:00
{GamepadButton::EAST, ButtonConfig(InputDeviceGroup::GAMEPAD, {GameAction::CONFIRM})},
{GamepadButton::SOUTH, ButtonConfig(InputDeviceGroup::GAMEPAD, {GameAction::CONFIRM})}
};
// Actions
const std::map<GameAction, GameActionConfig> GAME_ACTION_CONFIGS = {
2023-07-09 23:51:34 +02:00
{GameAction::CONFIRM, GameActionConfig(InteractionMode::PRESS)}
};
const std::map<InputDeviceGroup, std::string> DEVICE_GROUP_NAMES = {
{InputDeviceGroup::KEYBOARD_WASD, "WASD"},
{InputDeviceGroup::KEYBOARD_IJKL, "IJKL"},
{InputDeviceGroup::KEYBOARD_ARROWS, "Arrow keys"},
{InputDeviceGroup::GAMEPAD, "Gamepad"}
};
const std::map<InputDeviceGroup, std::string> DEVICE_GROUP_CONFIRM = {
{InputDeviceGroup::KEYBOARD_WASD, "Q or E"},
{InputDeviceGroup::KEYBOARD_IJKL, "U or O"},
{InputDeviceGroup::KEYBOARD_ARROWS, "Space"},
{InputDeviceGroup::GAMEPAD, "A or B"}
};
#endif //HOLESOME_INPUT_CONFIG_H