Skip to content

Fix GetInputEventAsync#6

Closed
bstudtma wants to merge 4 commits intostopbars:mainfrom
bstudtma:fix-getinputevent
Closed

Fix GetInputEventAsync#6
bstudtma wants to merge 4 commits intostopbars:mainfrom
bstudtma:fix-getinputevent

Conversation

@bstudtma
Copy link
Copy Markdown
Contributor

Summary

Fixed GetInputEventAsync to read the Value bytes correctly based on type.

Changes Made

Corrected the return type enum.
Added a new structure for the response without the value.
Read the bytes dynamically based on the type.
Removed an unused structure.

Additional Information

Tested with:

var inputEvents = await client.InputEvents.EnumerateInputEventsAsync(cancellationToken);
foreach (var evt in inputEvents)
{
Console.WriteLine($" 📋 InputEvent: {evt.Name}");
var currentValue = await client.InputEvents.GetInputEventAsync(evt.Hash, cancellationToken);
Console.WriteLine($" 📊 Current value: {currentValue}");
}

Author Information

Discord Username: bstudtma


Checklist:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Copilot AI review requested due to automatic review settings August 23, 2025 11:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the GetInputEventAsync method to correctly handle reading input event values based on their data type. The fix addresses issues with how the SimConnect response structure was being interpreted and value extraction.

  • Updated the response structure to separate header from value data
  • Implemented dynamic value reading based on the input event type
  • Removed the unused None enum value and cleaned up default handling

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
SimConnectRecvGetInputEventHeader.cs Renamed struct and removed Value field to create header-only structure
InputEventManager.cs Updated value extraction logic to dynamically read bytes based on type
SimConnectInputEventType.cs Removed unused None enum value

Comment on lines +700 to +702
byte[] defBuf = new byte[payloadSize];
Marshal.Copy(pValue, defBuf, 0, defBuf.Length);
value = defBuf;
Copy link

Copilot AI Aug 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 702 assigns the byte array to value, but line 703 immediately overwrites it with a double. Remove line 702 as it's redundant and the final assignment should be the double value.

Suggested change
byte[] defBuf = new byte[payloadSize];
Marshal.Copy(pValue, defBuf, 0, defBuf.Length);
value = defBuf;

Copilot uses AI. Check for mistakes.
@bstudtma bstudtma closed this Aug 23, 2025
@bstudtma bstudtma review requested due to automatic review settings March 24, 2026 01:17
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