[SU13] [resolved] [SimConnect] SIMCONNECT_INPUT_EVENT_TYPE wrong for GetInputEvent (managed)

Version: Flighting SU13 - 1.34.11.0

Frequency: Consistently

Severity: Low

Context: External SimConnect Client

Bug description:
GetInputEvent
SIMCONNECT_INPUT_EVENT_TYPE.NONE returns a float64 (?)
SIMCONNECT_INPUT_EVENT_TYPE.DOUBLE returns a string
SIMCONNECT_INPUT_EVENT_TYPE.STRING returns a string

The type works correctly with SubscribeInputEvent

Repro steps:
Tested with the C208
ELECTRICAL_ExternalPower_1_Cover

Attachments:

Private attachments: Send a PM to @PrivateContent with the link to this topic and the link to download your content

Hello @LorbySI

The type you receive in SIMCONNECT_RECV_GET_INPUT_EVENT is the one you have set yourself when calling SimConnect_GetInputEvent.
Are you receiving the correct type when calling EnumerateInputEvents ?
Are you sure you haven’t mixed your hash or request ID ?

I just tested that specific event on the 208 and I receive the expected double.

Regards,
Sylvain

Hello Sylvain,

yes, I am sure. I am using the same code as in the other thread, I am only changing the SIMCONNECT_INPUT_EVENT_TYPE. And I only get the double structure back when I set it to NONE, the others return Strings. That is not really a problem for me, I just wanted to let you know.

Best regards
Oliver

Hello @LorbySI

None of us had the issue.
If you can provide us with sources that produce this behaviour, we’ll investigate.

Regards,
Sylvain

Hello Sylvain,

with the new version, are you still RegisterStruct’ing your data structures with SIMCONNECT_RECV_GET_INPUT_EVENT?

I just left this as it was before (=register a String and a Double structure to my own enum), maybe that is my mistake?

Still, this doesn’t explain why the same code is working for SubscribeInputEvent but not for GetInputEvent…

Best
Oliver

OK, got it now. The problem is how one associates the data structures with an enum.

With GetInputEvent I can’t do this:

        public enum InputEventType
        {
            DOUBLE,
            STRING
        }

                Sim.Connect.RegisterStruct<SIMCONNECT_RECV_GET_INPUT_EVENT, GetInputEventString>(InputEventType.STRING);
                Sim.Connect.RegisterStruct<SIMCONNECT_RECV_GET_INPUT_EVENT, GetInputEventDouble>(InputEventType.DOUBLE);

Instead I have to do this:

                Sim.Connect.RegisterStruct<SIMCONNECT_RECV_GET_INPUT_EVENT, GetInputEventString>(SIMCONNECT_INPUT_EVENT_TYPE.STRING);
                Sim.Connect.RegisterStruct<SIMCONNECT_RECV_GET_INPUT_EVENT, GetInputEventDouble>(SIMCONNECT_INPUT_EVENT_TYPE.DOUBLE);

WEREAS

with SubscribeInputEvent I have to use

        public enum InputEventType
        {
            DOUBLE,
            STRING
        }

                Sim.Connect.RegisterStruct<SIMCONNECT_RECV_GET_INPUT_EVENT, GetInputEventString>(InputEventType.STRING);
                Sim.Connect.RegisterStruct<SIMCONNECT_RECV_GET_INPUT_EVENT, GetInputEventDouble>(InputEventType.DOUBLE);

or it doesn’t work.

You no longer have to register anything after the modifications we have made.
Check the examples provided in the doc:
SimConnect_GetInputEvent (flightsimulator.com)

Regards,
Sylvain

I am really sorry, but for me this is still only true for GetInputEvent. It does not work that way for SubscribeInputEvent. That is what was confusing me, I started out with Subscribe and noticed that I can only read from Subscribe using the structures. So I assumed that it would be the same with Get - but that is not the case. I can run GetInputEvent as described in the manual now.

I will stick to my working logic regarding the SubscribeInputEvent - the structure reference is the only way I can get it to work.

As I said, that is not really a problem, just odd.

I used the exact same code for the SubscribeInputEvent callback and had the expected result as well.

private void SimConnect_OnRecvSubscribeInputEvent(SimConnect sender, SIMCONNECT_RECV_SUBSCRIBE_INPUT_EVENT data)
{
    switch (data.eType)
    {
        case SIMCONNECT_INPUT_EVENT_TYPE.DOUBLE:
            double d = (double)data.Value[0];
            Console.WriteLine("Receive Double: " + d.ToString());
            break;
        case SIMCONNECT_INPUT_EVENT_TYPE.STRING:
            SimConnect.GetInputEventString str = (SimConnect.GetInputEventString)data.Value[0];
            Console.WriteLine("Receive String: " + str.value.ToString());
            break;
        case SIMCONNECT_INPUT_EVENT_TYPE.NONE:
            break;
    }
}

Regards,
Sylvain

Strange, but that doesn’t work for me. Calling

Sim.Connect.SubscribeInputEvent(0, SIMCONNECT_INPUT_EVENT_TYPE.DOUBLE);

assuming that I will receive only DOUBLE events, I get invalid cast exceptions and type NONE. But using the structures like before, with the exact same call, it works.

Never mind, I’m happy as long as it works at all :slight_smile:

You are passing 0 as a hash parameter?

I do.

The spec said, that with “0” all Input Events are returned that happen in the simulation. So I assumed that by adding the type, the events would be limited to the FLOAT64 variant. This works too, when I supply my own registered data structure, but not with the event type “DOUBLE”.

When passing 0 as a hash to subscribe to all events, the type parameter is just ignored and the data you will receive will be typed with NONE.
This prevents you from casting into the types that are registered by SimConnect.

We’ll improve this as well, possibly by having the server provide the appropriate type rather than having this on client side.

Regards,
Sylvain

Hello Sylvain,

the curious thing is, that my method is working too. Registering a double struct and passing the associated enum, the Subscribe seems to return only those.

Again, thank you for your time!

Cheers
Oliver

Well, all our InputEvents are returning doubles as far as I can tell so using this type and registering your own structure will work in this case.
But receiving events with different types will be a problem with this design and the point was to use pre registered structures anyway so we’ll improve this for the final SU13 release.

Thank you for your feedback.

Regards,
Sylvain