libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
ControllerRumble.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <memory>
5#include <unordered_map>
6#include <string>
7
9
10namespace Ship {
11class ConsoleVariable;
12class ControlDeck;
24 public:
26 void SetControlDeck(std::shared_ptr<ControlDeck> controlDeck) {
27 mControlDeck = std::move(controlDeck);
28 }
33 ControllerRumble(uint8_t portIndex, std::shared_ptr<ConsoleVariable> consoleVariable = nullptr,
34 std::shared_ptr<ControlDeck> controlDeck = nullptr);
36
40 std::unordered_map<std::string, std::shared_ptr<ControllerRumbleMapping>> GetAllRumbleMappings();
41
46 void AddRumbleMapping(std::shared_ptr<ControllerRumbleMapping> mapping);
47
52 void ClearRumbleMappingId(std::string id);
53
58 void ClearRumbleMapping(std::string id);
59
62
65
71
76 void AddDefaultMappings(PhysicalDeviceType physicalDeviceType);
77
82 void LoadRumbleMappingFromConfig(std::string id);
83
86
92
95
97 void StopRumble();
98
104
105 private:
106 uint8_t mPortIndex;
107 std::unordered_map<std::string, std::shared_ptr<ControllerRumbleMapping>> mRumbleMappings;
108 std::shared_ptr<ConsoleVariable> mConsoleVariable;
109 std::shared_ptr<ControlDeck> mControlDeck;
110};
111} // namespace Ship
Aggregates rumble output mappings and drives force-feedback hardware.
Definition ControllerRumble.h:23
void StartRumble()
Activates rumble on all mapped physical devices.
bool HasMappingsForPhysicalDeviceType(PhysicalDeviceType physicalDeviceType)
Returns true if any mapping targets the given device type.
void ClearRumbleMappingId(std::string id)
Removes the mapping ID from Config without destroying the in-memory object.
void LoadRumbleMappingFromConfig(std::string id)
Loads the mapping with id from Config and adds it to the collection.
void ReloadAllMappingsFromConfig()
Clears all in-memory mappings and reloads them from Config.
ControllerRumble(uint8_t portIndex, std::shared_ptr< ConsoleVariable > consoleVariable=nullptr, std::shared_ptr< ControlDeck > controlDeck=nullptr)
Constructs a ControllerRumble for the given port.
void SaveRumbleMappingIdsToConfig()
Writes the current set of mapping IDs to Config.
void ClearAllMappings()
Removes all in-memory rumble mappings.
void AddDefaultMappings(PhysicalDeviceType physicalDeviceType)
Applies the default rumble mappings for the given device type.
void AddRumbleMapping(std::shared_ptr< ControllerRumbleMapping > mapping)
Adds a rumble mapping to the collection.
void ClearAllMappingsForDeviceType(PhysicalDeviceType physicalDeviceType)
Removes all mappings that target the given device type.
void ClearRumbleMapping(std::string id)
Removes the mapping with id from both in-memory and Config.
bool AddRumbleMappingFromRawPress()
Listens for the next raw physical input and creates a rumble mapping from it.
void SetControlDeck(std::shared_ptr< ControlDeck > controlDeck)
Injects the owning ControlDeck.
Definition ControllerRumble.h:26
std::unordered_map< std::string, std::shared_ptr< ControllerRumbleMapping > > GetAllRumbleMappings()
Returns a copy of the full id → mapping map.
void StopRumble()
Stops rumble on all mapped physical devices.
Core namespace for the libultraship engine framework.
Definition gfx_direct3d_common.h:14
PhysicalDeviceType
Identifies the category of a physical input device.
Definition PhysicalDeviceType.h:11