mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 12:49:56 +00:00
c3a312f80d
commit d8564b8e501c98fa2e3cde582b8d06d7c78ba6ce Author: Mads Buvik Sandvei <madssandvei@protonmail.com> Date: Fri Oct 16 23:43:39 2020 +0200 bad assignment commit 84f66e4bf1050ce8a316a27f8b10dc2243e35406 Author: Mads Buvik Sandvei <madssandvei@protonmail.com> Date: Fri Oct 16 21:08:27 2020 +0200 Removed the approach of abstracting xr paths with enums. It is not turning out to be useful. Use the explicit paths instead. Added some default bindings for most currently available controllers, except the xbox controller. commit ae525d0a239c087a7344528634a078e0812af66d Author: Mads Buvik Sandvei <madssandvei@protonmail.com> Date: Fri Oct 16 21:05:37 2020 +0200 Cleaned up openxr extensions code. Upgraded openxr to version 1.0.12 to enable support for certain controllers. commit 2d71a5ecbf699c59f1fcdbebcad867fd28552929 Author: Mads Buvik Sandvei <madssandvei@protonmail.com> Date: Thu Sep 24 22:18:25 2020 +0200 simple_controller
98 lines
3.1 KiB
C++
98 lines
3.1 KiB
C++
#ifndef VR_INPUT_MANAGER_HPP
|
|
#define VR_INPUT_MANAGER_HPP
|
|
|
|
#include "vrtypes.hpp"
|
|
|
|
#include "../mwinput/inputmanagerimp.hpp"
|
|
|
|
#include <vector>
|
|
#include <array>
|
|
#include <iostream>
|
|
|
|
#include "../mwworld/ptr.hpp"
|
|
|
|
namespace MWVR
|
|
{
|
|
struct OpenXRInput;
|
|
struct OpenXRActionSet;
|
|
|
|
namespace RealisticCombat {
|
|
class StateMachine;
|
|
}
|
|
|
|
/// Extension of the input manager to include VR inputs
|
|
class VRInputManager : public MWInput::InputManager
|
|
{
|
|
public:
|
|
VRInputManager(
|
|
SDL_Window* window,
|
|
osg::ref_ptr<osgViewer::Viewer> viewer,
|
|
osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCaptureHandler,
|
|
osgViewer::ScreenCaptureHandler::CaptureOperation* screenCaptureOperation,
|
|
const std::string& userFile, bool userFileExists,
|
|
const std::string& userControllerBindingsFile,
|
|
const std::string& controllerBindingsFile, bool grab);
|
|
|
|
virtual ~VRInputManager();
|
|
|
|
/// Overriden to force vr modes such as hiding cursors and crosshairs
|
|
virtual void changeInputMode(bool guiMode);
|
|
|
|
/// Overriden to update XR inputs
|
|
virtual void update(float dt, bool disableControls = false, bool disableEvents = false);
|
|
|
|
/// Current head offset from character position
|
|
osg::Vec3 headOffset() const { return mHeadOffset; };
|
|
|
|
/// Update head offset. Should only be called by the movement solver when reducing head offset.
|
|
void setHeadOffset(osg::Vec3 offset) { mHeadOffset = offset; };
|
|
|
|
/// Quaternion that aligns VR stage coordinates with world coordinates.
|
|
osg::Quat stageRotation();
|
|
|
|
/// Set current offset to 0 and re-align VR stage.
|
|
void requestRecenter();
|
|
|
|
/// Tracking pose of the given limb at the given predicted time
|
|
Pose getLimbPose(int64_t time, TrackedLimb limb);
|
|
|
|
/// Currently active action set
|
|
OpenXRActionSet& activeActionSet();
|
|
|
|
protected:
|
|
void updateHead();
|
|
|
|
void processAction(const class Action* action, float dt, bool disableControls);
|
|
|
|
void updateActivationIndication(void);
|
|
void pointActivation(bool onPress);
|
|
|
|
void injectMousePress(int sdlButton, bool onPress);
|
|
void injectChannelValue(MWInput::Actions action, float value);
|
|
|
|
void applyHapticsLeftHand(float intensity) override;
|
|
void applyHapticsRightHand(float intensity) override;
|
|
|
|
private:
|
|
void suggestBindingsSimple();
|
|
void suggestBindingsOculusTouch();
|
|
void suggestBindingsHpMixedReality();
|
|
void suggestBindingsMicrosoftMixedReality();
|
|
void suggestBindingsIndex();
|
|
void suggestBindingsVive();
|
|
void suggestBindingsXboxController();
|
|
|
|
std::unique_ptr<OpenXRInput> mXRInput;
|
|
std::unique_ptr<RealisticCombat::StateMachine> mRealisticCombat;
|
|
Pose mHeadPose{};
|
|
osg::Vec3 mHeadOffset{ 0,0,0 };
|
|
bool mShouldRecenter{ true };
|
|
bool mActivationIndication{ false };
|
|
bool mHapticsEnabled{ true };
|
|
float mYaw{ 0.f };
|
|
|
|
float mVrAngles[3]{ 0.f,0.f,0.f };
|
|
};
|
|
}
|
|
|
|
#endif
|