SDraw / driver_leap

Self-sustainable fork of SteamVR driver for Leap Motion controller with updated vendor libraries
MIT License
121 stars 14 forks source link

Custom Gesture threshold #9

Closed LabeVR closed 3 days ago

LabeVR commented 1 week ago

I've experimented a bit with this repo and i found out that one of the problem with the gestures are the thresholds.

It would help a lot to have a custom slider that dictates the treshold at which a gesture is considered as one or not

Example in CLeapIndexController:

float touchThreshold = CDriverConfig::GetTouchThreshold();
float clickThreshold = CDriverConfig::GetClickThreshold();
float griptouchThreshold =  CDriverConfig::GetGripTouchThreshold();
/*^ this would have to be implemented in CDriverConfig.cpp and the Leap Control app ^*/

/*other code here*/

void CLeapIndexController::UpdateInput(const CLeapHand *p_hand)
{
    if(!CDriverConfig::IsControllerInputUsed())
    {
        /*code that assigns l_trigger based on gesture (pinch or finger bend)*/

        m_buttons[IB_TriggerTouch]->SetState(l_trigger >= touchThreshold)
        m_buttons[IB_TriggerClick]->SetState(l_trigger >= clickThreshold)

        float l_grabValue = p_hand->GetGrabValue();
        m_buttons[IB_GripValue]->SetValue(l_grabValue);
        m_buttons[IB_GripTouch]->SetState(l_grabValue >= griptouchThreshold);
        m_buttons[IB_GripForce]->SetValue(InverseLerp(l_grabValue, 0.9f, 1.f));

    }

where touchThreshold, clickThreshold and griptouchThreshold are floats that go from .0 to 1 inclusive

this could make it easier for the user to trigger the gestures (would also fix the pinch gesture being too sensitive as it would leave the choice to the user)

SDraw commented 1 week ago

Reasonable, will be added

LabeVR commented 1 week ago

Thank you very much ^^

SDraw commented 3 days ago

Implemented and improved in release 1.4-232.