Chaperone Tab Update (#101)

* added actions for haptics

* Haptic WIP #1 crash on haptic event

* haptics rough implemented

* fixed action names and prox sensor work-around

* added workaround to catch-all in begineer chaperone switch

* added idle work-around to alarm warning

* changed visibility slider values to reflect new API limits

* added disable chaperone

* added display Logic

* fixed visibility slider display and some saving fade distance when chaperone disabled

* fixed warnings not always working (hopefully) centralized action/input keys into ivrinput.h

* default bindings for HMD's

* chaperone input re-factor

* refactored ivrinput class

* fixed naming errors commented out prox testing

* formatting removed commented code

* format

* fixed compiler warnings

* updated documentation

* Reduced reload chaperone calls

* adjusted haptics for chaperone bounds warnings
This commit is contained in:
ykeara
2019-03-15 15:19:23 -05:00
committed by GitHub
parent 55b6d5de66
commit 3c5cab72e5
14 changed files with 425 additions and 77 deletions
+61 -27
View File
@@ -123,56 +123,57 @@ Wrong action names may not result in direct error messages, but just features
mystically not working.
*/
SteamIVRInput::SteamIVRInput()
: m_manifest(), m_mainSet( input_strings::k_setMain ),
m_nextTrack( input_strings::k_actionNextTrack, ActionType::Digital ),
m_previousTrack( input_strings::k_actionPreviousTrack,
: m_manifest(), m_mainSet( action_sets::k_setMain ),
m_nextTrack( action_keys::k_actionNextTrack, ActionType::Digital ),
m_previousTrack( action_keys::k_actionPreviousTrack,
ActionType::Digital ),
m_pausePlayTrack( input_strings::k_actionPausePlayTrack,
m_pausePlayTrack( action_keys::k_actionPausePlayTrack,
ActionType::Digital ),
m_stopTrack( input_strings::k_actionStopTrack, ActionType::Digital ),
m_leftHandSpaceTurn( input_strings::k_actionLeftHandSpaceTurn,
m_stopTrack( action_keys::k_actionStopTrack, ActionType::Digital ),
m_leftHandSpaceTurn( action_keys::k_actionLeftHandSpaceTurn,
ActionType::Digital ),
m_rightHandSpaceTurn( input_strings::k_actionRightHandSpaceTurn,
m_rightHandSpaceTurn( action_keys::k_actionRightHandSpaceTurn,
ActionType::Digital ),
m_leftHandSpaceDrag( input_strings::k_actionLeftHandSpaceDrag,
m_leftHandSpaceDrag( action_keys::k_actionLeftHandSpaceDrag,
ActionType::Digital ),
m_rightHandSpaceDrag( input_strings::k_actionRightHandSpaceDrag,
m_rightHandSpaceDrag( action_keys::k_actionRightHandSpaceDrag,
ActionType::Digital ),
m_optionalOverrideLeftHandSpaceTurn(
input_strings::k_actionOptionalOverrideLeftHandSpaceTurn,
action_keys::k_actionOptionalOverrideLeftHandSpaceTurn,
ActionType::Digital ),
m_optionalOverrideRightHandSpaceTurn(
input_strings::k_actionOptionalOverrideRightHandSpaceTurn,
action_keys::k_actionOptionalOverrideRightHandSpaceTurn,
ActionType::Digital ),
m_optionalOverrideLeftHandSpaceDrag(
input_strings::k_actionOptionalOverrideLeftHandSpaceDrag,
action_keys::k_actionOptionalOverrideLeftHandSpaceDrag,
ActionType::Digital ),
m_optionalOverrideRightHandSpaceDrag(
input_strings::k_actionOptionalOverrideRightHandSpaceDrag,
action_keys::k_actionOptionalOverrideRightHandSpaceDrag,
ActionType::Digital ),
m_swapSpaceDragToLeftHandOverride(
input_strings::k_actionSwapSpaceDragToLeftHandOverride,
action_keys::k_actionSwapSpaceDragToLeftHandOverride,
ActionType::Digital ),
m_swapSpaceDragToRightHandOverride(
input_strings::k_actionSwapSpaceDragToRightHandOverride,
action_keys::k_actionSwapSpaceDragToRightHandOverride,
ActionType::Digital ),
m_gravityToggle( input_strings::k_actionGravityToggle,
m_gravityToggle( action_keys::k_actionGravityToggle,
ActionType::Digital ),
m_heightToggle( input_strings::k_actionHeightToggle,
ActionType::Digital ),
m_resetOffsets( input_strings::k_actionResetOffsets,
ActionType::Digital ),
m_snapTurnLeft( input_strings::k_actionSnapTurnLeft,
ActionType::Digital ),
m_snapTurnRight( input_strings::k_actionSnapTurnRight,
m_heightToggle( action_keys::k_actionHeightToggle, ActionType::Digital ),
m_resetOffsets( action_keys::k_actionResetOffsets, ActionType::Digital ),
m_snapTurnLeft( action_keys::k_actionSnapTurnLeft, ActionType::Digital ),
m_snapTurnRight( action_keys::k_actionSnapTurnRight,
ActionType::Digital ),
m_xAxisLockToggle( input_strings::k_actionXAxisLockToggle,
m_xAxisLockToggle( action_keys::k_actionXAxisLockToggle,
ActionType::Digital ),
m_yAxisLockToggle( input_strings::k_actionYAxisLockToggle,
m_yAxisLockToggle( action_keys::k_actionYAxisLockToggle,
ActionType::Digital ),
m_zAxisLockToggle( input_strings::k_actionZAxisLockToggle,
m_zAxisLockToggle( action_keys::k_actionZAxisLockToggle,
ActionType::Digital ),
m_pushToTalk( input_strings::k_actionPushToTalk, ActionType::Digital )
m_pushToTalk( action_keys::k_actionPushToTalk, ActionType::Digital ),
m_leftHaptic( action_keys::k_actionHapticsLeft, ActionType::Haptic ),
m_rightHaptic( action_keys::k_actionHapticsRight, ActionType::Haptic ),
m_leftHand( input_keys::k_inputSourceLeft ),
m_rightHand( input_keys::k_inputSourceRight )
{
m_activeActionSet.ulActionSet = m_mainSet.handle();
m_activeActionSet.ulRestrictedToDevice = vr::k_ulInvalidInputValueHandle;
@@ -322,6 +323,39 @@ bool SteamIVRInput::pushToTalk()
return isDigitalActionActivatedConstant( m_pushToTalk );
}
/*!
Returns the action handle of the Left Haptic Action
*/
vr::VRActionHandle_t SteamIVRInput::leftHapticActionHandle()
{
return m_leftHaptic.handle();
}
/*!
Returns the action handle of the Right Haptic Action
*/
vr::VRActionHandle_t SteamIVRInput::rightHapticActionHandle()
{
return m_rightHaptic.handle();
}
/*!
Returns the input handle of the Right hand
*/
vr::VRInputValueHandle_t SteamIVRInput::rightInputHandle()
{
return m_rightHand.handle();
}
/*!
Returns the input handle of the Left hand
*/
vr::VRInputValueHandle_t SteamIVRInput::leftInputHandle()
{
return m_leftHand.handle();
}
/*!
Updates the active action set(s).
Should be called every frame, or however often you want the input system to
+39 -3
View File
@@ -4,6 +4,7 @@
#include "ivrinput_action.h"
#include "ivrinput_manifest.h"
#include "ivrinput_action_set.h"
#include "ivrinput_input_source.h"
namespace input
{
@@ -62,6 +63,13 @@ public:
bool pushToTalk();
bool proxIsActive();
vr::VRActionHandle_t leftHapticActionHandle();
vr::VRActionHandle_t rightHapticActionHandle();
vr::VRInputValueHandle_t rightInputHandle();
vr::VRInputValueHandle_t leftInputHandle();
// Destructor. There are no terminating calls for the IVRInput API, so it
// is left blank.
~SteamIVRInput() {}
@@ -113,6 +121,14 @@ private:
// Push To Talk
Action m_pushToTalk;
// haptic bindings
Action m_leftHaptic;
Action m_rightHaptic;
// input sources
InputSource m_leftHand;
InputSource m_rightHand;
};
/*!
@@ -120,7 +136,7 @@ The IVRInput system is _very_ finnicky about strings matching and if they don't
match there are usually no errors logged reflecting that. constexpr auto strings
should be used to refer to all action manifest strings.
*/
namespace input_strings
namespace action_keys
{
constexpr auto k_actionNextTrack = "/actions/main/in/NextTrack";
constexpr auto k_actionPreviousTrack = "/actions/main/in/PreviousTrack";
@@ -158,8 +174,28 @@ namespace input_strings
constexpr auto k_actionPushToTalk = "/actions/main/in/PushToTalk";
constexpr auto k_setMain = "/actions/main";
constexpr auto k_actionHapticsLeft = "/actions/main/out/HapticsLeft";
constexpr auto k_actionHapticsRight = "/actions/main/out/HapticsRight";
} // namespace input_strings
constexpr auto k_actionProxSensor = "/actions/main/in/ProxSensor";
} // namespace action_keys
/*!
Keys to get input source handles (things like hmd controllers etc.)
*/
namespace input_keys
{
constexpr auto k_inputSourceLeft = "/user/hand/left";
constexpr auto k_inputSourceRight = "/user/hand/right";
} // namespace input_keys
/*!
Keys for different action sets
*/
namespace action_sets
{
constexpr auto k_setMain = "/actions/main";
} // namespace action_sets
} // namespace input
+1
View File
@@ -14,6 +14,7 @@ enum class ActionType
Undefined,
Digital,
Analog,
Haptic,
};
/*!
+45
View File
@@ -0,0 +1,45 @@
#pragma once
#include <openvr.h>
#include <easylogging++.h>
namespace input
{
/*!
Represents an input source i.e. right controller
*/
class InputSource
{
public:
InputSource( const char* const inputSourceName ) : m_name( inputSourceName )
{
auto error
= vr::VRInput()->GetInputSourceHandle( inputSourceName, &m_handle );
if ( error != vr::EVRInputError::VRInputError_None )
{
LOG( ERROR ) << "Error getting input handle for '"
<< inputSourceName
<< "'. OpenVR Input Error: " << error;
}
}
/*!
An API internal handle that identifies an input handle.
*/
vr::VRInputValueHandle_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;
}
private:
vr::VRInputValueHandle_t m_handle = 0;
const std::string m_name;
};
} // namespace input