Toast Engine
Loading...
Searching...
No Matches
haptics_system.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
10#include <toast/events/listener.hpp>
11#include <unordered_set>
12
13namespace input {
14
15class TOAST_API HapticsSystem {
16public:
17 HapticsSystem();
18 ~HapticsSystem();
19
20 HapticsSystem(const HapticsSystem&) = delete;
21 auto operator=(const HapticsSystem&) -> HapticsSystem& = delete;
22
23 [[nodiscard]]
24 static auto get() noexcept -> HapticsSystem&;
25
29 void play(uint32_t controller, assets::Handle<assets::Haptic> haptic);
30
31 void setGlobalMultiplier(float multiplier) noexcept;
32
33 [[nodiscard]]
34 auto globalMultiplier() const noexcept -> float {
35 return m_global_multiplier;
36 }
37
38 void tick();
39
40private:
41 struct Playback {
42 uint32_t controller = 0;
44 float elapsed = 0.0f;
45 };
46
47 static inline HapticsSystem* instance = nullptr;
48
49 event::Listener m_listener;
50 std::vector<Playback> m_playbacks;
51 std::unordered_set<uint32_t> m_rumbling;
52 float m_global_multiplier = 1.0f;
53};
54
55}
Type-safe smart pointer for assets.
Definition core_types.hpp:149
manages the lifetime, subscription, and unsubscription of callbacks
Definition listener.hpp:39
void play(uint32_t controller, assets::Handle< assets::Haptic > haptic)
Definition haptics_system.cpp:51
Concrete asset types for the Toast engine.