Move push to talk bindings to overlaycontroller
The old system used the old OpenVR input system which is incompatible with the new IVRInput. This change broke the AccessbilityTabController, but that is to be removed because the functionality can be found elsewhere.
This commit is contained in:
@@ -464,14 +464,7 @@ QPoint OverlayController::getMousePositionForEvent( vr::VREvent_Mouse_t mouse )
|
||||
return QPoint( mouse.x, y );
|
||||
}
|
||||
|
||||
/*!
|
||||
Checks if an action has been activated and dispatches the related action if it
|
||||
has been.
|
||||
|
||||
This function should probably be split into several functions that are specific
|
||||
to a binding type as the amount of actions grows.
|
||||
*/
|
||||
void OverlayController::processInputBindings()
|
||||
void OverlayController::processMediaKeyBindings()
|
||||
{
|
||||
if ( m_actions.nextSong() )
|
||||
{
|
||||
@@ -489,6 +482,10 @@ void OverlayController::processInputBindings()
|
||||
{
|
||||
m_utilitiesTabController.sendMediaStopSong();
|
||||
}
|
||||
}
|
||||
|
||||
void OverlayController::processRoomBindings()
|
||||
{
|
||||
// Execution order for moveCenterTabController actions is important. Don't
|
||||
// reorder these. Override actions must always come after normal because
|
||||
// active priority is set based on which action is "newest"
|
||||
@@ -511,6 +508,39 @@ void OverlayController::processInputBindings()
|
||||
m_actions.optionalOverrideRightHandRoomTurn() );
|
||||
}
|
||||
|
||||
void OverlayController::processPushToTalkBindings()
|
||||
{
|
||||
const auto pushToTalkCannotChange = !m_audioTabController.pttChangeValid();
|
||||
if ( pushToTalkCannotChange )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto pushToTalkButtonActivated = m_actions.pushToTalk();
|
||||
const auto pushToTalkCurrentlyActive = m_audioTabController.pttActive();
|
||||
if ( pushToTalkButtonActivated && !pushToTalkCurrentlyActive )
|
||||
{
|
||||
m_audioTabController.startPtt();
|
||||
}
|
||||
else if ( !pushToTalkButtonActivated && pushToTalkCurrentlyActive )
|
||||
{
|
||||
m_audioTabController.stopPtt();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Checks if an action has been activated and dispatches the related action if it
|
||||
has been.
|
||||
*/
|
||||
void OverlayController::processInputBindings()
|
||||
{
|
||||
processMediaKeyBindings();
|
||||
|
||||
processRoomBindings();
|
||||
|
||||
processPushToTalkBindings();
|
||||
}
|
||||
|
||||
// vsync implementation:
|
||||
// (this function triggers every 1ms)
|
||||
void OverlayController::OnTimeoutPumpEvents()
|
||||
|
||||
@@ -123,6 +123,9 @@ public: // I know it's an ugly hack to make them public to enable external
|
||||
private:
|
||||
QPoint getMousePositionForEvent( vr::VREvent_Mouse_t mouse );
|
||||
void processInputBindings();
|
||||
void processMediaKeyBindings();
|
||||
void processRoomBindings();
|
||||
void processPushToTalkBindings();
|
||||
|
||||
public:
|
||||
OverlayController( bool desktopMode, bool noSound, QQmlEngine& qmlEngine );
|
||||
|
||||
@@ -87,7 +87,7 @@ private:
|
||||
void onPttStop() override;
|
||||
void onPttEnabled() override;
|
||||
void onPttDisabled() override;
|
||||
bool pttChangeValid() override;
|
||||
|
||||
virtual vr::VROverlayHandle_t getNotificationOverlayHandle() override
|
||||
{
|
||||
return m_ulNotificationOverlayHandle;
|
||||
@@ -114,6 +114,8 @@ public:
|
||||
|
||||
void eventLoopTick();
|
||||
|
||||
bool pttChangeValid() override;
|
||||
|
||||
int playbackDeviceIndex() const;
|
||||
|
||||
int mirrorDeviceIndex() const;
|
||||
|
||||
@@ -222,118 +222,8 @@ void PttController::savePttConfig()
|
||||
|
||||
void PttController::checkPttStatus()
|
||||
{
|
||||
static auto handleControllerState
|
||||
= []( const vr::VRControllerState_t& state,
|
||||
PttControllerConfig* config ) -> bool {
|
||||
if ( state.ulButtonPressed & config->digitalButtonMask )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ( config->triggerMode )
|
||||
{
|
||||
if ( state.ulButtonPressed
|
||||
& vr::ButtonMaskFromId( vr::k_EButton_SteamVR_Trigger ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ( config->touchpadMode )
|
||||
{
|
||||
if ( ( ( config->touchpadMode & 1 )
|
||||
&& ( state.ulButtonTouched
|
||||
& vr::ButtonMaskFromId(
|
||||
vr::k_EButton_SteamVR_Touchpad ) ) )
|
||||
|| ( ( config->touchpadMode & 2 )
|
||||
&& ( state.ulButtonPressed
|
||||
& vr::ButtonMaskFromId(
|
||||
vr::k_EButton_SteamVR_Touchpad ) ) ) )
|
||||
{
|
||||
if ( config->touchpadAreas
|
||||
== ( PAD_AREA_LEFT + PAD_AREA_TOP + PAD_AREA_RIGHT
|
||||
+ PAD_AREA_BOTTOM ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
float x = state.rAxis[0].x;
|
||||
float y = state.rAxis[0].y;
|
||||
if ( std::abs( x ) >= 0.2 || std::abs( y ) >= 0.2 )
|
||||
{ // deadzone in the middle
|
||||
if ( x < 0 && std::abs( y ) < -x
|
||||
&& ( config->touchpadAreas & PAD_AREA_LEFT ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( y > 0 && std::abs( x ) < y
|
||||
&& ( config->touchpadAreas & PAD_AREA_TOP ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( x > 0 && std::abs( y ) < x
|
||||
&& ( config->touchpadAreas
|
||||
& PAD_AREA_RIGHT ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( y < 0 && std::abs( x ) < -y
|
||||
&& ( config->touchpadAreas
|
||||
& PAD_AREA_BOTTOM ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
if ( m_pttEnabled )
|
||||
{
|
||||
bool newState = false;
|
||||
if ( m_pttLeftControllerEnabled )
|
||||
{
|
||||
auto leftId
|
||||
= vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(
|
||||
vr::TrackedControllerRole_LeftHand );
|
||||
if ( leftId != vr::k_unTrackedDeviceIndexInvalid )
|
||||
{
|
||||
vr::VRControllerState_t state;
|
||||
if ( vr::VRSystem()->GetControllerState(
|
||||
leftId, &state, sizeof( vr::VRControllerState_t ) ) )
|
||||
{
|
||||
// logControllerState(state, "Left ");
|
||||
newState |= handleControllerState( state,
|
||||
m_pttControllerConfigs );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( m_pttRightControllerEnabled )
|
||||
{
|
||||
auto rightId
|
||||
= vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(
|
||||
vr::TrackedControllerRole_RightHand );
|
||||
if ( rightId != vr::k_unTrackedDeviceIndexInvalid )
|
||||
{
|
||||
vr::VRControllerState_t state;
|
||||
if ( vr::VRSystem()->GetControllerState(
|
||||
rightId, &state, sizeof( vr::VRControllerState_t ) ) )
|
||||
{
|
||||
// logControllerState(state, "Right ");
|
||||
newState |= handleControllerState(
|
||||
state, m_pttControllerConfigs + 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( newState && !m_pttActive && pttChangeValid() )
|
||||
{
|
||||
startPtt();
|
||||
}
|
||||
else if ( !newState && m_pttActive && pttChangeValid() )
|
||||
{
|
||||
stopPtt();
|
||||
}
|
||||
}
|
||||
// PTT Controls are now handled in the overlaycontroller using public
|
||||
// functions.
|
||||
}
|
||||
|
||||
void PttController::startPtt()
|
||||
|
||||
@@ -75,10 +75,7 @@ protected:
|
||||
virtual void onPttStop(){};
|
||||
virtual void onPttEnabled(){};
|
||||
virtual void onPttDisabled(){};
|
||||
virtual bool pttChangeValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual vr::VROverlayHandle_t getNotificationOverlayHandle()
|
||||
{
|
||||
return vr::k_ulOverlayHandleInvalid;
|
||||
@@ -100,6 +97,11 @@ public:
|
||||
void savePttProfiles();
|
||||
void savePttConfig();
|
||||
|
||||
virtual bool pttChangeValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Q_INVOKABLE QVariantList pttDigitalButtons( unsigned controller );
|
||||
Q_INVOKABLE unsigned long pttDigitalButtonMask( unsigned controller );
|
||||
Q_INVOKABLE unsigned pttTouchpadMode( unsigned controller );
|
||||
|
||||
Reference in New Issue
Block a user