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>
24#include <neolib/core/i_map.hpp>
26
27namespace neogfx
28{
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:
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:
53 public:
54 template <typename Controller, typename... Args>
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}
virtual ~i_game_controllers()=default
virtual const i_string & product_name(const hid_device_uuid &aProductId) const =0
virtual const button_map_type & button_map(const hid_device_uuid &aProductId) const =0
neolib::i_map< game_controller_button_ordinal, game_controller_button > button_map_type
virtual i_game_controller & controller_for(game_player aPlayer) const =0
virtual controller_list::iterator add_device(i_game_controller &aController)=0
virtual void enumerate_controllers()=0
virtual const controller_list & controllers() const =0
neolib::i_vector< i_ref_ptr< i_game_controller > > controller_list
declare_event(controller_connected, i_game_controller &) declare_event(controller_disconnected
virtual bool have_controller_for(game_player aPlayer) const =0
virtual controller_list::iterator remove_device(i_game_controller &aController)=0
ref_ptr< Controller > add_controller(Args &&... aArgs)
offset_iterator< value_type > iterator
#define declare_event(declName,...)
Definition i_event.hpp:305