DSprtn / GTFO_VR_Plugin

A plugin to add full roomscale Virtual Reality support to your favorite game!
MIT License
143 stars 13 forks source link

Shockwave haptics setting #50

Closed Nordskog closed 1 year ago

Nordskog commented 1 year ago

What

Adds a new setting for toggling Shockwave suit support. It also prevents suit initialization from being performed unless/until enabled, as this can cause issues for some users.

In addition to checking whether the setting has been enabled, we also check if the suit was successfully initialized and that the suit is connected before performing any of the work involved in submitting the haptic patterns.

An Info log entry was added immediately before the initialization, so that we can easily identify from the logs if another user encounters the same issue and needs to disable Shockwave support.

How

There was no existing setting to toggle Shockwave support, so a new one was added. The setting is monitored and the Shockwave suit will be initialized if the setting is enabled after launching the game.

Both BodyHapticAgents have been given a new method for checking whether they should perform any work, bool AgentActive(). In ShockwaveIntegration this checks whether the setting is enabled, was successfully initialized, and is actually connected.

public bool AgentActive()
{
    return VRConfig.configUseShockwave.Value && ShockwaveManager.Instance.Ready && ShockwaveManager.Instance.suitConnected();
}

In BhapticsIntegration this currently only checks the setting. Any calls that queried the setting directly have been redirected to use AgentActive() instead. Ideally this should also check for the presence of a bHaptics suit to avoid unnecessary work.

public bool AgentActive()
{
    return VRConfig.configUseBhaptics.Value;
}

Both agents will continue to update their internal state when disabled, without triggering any haptic patterns. AgentActive() is also used in a few locations to ensure that while() loops exit when disabled, if they were already active.

Considerations

I own neither a bHaptics suit nor a Shockwave suit, so this should ideally be tested by someone who owns them.

DSprtn commented 1 year ago

I wish I had one of these too. I guess beta testers will have to let us know if things work correctly.