OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
game_controller_protocol.hpp
1#pragma once
2
3#include <ossia/detail/small_flat_map.hpp>
4#include <ossia/network/base/protocol.hpp>
5#include <ossia/network/common/complex_type.hpp>
6#include <ossia/network/common/device_parameter.hpp>
7#include <ossia/network/context_functions.hpp>
8#include <ossia/network/domain/domain.hpp>
9
10typedef struct _SDL_GameController SDL_GameController;
11namespace ossia::net
12{
13class joystick_protocol_manager;
14struct joystick_event_processor;
15
16class OSSIA_EXPORT game_controller_protocol final : public ossia::net::protocol_base
17{
18 friend class joystick_protocol_manager;
19 friend struct joystick_event_processor;
20
21public:
22 game_controller_protocol(
23 ossia::net::network_context_ptr, const int32_t joystick_id,
24 const int joystick_index);
25 game_controller_protocol(const game_controller_protocol&) = delete;
26 game_controller_protocol(game_controller_protocol&&) = delete;
27 game_controller_protocol& operator=(const game_controller_protocol&) = delete;
28 game_controller_protocol& operator=(game_controller_protocol&&) = delete;
29 ~game_controller_protocol() override;
30
31 void set_device(ossia::net::device_base& dev) override;
32
33 bool pull(ossia::net::parameter_base& param) override;
34 bool push(const ossia::net::parameter_base& param, const ossia::value& v) override;
35 bool push_raw(const ossia::net::full_parameter_data&) override;
36 bool observe(ossia::net::parameter_base& param, bool enable) override;
37
38 bool update(ossia::net::node_base&) override;
39 void stop() override;
40
41private:
42 joystick_protocol_manager& m_manager;
43 joystick_event_processor& m_processor;
44 ossia::net::network_context_ptr m_ctx{};
45
46 ossia::net::device_base* m_device{};
47
48 ossia::small_flat_map<int, device_parameter*, 6> m_axis_parameters;
49 ossia::small_flat_map<int, device_parameter*, 32> m_button_parameters;
50 ossia::small_flat_map<int, device_parameter*, 10> m_sensor_parameters;
51
52 struct
53 {
54 device_parameter* lo_freq{};
55 device_parameter* hi_freq{};
56 device_parameter* duration{};
57 } rumble;
58
59 struct
60 {
61 device_parameter* left{};
62 device_parameter* right{};
63 device_parameter* duration{};
64 } rumble_triggers;
65 struct touchpad
66 {
67 struct finger
68 {
69 device_parameter* x{};
70 device_parameter* y{};
71 device_parameter* pressure{};
72 };
73 std::vector<finger> fingers;
74 };
75 ossia::small_flat_map<int, touchpad, 2> m_touchpads;
76
77 int32_t m_joystick_id{};
78 int32_t m_joystick_index{};
79
80 SDL_GameController* m_joystick{};
81};
82
83}
Root of a device tree.
Definition ossia/network/base/device.hpp:58
The node_base class.
Definition node.hpp:48
The parameter_base class.
Definition ossia/network/base/parameter.hpp:48
The protocol_base class.
Definition protocol.hpp:40
The value class.
Definition value.hpp:173
Full information about a parameter.
Definition parameter_data.hpp:61