P3D v4 Throttle/Mixture overwrite using simConnect. Problem: FSUIPC


Resource contributor
Hi folks,
It's been a while. I've been super busy getting the update for my Vega out of the way.

Since the update, some of my customers experienced some issues in combination with FSUIPC and I was wondering if someone here has an idea how to resolve this.

I am overwriting the sims throttle and mixture settings using simConnect, like we discussed a few months ago. I use:
SimConnect_AddClientEventToNotificationGroup(mySimConnect, GROUP_THROTTLE, EVENT_AXIS_THROTTLE, true);
and similar to intercept the throttle and mixture axis from the sim. Furthermore, I set up:
    SimConnect_AddToDataDefinition(simConnectHandle, DEFINITION_ENGINE_CONTROLS, "GENERAL ENG THROTTLE LEVER POSITION:1", "percent");
to later overwrite the throttle setting. Similar code exists for the mixture.

The main simConnect callback catches the event:
        case EVENT_AXIS_THROTTLE1:
            throttle = (double)(((*evt).dwData + 16383) * 0.0030519441);
I use the throttle variable to set my custom throttle lever animation in the modeldef.xml.

After some processing of the throttle variable, I use
        SimConnect_SetDataOnSimObject(mySimConnect, DEFINITION_ENGINE_CONTROLS, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(sim_engine_controls), &sim_engine_controls);
To finally set the internal throttle lever of the sim, to manipulate the engine power according to some custom conditions (like spark lever control etc.).

This works like charm. ..... As long as you don't use FSUIPC. Whenever you use the axis calibration this system screws up. What happens is that when you move the joystick's throttle all the way back, beyond FSUIPCs "minimum", my throttle event reads a ridiculously high number, something in the millions range.

Can anyone recommend a method to improve the function for FSUIPC support?

Btw: check out my updated Wing42 Lockheed Vega. She's awesome! :wave:
It is my understanding that FSUIPC intercepts the FS variables for throttle position that you're trying to influence. You can not win that fight because FSUIPC always starts as a module with the sim and thus gets in line first with regards to who controls access to the throttle input and output to the sim.


Resource contributor
Oh look, for the most part this works just fine with FSUIPC. The only issue is those minimums! So if there was a tug-of-war of who gets to overwrite the throttle in the first place, I DO win it ;)


Resource contributor
I expect that FSUIPC is throwing THROTTLE_SET, rather than AXIS_THROTTLE_SET.
That would be why you're not capturing events when the user has calibrated with FSUIPC.



Resource contributor
Sorry for the late reply, I've been with family over Easter.

Doug, I read the events alright. It's just when you move the throttle over the minimum set in FSUIPC when he problem occurs. It feels as if FSUIPC is sending a wrong number when this range is hit. Would it be worthwhile reading THROTTLE_SET instead and see if that does the trick?
Ok... you use the term EVENT_AXIS_THROTTLE, but you've not shown what event that's actually tied to. I assume it's AXIS_THROTTLE_SET. FSUIPC uses THROTTLE_SET to input it's calibration. THROTTLE_SET has no negative value defined by documents... HOWEVER... if the throttles go into reverse... the value indeed becomes a negative value. I suspect you are running afoul of a reverse thrust range setting.

I'm not clear on the purpose of your code, and you've left a few holes that require guesswork. If you're only reading a control's position, they why are you attempting to write back to the sim a new position? If you are attempting to override what the sim sees versus the physical control... then using SetDataOnSimObject is probably not the best approach. If you're going to override a control input... you need to still let the sim see the control's input (after you've adjusted the value). That's the method that FSUIPC uses. It intercepts the physical axis input from your hardware... and then writes the value to the sim. The sim never sees the hardware's actual input at all, though it thinks it does because you're sending the event on after you've adjusted it's values.


Resource contributor
Sorry, I didn't point this out before. Yes, I'm using the AXIS_THROTTLE_SET event. I'm also using some of the discreet events to make sure I get the F1-F4 keystrokes as well.
        hr = SimConnect_MapClientEventToSimEvent(mySimConnect, EVENT_AXIS_THROTTLE, "AXIS_THROTTLE_SET");
        hr = SimConnect_MapClientEventToSimEvent(mySimConnect, EVENT_THROTTLE_SET, "THROTTLE_SET");
        hr = SimConnect_MapClientEventToSimEvent(mySimConnect, EVENT_THROTTLE_CUT, "THROTTLE_CUT");
        hr = SimConnect_MapClientEventToSimEvent(mySimConnect, EVENT_THROTTLE_FULL, "THROTTLE_FULL");
        hr = SimConnect_MapClientEventToSimEvent(mySimConnect, EVENT_THROTTLE_INC, "THROTTLE_INCR");
        hr = SimConnect_MapClientEventToSimEvent(mySimConnect, EVENT_THROTTLE_SINC, "THROTTLE_INCR_SMALL");
        hr = SimConnect_MapClientEventToSimEvent(mySimConnect, EVENT_THROTTLE_DEC, "THROTTLE_DECR");
I am converting the values I get from these events to a double ranging from 0 to 100 and pass that number to an L: var to animate the throttle lever. I calculate intermediate variables like the fill level of the carburetor bowls, ignition etc and consolidate everything into another double variable ranging from 0 to 100 that is passed to the sim using SetDataOnSimObject as written above. I omitted the calculation of that variable, because it's really not relevant to the conversation :)

I'm not quite sure what's wrong with my approach, since it works really nicely - as long ass you don't use FSUIPC. The way I see it, it's FSUIPC that is spoiling the fun here, not me. :duck:

Am I interpreting this correctly: your suggestion is to use a normal send_key_event to override the sims throttle lever?
No... I don't use send_key_event.

Before I go further, let me ensure I am understanding your overall goal... you are attempting to intercept the actual throttle input from the user (hardware/keyboard) and prevent the sim from seeing that, instead forcing the sim to see a different throttle condition based on your own simulation coding. Correct?


Resource contributor
Yep, that's roughly what I am doing. Plus a lot of Spaghetti-Code-Magic in between :laughing:
Ok... here are the steps you will need to accomplish it. I suspect you have most of them accomplished... but I will list them for clarity. All of this is using SimConnect.

1. Map client event to sim event to receive the incoming events.
2. Add the client event to a notification group, so you know when they change.
3. Set the notification group's priority to SIMCONNECT_GROUP_PRIORITY_HIGHEST_MASKABLE. This allows you to block the sim from seeing the actual values.
4. Modify the desired event values.
5. Use TransmitClientEvent to send the throttle event with the updated value... this allows the sim to see the throttle input, but the actual value is one you calculated above.

I noticed you are trapping key inputs, which is fine. However, all output will be via the axis... you will 'swallow' the keyboard events so that the sim doesn't see them at all.
I did not add in the need to turn on the notification events, etc... assuming those details you already understand.


Resource contributor
@Vitus you might want to monitor the THROTTLE1 events as well since those with dual throttles aren't necessarily going to remap them to the one for all THROTTLE events.