neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_game_controller.hpp
Go to the documentation of this file.
1// i_game_controller.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
26
27namespace neogfx
28{
29 enum class game_player : uint32_t
30 {
31 One = 0x00000001,
32 Two = 0x00000002,
33 Three = 0x00000003,
34 Four = 0x00000004
35 };
36
37 typedef uint32_t game_controller_port;
38
39 enum class game_controller_button : uint64_t
40 {
41 None = 0x0000000000000000,
42 A = 0x0000000000000001,
43 B = 0x0000000000000002,
44 X = 0x0000000000000004,
45 Y = 0x0000000000000008,
46 C = X,
47 D = Y,
48 Cross = A,
49 Circle = B,
50 Square = X,
51 Triangle = Y,
52 Green = A,
53 Red = B,
54 Blue = X,
55 Yellow = Y,
56 LeftShoulder = 0x0000000000000010,
57 RightShoulder = 0x0000000000000020,
58 LeftTrigger = 0x0000000000000040,
59 RightTrigger = 0x0000000000000080,
60 DirectionalPadUp = 0x0000000000000100,
61 DirectionalPadDown = 0x0000000000000200,
62 DirectionalPadLeft = 0x0000000000000400,
63 DirectionalPadRight = 0x0000000000000800,
64 LeftThumb = 0x0000000000001000,
65 LeftThumbUp = 0x0000000000002000,
66 LeftThumbDown = 0x0000000000004000,
67 LeftThumbLeft = 0x0000000000008000,
68 LeftThumbRight = 0x0000000000010000,
69 LeftThumbUpLeft = 0x0000000000020000,
70 LeftThumbUpRight = 0x0000000000040000,
71 LeftThumbDownLeft = 0x0000000000080000,
72 LeftThumbDownRight = 0x0000000000100000,
73 RightThumb = 0x0000000000200000,
74 RightThumbUp = 0x0000000000400000,
75 RightThumbDown = 0x0000000000800000,
76 RightThumbLeft = 0x0000000001000000,
77 RightThumbRight = 0x0000000002000000,
78 RightThumbUpLeft = 0x0000000004000000,
79 RightThumbUpRight = 0x0000000008000000,
80 RightThumbDownLeft = 0x0000000010000000,
81 RightThumbDownRight = 0x0000000020000000,
82 Start = 0x0000000040000000,
83 Back = 0x0000000080000000,
84 Function1 = 0x0000000100000000,
85 Function2 = 0x0000000200000000,
86 Function3 = 0x0000000400000000,
87 Function4 = 0x0000000800000000,
88 Function5 = 0x0000001000000000,
89 Function6 = 0x0000002000000000,
90 Function7 = 0x0000004000000000,
91 Function8 = 0x0000008000000000,
92 Function9 = 0x0000010000000000,
93 Function10 = 0x0000020000000000,
94 Function11 = 0x0000040000000000,
95 Function12 = 0x0000080000000000,
96 Function13 = 0x0000100000000000,
97 Function14 = 0x0000200000000000,
98 Function15 = 0x0000400000000000,
99 Function16 = 0x0000800000000000,
100 Function17 = 0x0001000000000000,
101 Function18 = 0x0002000000000000,
102 Function19 = 0x0004000000000000,
103 Function20 = 0x0008000000000000,
104 Function21 = 0x0010000000000000,
105 Function22 = 0x0020000000000000,
106 Function23 = 0x0040000000000000,
107 Function24 = 0x0080000000000000,
108 Function25 = 0x0100000000000000,
109 Function26 = 0x0200000000000000,
110 Function27 = 0x0400000000000000,
111 Function28 = 0x0800000000000000,
112 Function29 = 0x1000000000000000,
113 Function30 = 0x2000000000000000,
114 Function31 = 0x4000000000000000,
115 Function32 = 0x8000000000000000
116 };
117
119
121 {
122 public:
124 public:
128 declare_event(left_trigger_moved, double, key_modifiers_e)
129 declare_event(right_trigger_moved, double, key_modifiers_e)
130 declare_event(left_thumb_moved, const vec2&, key_modifiers_e)
131 declare_event(right_thumb_moved, const vec2&, key_modifiers_e)
132 declare_event(stick_moved, const vec3&, key_modifiers_e)
133 declare_event(stick_rotated, const vec3&, key_modifiers_e)
134 declare_event(slider_moved, const vec2&, key_modifiers_e)
135 public:
136 struct player_not_assigned : std::logic_error { player_not_assigned() : std::logic_error{ "neogfx::i_game_controller::player_not_assigned" } {} };
137 struct unknown_port : std::logic_error { unknown_port() : std::logic_error{ "neogfx::i_game_controller::unknown_port" } {} };
138 public:
139 virtual bool player_assigned() const = 0;
140 virtual game_player player() const = 0;
141 virtual void assign_player(game_player aPlayer) = 0;
142 virtual void unassign_player() = 0;
143 public:
144 virtual bool have_port() const = 0;
145 virtual game_controller_port port() const = 0;
146 virtual void set_port(game_controller_port aPort) = 0;
147 virtual void clear_port() = 0;
148 public:
149 virtual bool needs_calibrating() const = 0;
150 public:
151 virtual bool is_button_pressed(game_controller_button_ordinal aButtonOrdinal) const = 0;
152 virtual bool is_button_pressed(game_controller_button aButton) const = 0;
153 virtual double left_trigger_position() const = 0;
154 virtual double right_trigger_position() const = 0;
155 virtual const vec2& left_thumb_position() const = 0;
156 virtual const vec2& right_thumb_position() const = 0;
157 virtual const vec3& stick_position() const = 0;
158 virtual const vec3& stick_rotation() const = 0;
159 virtual const vec2& slider_position() const = 0;
160 public:
161 virtual uint32_t button_count() const = 0;
162 virtual bool button_mapped(game_controller_button aButton) const = 0;
165 };
166}
virtual bool player_assigned() const =0
virtual const vec2 & left_thumb_position() const =0
virtual double right_trigger_position() const =0
virtual void set_port(game_controller_port aPort)=0
virtual bool is_button_pressed(game_controller_button aButton) const =0
virtual game_player player() const =0
declare_event(button_pressed, game_controller_button, key_modifiers_e) declare_event(button_released
virtual bool is_button_pressed(game_controller_button_ordinal aButtonOrdinal) const =0
virtual double left_trigger_position() const =0
virtual const vec3 & stick_rotation() const =0
virtual const vec3 & stick_position() const =0
virtual void unassign_player()=0
virtual game_controller_port port() const =0
virtual bool button_mapped(game_controller_button aButton) const =0
virtual void clear_port()=0
virtual bool needs_calibrating() const =0
virtual uint32_t button_count() const =0
virtual game_controller_button button_ordinal_to_button(game_controller_button_ordinal aButtonOrdinal) const =0
virtual const vec2 & right_thumb_position() const =0
virtual const vec2 & slider_position() const =0
virtual game_controller_button_ordinal button_to_button_ordinal(game_controller_button aButton) const =0
virtual bool have_port() const =0
virtual void assign_player(game_player aPlayer)=0
uint32_t game_controller_port
uint32_t game_controller_button_ordinal
Definition plf_hive.h:79
#define declare_event(declName,...)
Definition i_event.hpp:305