openMSX
JoystickManager.hh
Go to the documentation of this file.
1#ifndef JOYSTICK_MANAGER_HH
2#define JOYSTICK_MANAGER_HH
3
4#include "JoystickId.hh"
5
6#include <memory>
7#include <optional>
8#include <vector>
9
10#include <SDL.h>
11
12namespace openmsx {
13
14class CommandController;
15class IntegerSetting;
16
18 JoystickManager(const JoystickManager&) = delete;
20 JoystickManager& operator=(const JoystickManager&) = delete;
21 JoystickManager& operator=(JoystickManager&&) = delete;
22
23public:
24 explicit JoystickManager(CommandController& commandController_);
26
27 // Handle SDL joystick added/removed events
28 void add(int deviceIndex);
29 void remove(int instanceId);
30
31 // return the range of JoystickId's for which there is a corresponding SDL_Joystick
32 [[nodiscard]] std::vector<JoystickId> getConnectedJoysticks() const;
33
34 [[nodiscard]] IntegerSetting* getJoyDeadZoneSetting(JoystickId joyId) const;
35 [[nodiscard]] std::string getDisplayName(JoystickId joyId) const;
36 [[nodiscard]] std::optional<unsigned> getNumButtons(JoystickId joyId) const;
37
38 [[nodiscard]] std::optional<JoystickId> translateSdlInstanceId(SDL_Event& evt) const;
39
40private:
41 [[nodiscard]] size_t getFreeSlot();
42
43private:
44 CommandController& commandController;
45
46 struct Info {
47 SDL_Joystick* joystick = nullptr;
48 int instanceId = -1;
49 std::unique_ptr<IntegerSetting> deadZoneSetting;
50 };
51 std::vector<Info> infos;
52};
53
54} // namespace openmsx
55
56#endif
A Setting with an integer value.
void add(int deviceIndex)
IntegerSetting * getJoyDeadZoneSetting(JoystickId joyId) const
std::optional< unsigned > getNumButtons(JoystickId joyId) const
void remove(int instanceId)
std::vector< JoystickId > getConnectedJoysticks() const
std::optional< JoystickId > translateSdlInstanceId(SDL_Event &evt) const
std::string getDisplayName(JoystickId joyId) const
This file implemented 3 utility functions:
Definition Autofire.cc:9
AmdFlash::SectorInfo Info
Definition RomManbow2.cc:18