Move ivrinput into openvr folder

Doesn't make sense for it to have it's own folder when there's an openvr
folder now.
This commit is contained in:
Vasily
2019-03-10 23:12:26 +01:00
committed by username223
parent b7ff972997
commit dd5ae97b62
8 changed files with 7 additions and 8 deletions
+66
View File
@@ -0,0 +1,66 @@
#pragma once
#include <openvr.h>
#include <easylogging++.h>
namespace input
{
/*!
The type of function that should be called to get data for the action.
The IVRInput API does not give explicit warnings when the wrong functions are
called. This enum is an attempt at runtime checking.
*/
enum class ActionType
{
Undefined,
Digital,
Analog,
};
/*!
Represents a single action from the actions manifest. Should be instantiated
with a name similar to that of the one in the actions manifest.
*/
class Action
{
public:
Action( const char* const actionName, const ActionType type )
: m_name( actionName ), m_type( type )
{
auto error = vr::VRInput()->GetActionHandle( actionName, &m_handle );
if ( error != vr::EVRInputError::VRInputError_None )
{
LOG( ERROR ) << "Error getting handle for '" << actionName
<< "'. OpenVR Error: " << error;
}
}
/*!
An API internal handle that identifies an action.
*/
vr::VRActionHandle_t handle() const noexcept
{
return m_handle;
}
/*!
The actions manfiest name of the action. Used for error reporting.
*/
std::string name() const noexcept
{
return m_name;
}
/*!
The type of the action. Used for runtime checking that the wrong functions
aren't called.
*/
ActionType type() const noexcept
{
return m_type;
}
private:
vr::VRActionHandle_t m_handle = 0;
const std::string m_name;
const ActionType m_type = ActionType::Undefined;
};
} // namespace input