Closed
Conversation
Contributor
There was a problem hiding this comment.
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
Noneenum 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; |
There was a problem hiding this comment.
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: