1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 07:49:56 +00:00
openmw-tes3mp/apps/openmw/mwvr/openxractionset.hpp
Mads Buvik Sandvei c3a312f80d Squashed commit of the following:
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
2020-10-17 12:33:46 +02:00

53 lines
2 KiB
C++

#ifndef OPENXR_ACTIONSET_HPP
#define OPENXR_ACTIONSET_HPP
#include "vrinput.hpp"
#include <vector>
#include <array>
namespace MWVR
{
/// \brief Generates and manages an OpenXR ActionSet and associated actions.
class OpenXRActionSet
{
public:
using Actions = MWInput::Actions;
OpenXRActionSet(const std::string& actionSetName);
//! Update all controls and queue any actions
void updateControls();
//! Get next action from queue (repeat until null is returned)
const Action* nextAction();
//! Get current pose of limb in space.
Pose getLimbPose(int64_t time, TrackedLimb limb);
//! Apply haptics of the given intensity to the given limb
void applyHaptics(TrackedLimb limb, float intensity);
XrActionSet xrActionSet() { return mActionSet; };
void suggestBindings(std::vector<XrActionSuggestedBinding>& xrSuggestedBindings, const SuggestedBindings& mwSuggestedBindings);
protected:
template<typename A, XrActionType AT = A::ActionType>
void createMWAction(int openMWAction, const std::string& actionName, const std::string& localName);
void createPoseAction(TrackedLimb limb, const std::string& actionName, const std::string& localName);
void createHapticsAction(TrackedLimb limb, const std::string& actionName, const std::string& localName);
std::unique_ptr<OpenXRAction> createXRAction(XrActionType actionType, const std::string& actionName, const std::string& localName);
XrPath getXrPath(const std::string& path);
XrActionSet createActionSet(const std::string& name);
XrActionSet mActionSet{ nullptr };
std::string mLocalizedName{};
std::string mInternalName{};
std::map<int, std::unique_ptr<Action>> mActionMap;
std::map<TrackedLimb, std::unique_ptr<PoseAction>> mTrackerMap;
std::map<TrackedLimb, std::unique_ptr<HapticsAction>> mHapticsMap;
std::deque<const Action*> mActionQueue{};
};
}
#endif