Conquer Chess
Chess and Starcraft combined
Loading...
Searching...
No Matches
key_bindings.h
Go to the documentation of this file.
1#ifndef KEY_BINDINGS_H
2#define KEY_BINDINGS_H
3
4#include "ccfwd.h"
5#include "user_input_type.h"
6
7#include <SFML/Window/Keyboard.hpp>
8#include <SFML/Window/Event.hpp>
9
10#include <iosfwd>
11#include <vector>
12
19{
20public:
22 const sf::Keyboard::Key up,
23 const sf::Keyboard::Key right,
24 const sf::Keyboard::Key down,
25 const sf::Keyboard::Key left,
26 const sf::Keyboard::Key action_1,
27 const sf::Keyboard::Key action_2,
28 const sf::Keyboard::Key action_3,
29 const sf::Keyboard::Key action_4
30 );
31
34 std::vector<user_input_type> create_actions(
35 const sf::Keyboard::Key k
36 ) const noexcept;
37
39 sf::Keyboard::Key get_key_for_action(const action_number& action) const;
40
42 sf::Keyboard::Key get_key_for_move_down() const noexcept { return m_down; }
43
45 sf::Keyboard::Key get_key_for_move_left() const noexcept { return m_left; }
46
48 sf::Keyboard::Key get_key_for_move_right() const noexcept { return m_right; }
49
51 sf::Keyboard::Key get_key_for_move_up() const noexcept { return m_up; }
52
53private:
54
55 std::vector<sf::Keyboard::Key> m_actions;
56 sf::Keyboard::Key m_down;
57 sf::Keyboard::Key m_left;
58 sf::Keyboard::Key m_right;
59 sf::Keyboard::Key m_up;
60};
61
64
67
69sf::Keyboard::Key get_key_for_action(
70 const key_bindings& k,
71 const action_number& action
72) noexcept;
73
76
77bool operator==(const key_bindings& lhs, const key_bindings& rhs) noexcept;
78
79std::ostream& operator<<(std::ostream& os, const key_bindings& keys) noexcept;
80
81#endif // KEY_BINDINGS_H
The number of an action.
Definition action_number.h:12
The key bindings.
Definition key_bindings.h:19
sf::Keyboard::Key get_key_for_move_up() const noexcept
Get the key for moving up.
Definition key_bindings.h:51
std::vector< user_input_type > create_actions(const sf::Keyboard::Key k) const noexcept
From an event, create zero or one user inputs.
Definition key_bindings.cpp:27
sf::Keyboard::Key get_key_for_move_right() const noexcept
Get the key for moving right.
Definition key_bindings.h:48
sf::Keyboard::Key get_key_for_action(const action_number &action) const
Get the key for action 1, 2, 3 or 4.
Definition key_bindings.cpp:95
sf::Keyboard::Key get_key_for_move_left() const noexcept
Get the key for moving left.
Definition key_bindings.h:45
sf::Keyboard::Key get_key_for_move_down() const noexcept
Get the key for moving down.
Definition key_bindings.h:42
void test_key_bindings()
Test this class and its free functions.
Definition key_bindings.cpp:108
key_bindings create_left_keyboard_key_bindings() noexcept
Create the key bindings for a player at the left side of a keyboard.
Definition key_bindings.cpp:67
key_bindings create_right_keyboard_key_bindings() noexcept
Create the key bindings for a player at the right side of a keyboard.
Definition key_bindings.cpp:81
sf::Keyboard::Key get_key_for_action(const key_bindings &k, const action_number &action) noexcept
Get the key for a specific action.
Definition key_bindings.cpp:103