mirror of
https://github.com/ddeverill/SteamlessController.git
synced 2026-10-23 07:02:16 -05:00
Tick a directional pad on direction changes, not on distance
Phase 4 of the v1.20 trackpad work. The movement haptic ticks once per 6500 units of travel, which is the right feedback for a pad steering a pointer and the wrong one for a pad being used as a d-pad: distance means nothing there, so sliding around inside a single direction buzzes continuously for no event, while rolling from one direction to the next — the only thing that actually happens — gets no acknowledgement at all. A directional pad now ticks once per direction change instead, which is the detent a d-pad gives. Only between two directions: arriving from nothing is the press and going back to nothing is the release, and both already fire their own click haptic. That tick sits outside the distance gates rather than among them. Every one of those would suppress it — directions only change while the click is held, and the gates exist precisely to stop a press bleeding a tick into the click haptic. A single button reports no movement at all, so it ticks for nothing. The other three modes are untouched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a4c6475e84
commit
536536950e
1 file changed
+36
-2
@@ -1116,9 +1116,43 @@ void ControllerManager::ReadLoop(Slot* slot) {
|
||||
static constexpr float TRACKPAD_TICK_MAX_AREA = 900.0f;
|
||||
static constexpr float TRACKPAD_TICK_MAX_STEP = 4000.0f;
|
||||
|
||||
// What a movement tick means depends on what the pad is for.
|
||||
//
|
||||
// A directional pad ticks once per direction change, which is
|
||||
// the detent a d-pad gives when the thumb rolls from one
|
||||
// direction to the next. Distance means nothing to it: sliding
|
||||
// around inside a single direction changes nothing, and would
|
||||
// buzz continuously for no event at all.
|
||||
//
|
||||
// Deliberately outside the distance gates below, all of which
|
||||
// would suppress it — directions only change while the click
|
||||
// is held, and those gates exist to keep a press from bleeding
|
||||
// a tick into the click haptic.
|
||||
//
|
||||
// Only between two directions: coming from nothing is the
|
||||
// press and going back to nothing is the release, and both
|
||||
// already fire their own click haptic.
|
||||
auto directionTick = [&](bool leftPad, uint8_t prev, uint8_t now) {
|
||||
if (prev != DirNone && now != DirNone && prev != now)
|
||||
slot->sc->TickTrackpadMovement(leftPad);
|
||||
};
|
||||
const bool rightIsDpad = m_profile.rightPad.IsDirectionalPad();
|
||||
const bool leftIsDpad = m_profile.leftPad.IsDirectionalPad();
|
||||
if (rightIsDpad)
|
||||
directionTick(false, slot->prevRightDirs, resolved.rightDirs);
|
||||
if (leftIsDpad)
|
||||
directionTick(true, slot->prevLeftDirs, resolved.leftDirs);
|
||||
|
||||
// A single button has no movement to report on at all, and a
|
||||
// directional pad has already had its say above.
|
||||
const bool rightWantsDistance =
|
||||
!rightIsDpad && m_profile.rightPad.mode != TrackpadMode::SingleButton;
|
||||
const bool leftWantsDistance =
|
||||
!leftIsDpad && m_profile.leftPad.mode != TrackpadMode::SingleButton;
|
||||
|
||||
// Gate on the latch state, not the raw click bit — while the
|
||||
// click is held (even if the bit chatters low), no ticks.
|
||||
if (rt && slot->hapticWasRightTouching && !rc
|
||||
if (rightWantsDistance && rt && slot->hapticWasRightTouching && !rc
|
||||
&& slot->hapticRightClickState == Slot::ClickState::WaitingForPress
|
||||
&& slot->hapticRightTouchGrace == 0) {
|
||||
const float dx = static_cast<float>(rx - slot->hapticPrevRightX);
|
||||
@@ -1159,7 +1193,7 @@ void ControllerManager::ReadLoop(Slot* slot) {
|
||||
slot->hapticPrevRightY = ry;
|
||||
}
|
||||
}
|
||||
if (lt && slot->hapticWasLeftTouching && !lc
|
||||
if (leftWantsDistance && lt && slot->hapticWasLeftTouching && !lc
|
||||
&& slot->hapticLeftClickState == Slot::ClickState::WaitingForPress
|
||||
&& slot->hapticLeftTouchGrace == 0) {
|
||||
const float dx = static_cast<float>(lx - slot->hapticPrevLeftX);
|
||||
|
||||
Reference in new issue
Block a user