This repository has been archived by the owner on Apr 16, 2022. It is now read-only.
/
InputNames.hpp
99 lines (82 loc) · 3.57 KB
/
InputNames.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/////////////////////////////////////////////////////////////////////////////////
//
// Thor C++ Library
// Copyright (c) 2011-2022 Jan Haller
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
/////////////////////////////////////////////////////////////////////////////////
/// @file
/// @brief Functions to convert SFML keyboard/mouse enumerators from and to strings
#ifndef THOR_INPUTNAMES_HPP
#define THOR_INPUTNAMES_HPP
#include <Thor/Config.hpp>
#include <SFML/Window/Keyboard.hpp>
#include <SFML/Window/Mouse.hpp>
#include <SFML/Window/Joystick.hpp>
#include <string>
namespace thor
{
/// @addtogroup Input
/// @{
/// @brief Returns a string representation of @a key.
/// @details The returned string is identical to the enum identifier. For example:
/// @code
/// thor::toString(sf::Keyboard::BackSlash) == "BackSlash"
/// @endcode
/// @throw StringConversionException in case of invalid key.
std::string THOR_API toString(sf::Keyboard::Key key);
/// @brief Returns a string representation of @a button.
/// @details The returned string is identical to the enum identifier. For example:
/// @code
/// thor::toString(sf::Mouse::Right) == "Right"
/// @endcode
/// @throw StringConversionException in case of invalid mouse button.
std::string THOR_API toString(sf::Mouse::Button button);
/// @brief Returns a string representation of @a axis.
/// @details The returned string is identical to the enum identifier. For example:
/// @code
/// thor::toString(sf::Joystick::U) == "U"
/// @endcode
/// @throw StringConversionException in case of invalid joystick axis.
std::string THOR_API toString(sf::Joystick::Axis axis);
/// @brief Returns the key interpretation of @a string.
/// @details The passed string shall be identical to the enum identifier. For example:
/// @code
/// thor::toKeyboardKey("BackSlash") == sf::Keyboard::BackSlash
/// @endcode
/// @throw StringConversionException if the string doesn't match a key.
sf::Keyboard::Key THOR_API toKeyboardKey(const std::string& string);
/// @brief Returns the mouse button interpretation of @a string.
/// @details The passed string shall be identical to the enum identifier. For example:
/// @code
/// thor::toMouseButton("Right") == sf::Mouse::Right
/// @endcode
/// @throw StringConversionException if the string doesn't match a mouse button.
sf::Mouse::Button THOR_API toMouseButton(const std::string& string);
/// @brief Returns the joystick axis interpretation of @a string.
/// @details The passed string shall be identical to the enum identifier. For example:
/// @code
/// thor::toJoystickAxis("U") == sf::Joystick::U
/// @endcode
/// @throw StringConversionException if the string doesn't match a joystick axis.
sf::Joystick::Axis THOR_API toJoystickAxis(const std::string& string);
/// @}
} // namespace thor
#endif // THOR_INPUTNAMES_HPP