diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 8c3ae30169..4c85590107 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -205,53 +205,55 @@ void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(con } //motion control - bool activate; - for (int j = 0; j < 2; j++) { - float limit = 0.5f; //length of needed movement in meters - XrVector3f axis = {0, 1, 0}; - float center = ToRadians((float)VR_GetConfig(VR_CONFIG_MENU_YAW)); - XrQuaternionf orientation = XrQuaternionf_CreateFromVectorAngle(axis, center); - XrVector3f position = XrQuaternionf_Rotate(orientation, IN_VRGetPose(j).position); + if (g_Config.bEnableMotions) { + for (int j = 0; j < 2; j++) { + bool activate; + float limit = 0.5f; //length of needed movement in meters + XrVector3f axis = {0, 1, 0}; + float center = ToRadians((float)VR_GetConfig(VR_CONFIG_MENU_YAW)); + XrQuaternionf orientation = XrQuaternionf_CreateFromVectorAngle(axis, center); + XrVector3f position = XrQuaternionf_Rotate(orientation, IN_VRGetPose(j).position); - //up - activate = position.y > limit; - keyInput.flags = activate ? KEY_DOWN : KEY_UP; - keyInput.keyCode = NKCODE_EXT_MOTION_UP; - keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][0] != activate) NativeKey(keyInput); - controllerMotion[j][0] = activate; + //up + activate = position.y > limit; + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_UP; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][0] != activate) NativeKey(keyInput); + controllerMotion[j][0] = activate; - //down - activate = position.y < -limit * 1.5f; - keyInput.flags = activate ? KEY_DOWN : KEY_UP; - keyInput.keyCode = NKCODE_EXT_MOTION_DOWN; - keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][1] != activate) NativeKey(keyInput); - controllerMotion[j][1] = activate; + //down + activate = position.y < -limit * 1.5f; + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_DOWN; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][1] != activate) NativeKey(keyInput); + controllerMotion[j][1] = activate; - //left - activate = position.x < -limit * (j == 0 ? 1.0f : 0.25f); - keyInput.flags = activate ? KEY_DOWN : KEY_UP; - keyInput.keyCode = NKCODE_EXT_MOTION_LEFT; - keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][2] != activate) NativeKey(keyInput); - controllerMotion[j][2] = activate; + //left + activate = position.x < -limit * (j == 0 ? 1.0f : 0.25f); + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_LEFT; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][2] != activate) NativeKey(keyInput); + controllerMotion[j][2] = activate; - //right - activate = position.x > limit * (j == 1 ? 1.0f : 0.25f); - keyInput.flags = activate ? KEY_DOWN : KEY_UP; - keyInput.keyCode = NKCODE_EXT_MOTION_RIGHT; - keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][3] != activate) NativeKey(keyInput); - controllerMotion[j][3] = activate; + //right + activate = position.x > limit * (j == 1 ? 1.0f : 0.25f); + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_RIGHT; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][3] != activate) NativeKey(keyInput); + controllerMotion[j][3] = activate; - //forward - activate = position.z < -limit; - keyInput.flags = activate ? KEY_DOWN : KEY_UP; - keyInput.keyCode = NKCODE_EXT_MOTION_FORWARD; - keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][4] != activate) NativeKey(keyInput); - controllerMotion[j][4] = activate; + //forward + activate = position.z < -limit; + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_FORWARD; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][4] != activate) NativeKey(keyInput); + controllerMotion[j][4] = activate; + } } //mouse cursor diff --git a/Core/Config.cpp b/Core/Config.cpp index f62a4baaae..94f96d15ad 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1208,6 +1208,7 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VREnable", &g_Config.bEnableVR, true), ConfigSetting("VREnable6DoF", &g_Config.bEnable6DoF, true), ConfigSetting("VREnableStereo", &g_Config.bEnableStereo, false), + ConfigSetting("VREnableMotions", &g_Config.bEnableMotions, true), ConfigSetting("VRCameraDistance", &g_Config.fCameraDistance, 0.0f), ConfigSetting("VRCameraHeight", &g_Config.fCameraHeight, 0.0f), ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f), diff --git a/Core/Config.h b/Core/Config.h index a494cf4c61..3415cc55e0 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -463,6 +463,7 @@ public: bool bEnableVR; bool bEnable6DoF; bool bEnableStereo; + bool bEnableMotions; float fCameraDistance; float fCameraHeight; float fCameraSide; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 6b68d9c866..a7044d946f 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1163,6 +1163,8 @@ void GameSettingsScreen::CreateViews() { vr6DoF->SetEnabledPtr(&g_Config.bEnableVR); CheckBox *vrStereo = vrSettings->Add(new CheckBox(&g_Config.bEnableStereo, vr->T("Stereoscopic vision (Experimental)"))); vrStereo->SetEnabledPtr(&g_Config.bEnableVR); + CheckBox *vrMotions = vrSettings->Add(new CheckBox(&g_Config.bEnableMotions, vr->T("Map controller movements to keys"))); + vrMotions->SetEnabledPtr(&g_Config.bEnableVR); vrSettings->Add(new ItemHeader(vr->T("VR camera"))); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraDistance, -10.0f, 10.0f, vr->T("Camera distance adjust", "Camera distance adjust"), 1.0f, screenManager(), ""));