forked from WEARTHaptics/WEART-SDK-Cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeArtForce.h
43 lines (34 loc) · 874 Bytes
/
WeArtForce.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* WEART - Force struct
* https://www.weart.it/
*/
#pragma once
#include "WeArtCommon.h"
//! @brief Force value to be applied to an effect
struct WeArtForce {
public:
WeArtForce() : active(false), _value(DefaultValue) {};
WeArtForce(bool active, float force) {
this->active = active;
value(force);
}
static constexpr float DefaultValue = 0.0f;
static constexpr float MinValue = 0.0f;
static constexpr float MaxValue = 1.0f;
bool active;
//! @brief Force value getter
//! @return the force value
float value() const {
return _value;
}
//! @brief Force value setter
//! @param force Value to set
void value(float force) {
_value = force <= MinValue ? MinValue : force >= MaxValue ? MaxValue : force;
}
bool operator== (const WeArtForce& other) {
return (active == other.active && _value == other.value());
};
private:
float _value;
};