Toast Engine
Loading...
Searching...
No Matches
haptic.hpp
Go to the documentation of this file.
1
8
9#pragma once
10#include <cstdint>
11#include <glm/glm.hpp>
12#include <memory>
14#include <toast/assets/data.hpp>
15
16namespace assets {
17
18enum class HapticMode : uint8_t {
19 standard,
20 curve,
21 adaptive_trigger, // TODO: implement this
22 audio_haptic, // TODO: implement this
23};
24
25enum class HapticChannels : uint8_t {
26 single,
27 dual,
28};
29
33class TOAST_API Haptic : public Data {
34public:
35 explicit Haptic(const toml::table& table, Handle<Schema> schema = {});
36
37 [[nodiscard]]
38 auto type() const -> std::string_view override {
39 return "haptic";
40 }
41
42 [[nodiscard]]
43 auto mode() const noexcept -> HapticMode {
44 return m_mode;
45 }
46
47 [[nodiscard]]
48 auto priority() const noexcept -> int {
49 return m_priority;
50 }
51
52 [[nodiscard]]
53 auto durationMs() const noexcept -> uint32_t {
54 return m_duration_ms;
55 }
56
62 [[nodiscard]]
63 auto sample(float t) const -> glm::vec2;
64
65protected:
66 void onReloaded() override;
67
68private:
69 void readFields();
70
71 HapticMode m_mode = HapticMode::standard;
72 int m_priority = 0;
73 uint32_t m_duration_ms = 0;
74
75 // standard mode
76 float m_left = 0.0f;
77 float m_right = 0.0f;
78
79 // curve mode
80 HapticChannels m_channels = HapticChannels::single;
81 float m_pan = 0.0f;
82 float m_multiplier = 1.0f;
83 std::unique_ptr<Curve> m_curve;
84 std::unique_ptr<Curve> m_curve_right;
85};
86
87}
Type-safe smart pointer for assets.
Definition core_types.hpp:149
auto sample(float t) const -> glm::vec2
Samples the effect's motor intensities at a normalized playback time.
Definition haptic.cpp:113
Spline curve asset using tinyspline.
Typed data asset backed by schema-driven TOML.