neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_game_controllers.hpp
Go to the documentation of this file.
1
// i_game_controllers.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
>
23
#include <
neolib/core/i_vector.hpp
>
24
#include <
neolib/core/i_map.hpp
>
25
#include <
neogfx/hid/i_game_controller.hpp
>
26
27
namespace
neogfx
28
{
29
class
i_game_controllers
:
public
i_service
30
{
31
public
:
32
declare_event
(controller_connected,
i_game_controller
&)
33
declare_event
(controller_disconnected,
i_game_controller
&)
34
declare_event
(controller_calibration_required,
i_game_controller
&)
35
public
:
36
struct
unassigned_player : std::logic_error { unassigned_player() : std::logic_error{
"neogfx::i_game_controllers::unassigned_player"
} {} };
37
public
:
38
typedef
neolib::i_vector<i_ref_ptr<i_game_controller>
>
controller_list
;
39
typedef
neolib::i_map<game_controller_button_ordinal, game_controller_button>
button_map_type
;
40
public
:
41
virtual
~i_game_controllers
() =
default
;
42
public
:
43
virtual
void
enumerate_controllers
() = 0;
44
virtual
const
controller_list
&
controllers
()
const
= 0;
45
virtual
bool
have_controller_for
(
game_player
aPlayer)
const
= 0;
46
virtual
i_game_controller
&
controller_for
(
game_player
aPlayer)
const
= 0;
47
public
:
48
virtual
const
i_string
&
product_name
(
const
hid_device_uuid
& aProductId)
const
= 0;
49
virtual
const
button_map_type
&
button_map
(
const
hid_device_uuid
& aProductId)
const
= 0;
50
public
:
51
virtual
controller_list::iterator
add_device
(
i_game_controller
& aController) = 0;
52
virtual
controller_list::iterator
remove_device
(
i_game_controller
& aController) = 0;
53
public
:
54
template
<
typename
Controller,
typename
... Args>
55
ref_ptr<Controller>
add_controller
(Args&&... aArgs)
56
{
57
auto
newController = make_ref<Controller>(std::forward<Args>(aArgs)...);
58
add_device
(*newController);
59
return
newController;
60
}
61
public
:
62
static
uuid
const
&
iid
() {
static
uuid
const
sIid{ 0xda529547, 0xbddd, 0x4f52, 0x9f0, { 0xa5, 0xec, 0xee, 0x8e, 0x6e, 0x7f } };
return
sIid; }
63
};
64
}
neogfx::i_game_controller
Definition
i_game_controller.hpp:121
neogfx::i_game_controllers
Definition
i_game_controllers.hpp:30
neogfx::i_game_controllers::~i_game_controllers
virtual ~i_game_controllers()=default
neogfx::i_game_controllers::product_name
virtual const i_string & product_name(const hid_device_uuid &aProductId) const =0
neogfx::i_game_controllers::button_map
virtual const button_map_type & button_map(const hid_device_uuid &aProductId) const =0
neogfx::i_game_controllers::button_map_type
neolib::i_map< game_controller_button_ordinal, game_controller_button > button_map_type
Definition
i_game_controllers.hpp:39
neogfx::i_game_controllers::controller_for
virtual i_game_controller & controller_for(game_player aPlayer) const =0
neogfx::i_game_controllers::iid
static uuid const & iid()
Definition
i_game_controllers.hpp:62
neogfx::i_game_controllers::add_device
virtual controller_list::iterator add_device(i_game_controller &aController)=0
neogfx::i_game_controllers::enumerate_controllers
virtual void enumerate_controllers()=0
neogfx::i_game_controllers::controllers
virtual const controller_list & controllers() const =0
neogfx::i_game_controllers::controller_list
neolib::i_vector< i_ref_ptr< i_game_controller > > controller_list
Definition
i_game_controllers.hpp:34
neogfx::i_game_controllers::declare_event
declare_event(controller_connected, i_game_controller &) declare_event(controller_disconnected
neogfx::i_game_controllers::have_controller_for
virtual bool have_controller_for(game_player aPlayer) const =0
neogfx::i_game_controllers::remove_device
virtual controller_list::iterator remove_device(i_game_controller &aController)=0
neogfx::i_game_controllers::add_controller
ref_ptr< Controller > add_controller(Args &&... aArgs)
Definition
i_game_controllers.hpp:55
neolib::i_map
Definition
i_map.hpp:46
neolib::i_string
Definition
i_string.hpp:49
neolib::i_vector
Definition
i_vector.hpp:45
neolib::i_vector::iterator
offset_iterator< value_type > iterator
Definition
i_contiguous_random_access_container.hpp:123
neolib::ref_ptr
Definition
reference_counted.hpp:185
neolib::services::i_service
Definition
services.hpp:57
i_game_controller.hpp
i_map.hpp
i_vector.hpp
neogfx
Definition
action.hpp:28
neogfx::game_player
game_player
Definition
i_game_controller.hpp:30
neogfx.hpp
declare_event
#define declare_event(declName,...)
Definition
i_event.hpp:305
neolib::uuid
Definition
uuid.hpp:51
include
neogfx
hid
i_game_controllers.hpp
Generated by
1.9.8