Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified reg/DCS.reg
Binary file not shown.
6 changes: 2 additions & 4 deletions src/APILayer/APILayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,8 @@ XrResult APILayer::xrWaitFrame(
rightHand.mActions.mPrimary = r.mActions.mPrimary;
rightHand.mActions.mSecondary = r.mActions.mSecondary;
}
if (Config::PinchToScroll) {
leftHand.mActions.mValueChange = l.mActions.mValueChange;
rightHand.mActions.mValueChange = r.mActions.mValueChange;
}
leftHand.mActions.mValueChange = l.mActions.mValueChange;
rightHand.mActions.mValueChange = r.mActions.mValueChange;
}

if (mPointCtrl) {
Expand Down
35 changes: 35 additions & 0 deletions src/APILayer/HandTrackingSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,41 @@ void HandTrackingSource::UpdateHand(const FrameInfo& frameInfo, Hand* hand) {
state.mPose = {};
break;
}

// --- Grab-and-Move Scroll Gesture ---
if (Config::GrabMoveToScroll) {
bool pinchActive = state.mActions.mPrimary;

if (pinchActive && state.mPose) {
float currentY = state.mPose->position.y;

if (!hand->mScrolling) {
// Start scroll mode
hand->mScrolling = true;
hand->mLastScrollY = currentY;
} else {
float delta = currentY - hand->mLastScrollY;

// Apply grab-and-move scroll scale for different applications
delta *= Config::GrabMoveScrollScale;

// Threshold to avoid jitter
constexpr float scrollThreshold = 0.01f;

if (delta > scrollThreshold) {
state.mActions.mValueChange = ActionState::ValueChange::Increase;
hand->mLastScrollY = currentY;
} else if (delta < -scrollThreshold) {
state.mActions.mValueChange = ActionState::ValueChange::Decrease;
hand->mLastScrollY = currentY;
}
}
} else {
// Pinch released → stop scrolling
hand->mScrolling = false;
hand->mLastScrollY = 0.0f;
}
}
}

void HandTrackingSource::InitHandTracker(Hand* hand) {
Expand Down
4 changes: 4 additions & 0 deletions src/APILayer/HandTrackingSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class HandTrackingSource final : public InputSource {

ActionState mRawActions {};
XrTime mRawActionsSince {};

// --- Added for grab‑and‑move scroll ---
float mLastScrollY = 0.0f;
bool mScrolling = false;
};

bool mHibernating {false};
Expand Down
10 changes: 8 additions & 2 deletions src/SettingsApp/HTCCSettingsApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,15 @@ static void OpenXRGUI() {
HTCC::Config::SavePinchToClick();
}

if (ToggleSwitch(&HTCC::Config::PinchToScroll).Caption("Pinch to scroll")) {
if (ToggleSwitch(&HTCC::Config::PinchToScroll)
.Caption("Pinch to scroll")) {
HTCC::Config::SavePinchToScroll();
}

if (ToggleSwitch(&HTCC::Config::GrabMoveToScroll)
.Caption("Grab and move to scroll")) {
HTCC::Config::SaveGrabMoveToScroll();
}
}

EndVStackPanel();
Expand Down Expand Up @@ -469,4 +475,4 @@ int WINAPI wWinMain(
},
},
});
}
}
2 changes: 2 additions & 0 deletions src/lib/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ enum class HandTrackingHands : DWORD {
IT(XrHandJointEXT, HandTrackingAimJoint, XR_HAND_JOINT_INDEX_PROXIMAL_EXT) \
IT(bool, PinchToClick, true) \
IT(bool, PinchToScroll, true) \
IT(bool, GrabMoveToScroll, false) \
IT(uint16_t, ShortPressLongPressMilliseconds, 200) \
IT(uint16_t, ScrollWheelDelayMilliseconds, 600) \
IT(uint16_t, ScrollWheelIntervalMilliseconds, 50) \
Expand Down Expand Up @@ -150,6 +151,7 @@ enum class HandTrackingHands : DWORD {
IT(HandTrackingActionHFOV, std::numbers::pi_v<float> / 2) \
IT(HandTrackingHibernateCutoff, std::numbers::pi_v<float> / 8) \
IT(SmoothingFactor, 1.0f) \
IT(GrabMoveScrollScale, 1.0f) \
IT(LeftEyeFOVLeft, 0.0f) \
IT(LeftEyeFOVRight, 0.0f) \
IT(LeftEyeFOVUp, 0.0f) \
Expand Down