Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 23, 2025

Addresses feedback from PR #8: the null-conditional operator Instance?.GetConnectedDevices() conflated two distinct error conditions—Instance being null vs. no devices connected—logging both as "No bHaptics devices detected".

Changes

  • Split null check into two conditions:
    • Instance == nullError log indicating initialization failure
    • Empty device list → Warning log for no connected devices
  • Removed null-conditional operator in favor of explicit null check
// Before
var connectedDevices = BHapticsConnection.Instance?.GetConnectedDevices();
if (connectedDevices == null || connectedDevices.Count == 0)
{
    Warn("No bHaptics devices detected");
    return;
}

// After
if (BHapticsConnection.Instance == null)
{
    Error("BHapticsConnection.Instance is null - connection not properly initialized");
    return;
}

var connectedDevices = BHapticsConnection.Instance.GetConnectedDevices();
if (connectedDevices.Count == 0)
{
    Warn("No bHaptics devices detected");
    return;
}

This improves debuggability by surfacing initialization failures as errors rather than masking them as operational warnings.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: nalathethird <36301692+nalathethird@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on bHapticsManager architecture refactor Separate Instance null check from no-devices check in InitializeHaptics Nov 23, 2025
Copilot AI requested a review from nalathethird November 23, 2025 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants