FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
SdlJoystick.h
1#pragma once
2
20#ifdef FH_VISUALIZATION
21
22#include "JoystickInput.h"
23
24#include <string>
25#include <vector>
26
27struct _SDL_Joystick;
28class ISimObjectCreator;
29
30namespace Ship
31{
32namespace joystick
33{
34
35class SdlJoystickPoller;
36
40void LogJoystickStatus(ISimObjectCreator* creator, const std::string& objectName, const SdlJoystickPoller& poller,
41 const std::string& error);
42
47class SdlJoystickPoller
48{
49public:
50 SdlJoystickPoller() = default;
51 ~SdlJoystickPoller();
52 SdlJoystickPoller(const SdlJoystickPoller&) = delete;
53 SdlJoystickPoller& operator=(const SdlJoystickPoller&) = delete;
54
57 std::string Open(int deviceIndex);
58
61 std::string OpenAll();
62
64 void Close();
65
67 std::size_t NumOpen() const { return m_devices.size(); }
68
70 void Poll(JoystickListener& listener);
71
73 std::string Name(std::size_t i) const;
74
75private:
76 struct Device
77 {
78 _SDL_Joystick* joystick = nullptr;
79 JoystickState previous;
80 };
81
82 bool InitSubsystem(std::string& error);
83
84 bool m_subsystem = false;
85 std::vector<Device> m_devices;
86};
87
88} // namespace joystick
89} // namespace Ship
90
91#endif
Simple waypoint object.
Definition CableAttach.h:16