Unravel Engine C++ Reference
Loading...
Searching...
No Matches
to_string.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "coord.hpp"
4#include "gamepad_axis.hpp"
5#include "gamepad_button.hpp"
6#include "key_state.hpp"
8#include "mouse_button.hpp"
9#include "point.hpp"
10#include <string>
11
12namespace input
13{
14
15inline auto to_string(axis_range range) -> const std::string&
16{
17 switch(range)
18 {
20 {
21 static const std::string text = "Full";
22 return text;
23 }
25 {
26 static const std::string text = "Positive";
27 return text;
28 }
30 {
31 static const std::string text = "Negative";
32 return text;
33 }
34 default:
35 {
36 static const std::string text = "Unknown";
37 return text;
38 }
39 }
40}
41
42inline auto to_string(input_type type) -> const std::string&
43{
44 switch(type)
45 {
47 {
48 static const std::string text = "Axis";
49 return text;
50 }
52 {
53 static const std::string text = "Button";
54 return text;
55 }
56 case input_type::key:
57 {
58 static const std::string text = "Key";
59 return text;
60 }
61 default:
62 {
63 static const std::string text = "Unknown";
64 return text;
65 }
66 }
67}
68
69inline auto to_string(const coord& coord) -> std::string
70{
71 return "(" + std::to_string(coord.x) + ", " + std::to_string(coord.y) + ")";
72}
73
74inline auto to_string(const gamepad_axis axis) -> std::string
75{
76 switch(axis)
77 {
79 return "Left X";
81 return "Left Y";
83 return "Right X";
85 return "Right Y";
87 return "Left Trigger";
89 return "Right Trigger";
90 default:
91 return "Unknown";
92 }
93}
94
95inline auto to_string(gamepad_button button) -> std::string
96{
97 switch(button)
98 {
100 return "South";
102 return "East";
104 return "West";
106 return "North";
108 return "Back";
110 return "Guide";
112 return "Start";
114 return "Left Stick";
116 return "Right Stick";
118 return "Left Shoulder";
120 return "Right Shoulder";
122 return "DPad Up";
124 return "DPad Down";
126 return "DPad left";
128 return "DPad Right";
130 return "Misc 1";
132 return "Right Paddle 1";
134 return "Left Paddle 1";
136 return "Right Paddle 2";
138 return "Left Paddle 2";
140 return "Touchpad";
142 return "Misc 2";
144 return "Misc 3";
146 return "Misc 4";
148 return "Misc 5";
150 return "Misc 6";
151 default:
152 return "Unknown";
153 }
154}
155
156inline auto get_description(gamepad_button button) -> std::string
157{
158 switch(button)
159 {
161 return "Bottom face button (e.g. Xbox A button, PS Cross button)";
163 return "Right face button (e.g. Xbox B button, PS Circle button)";
165 return "Left face button (e.g. Xbox X button, PS Square button)";
167 return "Top face button (e.g. Xbox Y button, PS Triangle button)";
169 return "Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button, Google Stadia capture button)";
171 return "Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1)";
173 return "Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3)";
175 return "Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2)";
177 return "Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4)";
179 return "PS4/PS5 touchpad button";
180 default:
181 return "";
182 }
183}
184
185inline auto to_string(const key_state state) -> std::string
186{
187 switch(state)
188 {
189 case key_state::down:
190 return "Down";
191 case key_state::up:
192 return "Up";
194 return "Released";
196 return "Pressed";
197 }
198}
199
200inline auto to_string(const point& p) -> std::string
201{
202 return "(" + std::to_string(p.x) + ", " + std::to_string(p.y) + ")";
203}
204
205inline auto to_string(mouse_button button) -> std::string
206{
207 switch(button)
208 {
210 return "Left";
212 return "Right";
214 return "Middle";
216 return "Button 4";
218 return "Button 5";
220 return "Button 6";
222 return "Button 7";
224 return "Button 8";
226 return "Button 9";
228 return "Button 10";
230 return "Button 11";
232 return "Button 12";
234 return "Button 13";
236 return "Button 14";
238 return "Button 15";
240 return "Button 16";
241 default:
242 return "Unknown";
243 }
244}
245
246inline auto to_string(mouse_axis axis) -> const std::string&
247{
248 switch(axis)
249 {
250 case mouse_axis::x:
251 {
252 static const std::string text = "X";
253 return text;
254 }
255 case mouse_axis::y:
256 {
257 static const std::string text = "Y";
258 return text;
259 }
261 {
262 static const std::string text = "Scroll";
263 return text;
264 }
265 default:
266 {
267 static const std::string text = "Unknown";
268 return text;
269 }
270 }
271}
272
273} // namespace input
manifold_type type
auto get_description(gamepad_button button) -> std::string
auto to_string(axis_range range) -> const std::string &
Definition to_string.hpp:15