Update to spice2x-25-04-25 (pre-apply)
> broken commit
This commit is contained in:
+59
-2
@@ -3,6 +3,7 @@
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <queue>
|
||||
|
||||
#define ANALOG_HISTORY_CNT 10
|
||||
#define M_TAU (2 * M_PI)
|
||||
@@ -22,7 +23,7 @@ class Analog {
|
||||
private:
|
||||
std::string name;
|
||||
std::string device_identifier = "";
|
||||
unsigned short index = 0xFF;
|
||||
unsigned short index = USHRT_MAX;
|
||||
float sensitivity = 1.f;
|
||||
float deadzone = 0.f;
|
||||
bool deadzone_mirror = false;
|
||||
@@ -30,7 +31,7 @@ private:
|
||||
float last_state = 0.5f;
|
||||
bool sensitivity_set = false;
|
||||
bool deadzone_set = false;
|
||||
|
||||
|
||||
// smoothing function
|
||||
bool smoothing = false;
|
||||
std::array<AnalogMovingAverage, ANALOG_HISTORY_CNT> vector_history;
|
||||
@@ -41,8 +42,22 @@ private:
|
||||
float previous_raw_rads = 0.f;
|
||||
float adjusted_rads = 0.f;
|
||||
|
||||
// multiplier/divisor
|
||||
int multiplier = 1;
|
||||
float divisor_previous_value = 0.5f;
|
||||
unsigned short divisor_region = 0;
|
||||
|
||||
// relative input mode
|
||||
float absolute_value_for_rel_mode = 0.5f;
|
||||
bool relative_mode = false;
|
||||
|
||||
// circular buffer (delayed input)
|
||||
int delay_buffer_depth = 0;
|
||||
std::queue<float> delay_buffer;
|
||||
|
||||
float calculateAngularDifference(float old_rads, float new_rads);
|
||||
float normalizeAngle(float rads);
|
||||
float normalizeAnalogValue(float value);
|
||||
|
||||
public:
|
||||
|
||||
@@ -57,6 +72,8 @@ public:
|
||||
std::string getDisplayString(rawinput::RawInputManager* manager);
|
||||
float getSmoothedValue(float raw_rads);
|
||||
float applyAngularSensitivity(float raw_rads);
|
||||
float applyMultiplier(float raw_value);
|
||||
float applyDeadzone(float raw_value);
|
||||
|
||||
inline bool isSet() {
|
||||
if (this->override_enabled) {
|
||||
@@ -72,6 +89,9 @@ public:
|
||||
setDeadzone(0.f);
|
||||
invert = false;
|
||||
smoothing = false;
|
||||
setMultiplier(1);
|
||||
setRelativeMode(false);
|
||||
setDelayBufferDepth(0);
|
||||
}
|
||||
|
||||
inline const std::string &getName() const {
|
||||
@@ -144,6 +164,16 @@ public:
|
||||
this->smoothing = smoothing;
|
||||
}
|
||||
|
||||
inline int getMultiplier() const {
|
||||
return this->multiplier;
|
||||
}
|
||||
|
||||
inline void setMultiplier(int multiplier) {
|
||||
this->multiplier = multiplier;
|
||||
this->divisor_region = 0;
|
||||
this->divisor_previous_value = 0.5f;
|
||||
}
|
||||
|
||||
inline float getLastState() const {
|
||||
return this->last_state;
|
||||
}
|
||||
@@ -151,4 +181,31 @@ public:
|
||||
inline void setLastState(float last_state) {
|
||||
this->last_state = last_state;
|
||||
}
|
||||
|
||||
inline bool isRelativeMode() const {
|
||||
return this->relative_mode;
|
||||
}
|
||||
|
||||
inline void setRelativeMode(bool relative_mode) {
|
||||
this->relative_mode = relative_mode;
|
||||
this->absolute_value_for_rel_mode = 0.5f;
|
||||
}
|
||||
|
||||
inline float getAbsoluteValue(float relative_delta) {
|
||||
this->absolute_value_for_rel_mode =
|
||||
normalizeAnalogValue(this->absolute_value_for_rel_mode + relative_delta);
|
||||
return this->absolute_value_for_rel_mode;
|
||||
}
|
||||
|
||||
inline int getDelayBufferDepth() const {
|
||||
return this->delay_buffer_depth;
|
||||
}
|
||||
|
||||
inline void setDelayBufferDepth(int depth) {
|
||||
this->delay_buffer_depth = depth;
|
||||
}
|
||||
|
||||
inline std::queue<float> &getDelayBuffer() {
|
||||
return this->delay_buffer;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user