Refactor ivrinput functions to be more generic

This commit is contained in:
Vasily
2019-01-19 16:42:49 +01:00
parent 1585322c9d
commit 8bcab9b2c0
5 changed files with 141 additions and 53 deletions
+42
View File
@@ -0,0 +1,42 @@
#pragma once
#include <openvr.h>
#include <easylogging++.h>
enum class ActionType
{
Undefined,
Digital,
};
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;
}
}
vr::VRActionHandle_t handle()
{
return m_handle;
}
const char* name()
{
return m_name;
}
ActionType type()
{
return m_type;
}
private:
vr::VRActionHandle_t m_handle = 0;
const char* m_name;
ActionType m_type = ActionType::Undefined;
};