vr_session: Support for trackpad scrolling
This commit is contained in:
parent
baea00fb15
commit
29710fb2ec
2 changed files with 23 additions and 0 deletions
|
@ -89,6 +89,7 @@ const struct option *gamescope_options = (struct option[]){
|
|||
{ "vr-overlay-physical-width", required_argument, nullptr, 0 },
|
||||
{ "vr-overlay-physical-curvature", required_argument, nullptr, 0 },
|
||||
{ "vr-overlay-physical-pre-curve-pitch", required_argument, nullptr, 0 },
|
||||
{ "vr-scroll-speed", required_argument, nullptr, 0 },
|
||||
#endif
|
||||
|
||||
// wlserver options
|
||||
|
@ -195,6 +196,7 @@ const char usage[] =
|
|||
" --vr-overlay-physical-width Sets the physical width of our VR overlay in metres\n"
|
||||
" --vr-overlay-physical-curvature Sets the curvature of our VR overlay\n"
|
||||
" --vr-overlay-physical-pre-curve-pitch Sets the pre-curve pitch of our VR overlay\n"
|
||||
" --vr-scrolls-speed Mouse scrolling speed of trackpad scroll in VR. Default: 8.0\n"
|
||||
"\n"
|
||||
#endif
|
||||
"Debug options:\n"
|
||||
|
|
|
@ -31,6 +31,8 @@ struct OpenVRSession
|
|||
float flPhysicalWidth = 2.0f;
|
||||
float flPhysicalCurvature = 0.0f;
|
||||
float flPhysicalPreCurvePitch = 0.0f;
|
||||
float flScrollSpeed = 8.0f;
|
||||
float flScrollAccum[2] = { 0.0f, 0.0f };
|
||||
vr::VROverlayHandle_t hOverlay = vr::k_ulOverlayHandleInvalid;
|
||||
vr::VROverlayHandle_t hOverlayThumbnail = vr::k_ulOverlayHandleInvalid;
|
||||
struct wlserver_input_method *pIME = nullptr;
|
||||
|
@ -91,6 +93,8 @@ bool vr_init(int argc, char **argv)
|
|||
GetVR().flPhysicalCurvature = atof( optarg );
|
||||
} else if (strcmp(opt_name, "vr-overlay-physical-pre-curve-pitch") == 0) {
|
||||
GetVR().flPhysicalPreCurvePitch = atof( optarg );
|
||||
} else if (strcmp(opt_name, "vr-scroll-speed") == 0) {
|
||||
GetVR().flScrollSpeed = atof( optarg );
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
|
@ -144,6 +148,7 @@ bool vrsession_init()
|
|||
vr::VROverlay()->SetOverlayFlag( GetVR().hOverlay, vr::VROverlayFlags_EnableControlBarKeyboard, GetVR().bEnableControlBarKeyboard );
|
||||
vr::VROverlay()->SetOverlayFlag( GetVR().hOverlay, vr::VROverlayFlags_EnableControlBarClose, GetVR().bEnableControlBarClose );
|
||||
vr::VROverlay()->SetOverlayFlag( GetVR().hOverlay, vr::VROverlayFlags_WantsModalBehavior, GetVR().bModal );
|
||||
vr::VROverlay()->SetOverlayFlag( GetVR().hOverlay, vr::VROverlayFlags_SendVRSmoothScrollEvents, true );
|
||||
vrsession_update_touch_mode();
|
||||
|
||||
vr::VROverlay()->SetOverlayWidthInMeters( GetVR().hOverlay, GetVR().flPhysicalWidth );
|
||||
|
@ -315,6 +320,22 @@ static void vrsession_input_thread()
|
|||
break;
|
||||
}
|
||||
|
||||
case vr::VREvent_ScrollSmooth:
|
||||
{
|
||||
wlserver_lock();
|
||||
|
||||
GetVR().flScrollAccum[0] += -vrEvent.data.scroll.xdelta * GetVR().flScrollSpeed;
|
||||
GetVR().flScrollAccum[1] += -vrEvent.data.scroll.ydelta * GetVR().flScrollSpeed;
|
||||
|
||||
float dx, dy;
|
||||
GetVR().flScrollAccum[0] = modf( GetVR().flScrollAccum[0], &dx );
|
||||
GetVR().flScrollAccum[1] = modf( GetVR().flScrollAccum[1], &dy );
|
||||
|
||||
wlserver_mousewheel( dx, dy, timestamp );
|
||||
wlserver_unlock();
|
||||
break;
|
||||
}
|
||||
|
||||
case vr::VREvent_ButtonPress:
|
||||
{
|
||||
vr::EVRButtonId button = (vr::EVRButtonId)vrEvent.data.controller.button;
|
||||
|
|
Loading…
Reference in a new issue