OpenXR - Vertical HMD rotation to keys cleanup

This commit is contained in:
Lubos 2023-03-09 11:22:54 +01:00
parent 6bcf65d526
commit b1f41c44fe
4 changed files with 7 additions and 27 deletions

View File

@ -315,7 +315,7 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) {
}
// Head control
if (g_Config.iHeadRotation) {
if (g_Config.bHeadRotationEnabled) {
float pitch = -VR_GetHMDAngles().x;
float yaw = -VR_GetHMDAngles().y;
bool disable = vrFlatForced || appMode == VR_MENU_MODE;
@ -342,25 +342,6 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) {
float limit = isVR ? g_Config.fHeadRotationScale : 20;
keyInput.deviceId = DEVICE_ID_XR_HMD;
// vertical rotations
if (g_Config.iHeadRotation == 2) {
//up
activate = !disable && pitch > limit;
keyInput.flags = activate ? KEY_DOWN : KEY_UP;
keyInput.keyCode = NKCODE_EXT_ROTATION_UP;
if (hmdMotion[0] != activate) NativeKey(keyInput);
if (isVR && activate) hmdMotionDiff[0] -= limit;
hmdMotion[0] = activate;
//down
activate = !disable && pitch < -limit;
keyInput.flags = activate ? KEY_DOWN : KEY_UP;
keyInput.keyCode = NKCODE_EXT_ROTATION_DOWN;
if (hmdMotion[1] != activate) NativeKey(keyInput);
if (isVR && activate) hmdMotionDiff[0] += limit;
hmdMotion[1] = activate;
}
//left
activate = !disable && yaw < -limit;
keyInput.flags = activate ? KEY_DOWN : KEY_UP;
@ -690,8 +671,7 @@ bool StartVRRender() {
float mRoll = mz * ToRadians(rotation.z);
// use in-game camera interpolated rotation
if (g_Config.iHeadRotation >= 2) mPitch = -mx * ToRadians(hmdMotionDiffLast[0]); // vertical
if (g_Config.iHeadRotation >= 1) mYaw = -my * ToRadians(hmdMotionDiffLast[1]); // horizontal
if (g_Config.bHeadRotationEnabled) mYaw = -my * ToRadians(hmdMotionDiffLast[1]); // horizontal
// create updated quaternion
XrQuaternionf pitch = XrQuaternionf_CreateFromVectorAngle({1, 0, 0}, mPitch);

View File

@ -1153,8 +1153,8 @@ static const ConfigSetting vrSettings[] = {
ConfigSetting("VRHeadUpDisplayScale", &g_Config.fHeadUpDisplayScale, 0.3f),
ConfigSetting("VRMotionLength", &g_Config.fMotionLength, 0.5f),
ConfigSetting("VRHeadRotationScale", &g_Config.fHeadRotationScale, 5.0f),
ConfigSetting("VRHeadRotationEnabled", &g_Config.bHeadRotationEnabled, false),
ConfigSetting("VRHeadRotationSmoothing", &g_Config.bHeadRotationSmoothing, false),
ConfigSetting("VRHeadRotation", &g_Config.iHeadRotation, false),
};
struct ConfigSectionSettings {

View File

@ -471,8 +471,8 @@ public:
float fHeadUpDisplayScale;
float fMotionLength;
float fHeadRotationScale;
bool bHeadRotationEnabled;
bool bHeadRotationSmoothing;
bool iHeadRotation;
// Debugger
int iDisasmWindowX;

View File

@ -1143,11 +1143,11 @@ void GameSettingsScreen::CreateVRSettings(UI::ViewGroup *vrSettings) {
vrSettings->Add(new ItemHeader(vr->T("Experts only")));
vrSettings->Add(new CheckBox(&g_Config.bManualForceVR, vr->T("Manual switching between flat screen and VR using SCREEN key")));
vrSettings->Add(new CheckBox(&g_Config.iHeadRotation, vr->T("Map HMD rotations on keys instead of VR camera")));
vrSettings->Add(new CheckBox(&g_Config.bHeadRotationEnabled, vr->T("Map HMD rotations on keys instead of VR camera")));
PopupSliderChoiceFloat *vrHeadRotationScale = vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fHeadRotationScale, 0.1f, 10.0f, vr->T("Game camera rotation step per frame"), 0.1f, screenManager(), "°"));
vrHeadRotationScale->SetEnabledFunc([&] { return g_Config.iHeadRotation > 0; });
vrHeadRotationScale->SetEnabledPtr(&g_Config.bHeadRotationEnabled);
CheckBox *vrHeadRotationSmoothing = vrSettings->Add(new CheckBox(&g_Config.bHeadRotationSmoothing, vr->T("Game camera uses rotation smoothing")));
vrHeadRotationSmoothing->SetEnabledFunc([&] { return g_Config.iHeadRotation > 0; });
vrHeadRotationSmoothing->SetEnabledPtr(&g_Config.bHeadRotationEnabled);
vrSettings->Add(new CheckBox(&g_Config.bEnableMotions, vr->T("Map controller movements to keys")));
PopupSliderChoiceFloat *vrMotions = vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fMotionLength, 0.3f, 1.0f, vr->T("Motion needed to generate action"), 0.1f, screenManager(), vr->T("m")));
vrMotions->SetEnabledPtr(&g_Config.bEnableMotions);