Skip to content

Commit 8327ea2

Browse files
haoxvclaude
andauthored
Add option to use grab-and-move action for scrolling (#119)
* Add option to use grab-and-move action for scrolling * src/SettingsApp/HTCCSettingsApp.cpp * Add GrabMoveToScroll configuration option - Add new boolean config: GrabMoveToScroll (default: false) - Allows enabling/disabling grab move to scroll feature - Part of grab_move_scroll feature branch Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Add GrabMoveScrollScale configuration for scroll sensitivity Adds a configurable scale factor for grab-move-to-scroll gesture. Default is 1.0, DCS configured to 4.0 via registry override. * Make MSFS.reg and DCS.reg to be text * Update DCS.reg with UTF-8 coding * Update MSFS.reg transcode it to UTF-8 * Remove GrabMoveScroll from reg file --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent c788d48 commit 8327ea2

6 files changed

Lines changed: 51 additions & 6 deletions

File tree

reg/DCS.reg

54 Bytes
Binary file not shown.

src/APILayer/APILayer.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,8 @@ XrResult APILayer::xrWaitFrame(
345345
rightHand.mActions.mPrimary = r.mActions.mPrimary;
346346
rightHand.mActions.mSecondary = r.mActions.mSecondary;
347347
}
348-
if (Config::PinchToScroll) {
349-
leftHand.mActions.mValueChange = l.mActions.mValueChange;
350-
rightHand.mActions.mValueChange = r.mActions.mValueChange;
351-
}
348+
leftHand.mActions.mValueChange = l.mActions.mValueChange;
349+
rightHand.mActions.mValueChange = r.mActions.mValueChange;
352350
}
353351

354352
if (mPointCtrl) {

src/APILayer/HandTrackingSource.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,41 @@ void HandTrackingSource::UpdateHand(const FrameInfo& frameInfo, Hand* hand) {
345345
state.mPose = {};
346346
break;
347347
}
348+
349+
// --- Grab-and-Move Scroll Gesture ---
350+
if (Config::GrabMoveToScroll) {
351+
bool pinchActive = state.mActions.mPrimary;
352+
353+
if (pinchActive && state.mPose) {
354+
float currentY = state.mPose->position.y;
355+
356+
if (!hand->mScrolling) {
357+
// Start scroll mode
358+
hand->mScrolling = true;
359+
hand->mLastScrollY = currentY;
360+
} else {
361+
float delta = currentY - hand->mLastScrollY;
362+
363+
// Apply grab-and-move scroll scale for different applications
364+
delta *= Config::GrabMoveScrollScale;
365+
366+
// Threshold to avoid jitter
367+
constexpr float scrollThreshold = 0.01f;
368+
369+
if (delta > scrollThreshold) {
370+
state.mActions.mValueChange = ActionState::ValueChange::Increase;
371+
hand->mLastScrollY = currentY;
372+
} else if (delta < -scrollThreshold) {
373+
state.mActions.mValueChange = ActionState::ValueChange::Decrease;
374+
hand->mLastScrollY = currentY;
375+
}
376+
}
377+
} else {
378+
// Pinch released → stop scrolling
379+
hand->mScrolling = false;
380+
hand->mLastScrollY = 0.0f;
381+
}
382+
}
348383
}
349384

350385
void HandTrackingSource::InitHandTracker(Hand* hand) {

src/APILayer/HandTrackingSource.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ class HandTrackingSource final : public InputSource {
4545

4646
ActionState mRawActions {};
4747
XrTime mRawActionsSince {};
48+
49+
// --- Added for grab‑and‑move scroll ---
50+
float mLastScrollY = 0.0f;
51+
bool mScrolling = false;
4852
};
4953

5054
bool mHibernating {false};

src/SettingsApp/HTCCSettingsApp.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,15 @@ static void OpenXRGUI() {
270270
HTCC::Config::SavePinchToClick();
271271
}
272272

273-
if (ToggleSwitch(&HTCC::Config::PinchToScroll).Caption("Pinch to scroll")) {
273+
if (ToggleSwitch(&HTCC::Config::PinchToScroll)
274+
.Caption("Pinch to scroll")) {
274275
HTCC::Config::SavePinchToScroll();
275276
}
277+
278+
if (ToggleSwitch(&HTCC::Config::GrabMoveToScroll)
279+
.Caption("Grab and move to scroll")) {
280+
HTCC::Config::SaveGrabMoveToScroll();
281+
}
276282
}
277283

278284
EndVStackPanel();
@@ -469,4 +475,4 @@ int WINAPI wWinMain(
469475
},
470476
},
471477
});
472-
}
478+
}

src/lib/Config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ enum class HandTrackingHands : DWORD {
6666
IT(XrHandJointEXT, HandTrackingAimJoint, XR_HAND_JOINT_INDEX_PROXIMAL_EXT) \
6767
IT(bool, PinchToClick, true) \
6868
IT(bool, PinchToScroll, true) \
69+
IT(bool, GrabMoveToScroll, false) \
6970
IT(uint16_t, ShortPressLongPressMilliseconds, 200) \
7071
IT(uint16_t, ScrollWheelDelayMilliseconds, 600) \
7172
IT(uint16_t, ScrollWheelIntervalMilliseconds, 50) \
@@ -150,6 +151,7 @@ enum class HandTrackingHands : DWORD {
150151
IT(HandTrackingActionHFOV, std::numbers::pi_v<float> / 2) \
151152
IT(HandTrackingHibernateCutoff, std::numbers::pi_v<float> / 8) \
152153
IT(SmoothingFactor, 1.0f) \
154+
IT(GrabMoveScrollScale, 1.0f) \
153155
IT(LeftEyeFOVLeft, 0.0f) \
154156
IT(LeftEyeFOVRight, 0.0f) \
155157
IT(LeftEyeFOVUp, 0.0f) \

0 commit comments

Comments
 (0)