2020-08-09 10:55:09 +00:00
|
|
|
#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;
|
|
|
|
|
2021-01-02 16:40:37 +00:00
|
|
|
OpenXRActionSet(const std::string& actionSetName, std::shared_ptr<AxisAction::Deadzone> deadzone);
|
2020-08-09 10:55:09 +00:00
|
|
|
|
|
|
|
//! 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:
|
2021-01-02 16:40:37 +00:00
|
|
|
template<typename A>
|
2020-08-09 10:55:09 +00:00
|
|
|
void createMWAction(int openMWAction, const std::string& actionName, const std::string& localName);
|
2021-01-02 16:40:37 +00:00
|
|
|
template<typename A>
|
|
|
|
void createMWAction(int openMWAction, const std::string& actionName, const std::string& localName, std::shared_ptr<AxisAction::Deadzone> deadzone);
|
2020-08-09 10:55:09 +00:00
|
|
|
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);
|
2020-10-17 10:33:46 +00:00
|
|
|
XrPath getXrPath(const std::string& path);
|
2020-08-09 10:55:09 +00:00
|
|
|
XrActionSet createActionSet(const std::string& name);
|
|
|
|
|
|
|
|
XrActionSet mActionSet{ nullptr };
|
|
|
|
std::string mLocalizedName{};
|
|
|
|
std::string mInternalName{};
|
2020-12-02 20:46:03 +00:00
|
|
|
std::map<std::string, std::unique_ptr<Action>> mActionMap;
|
2020-08-09 10:55:09 +00:00
|
|
|
std::map<TrackedLimb, std::unique_ptr<PoseAction>> mTrackerMap;
|
|
|
|
std::map<TrackedLimb, std::unique_ptr<HapticsAction>> mHapticsMap;
|
|
|
|
std::deque<const Action*> mActionQueue{};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|