mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
gitadora: various fixes for wailing (#513)
## Link to GitHub Issue, if one exists Fixes #512 ## Description of change Fix digital wailing not being recognized consistently. Also address the fact that wailing was completely broken when lefty mode was on. This requires a new option that the user needs to check off in the configurator since we can't magically guess if the user is holding the guitar in lefty mode. - [x] fix downward wail - [x] digital lefty mode - [x] implement all of this for arena model i/o - [x] test dx cab 2p - [x] lefty toggle in overlay - [x] fix analog not working for 2p guitar - [ ] analog lefty mode? ## Testing Checked GW and GW Delta
This commit is contained in:
@@ -84,4 +84,63 @@ namespace socd {
|
||||
return SocdNone;
|
||||
}
|
||||
}
|
||||
|
||||
// first dimension: p1/p2
|
||||
// second dimension: TiltUp / TiltDown
|
||||
// value: last timestamp when it was on
|
||||
static double most_recent_active[2][2] = {};
|
||||
|
||||
uint32_t TILT_HOLD_MS = 100;
|
||||
|
||||
TiltResult get_guitar_wail(uint8_t device, bool up, bool down, double time_now) {
|
||||
if (device >= 2) {
|
||||
log_fatal("socd", "invalid device index in socd_clean: {}", device);
|
||||
}
|
||||
|
||||
const auto socd_result = socd_clean(device, up, down, time_now);
|
||||
|
||||
if (up) {
|
||||
most_recent_active[device][TiltUp] = time_now;
|
||||
}
|
||||
if (down) {
|
||||
most_recent_active[device][TiltDown] = time_now;
|
||||
}
|
||||
|
||||
log_debug(
|
||||
"socd",
|
||||
"p{} wail up={}, down={}",
|
||||
device + 1,
|
||||
most_recent_active[device][TiltUp],
|
||||
most_recent_active[device][TiltDown]);
|
||||
|
||||
const auto delta_up = time_now - most_recent_active[device][TiltUp];
|
||||
const auto delta_down = time_now - most_recent_active[device][TiltDown];
|
||||
const bool is_up = delta_up <= TILT_HOLD_MS;
|
||||
const bool is_down = delta_down <= TILT_HOLD_MS;
|
||||
|
||||
auto result = TiltNone;
|
||||
if (is_up && is_down) {
|
||||
// both held recently: prefer more recently held using SOCD logic
|
||||
if (socd_result == SocdCCW) {
|
||||
result = TiltUp;
|
||||
} else if (socd_result == SocdCW) {
|
||||
result = TiltDown;
|
||||
} else {
|
||||
result = TiltUp;
|
||||
}
|
||||
} else if (is_up) {
|
||||
result = TiltUp;
|
||||
} else if (is_down) {
|
||||
result = TiltDown;
|
||||
}
|
||||
|
||||
// clear opposite direction being held
|
||||
if (result == TiltUp) {
|
||||
most_recent_active[device][TiltDown] = 0.f;
|
||||
} else if (result == TiltDown) {
|
||||
most_recent_active[device][TiltUp] = 0.f;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
namespace socd {
|
||||
|
||||
// SOCD for knobs / turntables
|
||||
|
||||
enum class SocdAlgorithm {
|
||||
Neutral,
|
||||
PreferRecent,
|
||||
@@ -19,4 +21,16 @@ namespace socd {
|
||||
} SocdResult;
|
||||
|
||||
SocdResult socd_clean(uint8_t device, bool ccw, bool cw, double time_now);
|
||||
|
||||
// for guitar wail (up/down only)
|
||||
|
||||
extern uint32_t TILT_HOLD_MS;
|
||||
|
||||
typedef enum _TiltResult {
|
||||
TiltUp = 0,
|
||||
TiltDown = 1,
|
||||
TiltNone = 2
|
||||
} TiltResult;
|
||||
|
||||
TiltResult get_guitar_wail(uint8_t device, bool up, bool down, double time_now);
|
||||
}
|
||||
Reference in New Issue
Block a user