Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
haptics_system.hpp
Go to the documentation of this file.
1
6
7
#pragma once
8
9
#include <
toast/assets/types.hpp
>
10
#include <toast/events/listener.hpp>
11
#include <unordered_set>
12
13
namespace
input {
14
15
class
TOAST_API HapticsSystem {
16
public
:
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
40
private
:
41
struct
Playback {
42
uint32_t controller = 0;
43
assets::Handle<assets::Haptic>
haptic;
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
}
assets::Handle
Type-safe smart pointer for assets.
Definition
core_types.hpp:149
event::Listener
manages the lifetime, subscription, and unsubscription of callbacks
Definition
listener.hpp:39
input::HapticsSystem::play
void play(uint32_t controller, assets::Handle< assets::Haptic > haptic)
Definition
haptics_system.cpp:51
types.hpp
Concrete asset types for the Toast engine.
engine
src
toast
input
haptics_system.hpp
Generated by
1.17.0