Tie a client event to a variable in code

Discuss on the SimConnect SDK can be used by programmers to write add-on components for Prepar3D
Locked
jpinheir
Posts: 7
Joined: Fri Aug 23, 2013 4:30 pm

Post by jpinheir »

I'm attempting to add camera-switching functionality to an existing SimConnect interface, triggered by incoming external data rather than a key press. Reading through the documentation and examples, I think I could do this either by using MapClientEventToSimEvent with the "VIEW MODE" Eventname, or by using CameraSetRelative6DOF. However, to trigger either of these events, I think I need to use MapInputEventToClientEvent? And if so, how do I point szInputDefinition to an existing variable in my code, rather than a keyboard command?

Or is there another way? Is it as simple as putting an if() statement with CameraSetRelative6DOF in my existing code that runs every frame and not doing an event?

A secondary question: Is the SimConnect command 'OpenView' only available with v2+? I'm using version 1.4 of P3D and (I assume) an older version of SimConnect, and I see no references to that command.

Thanks,

- Jacob
User avatar
Rob McCarthy
Lockheed Martin
Posts: 3704
Joined: Wed Aug 24, 2011 1:37 pm

Post by Rob McCarthy »

Jacob,

This depends on the data you're wanting to use to trigger the camera switch. Using the MapClientEventToSimEvent would work for you if the external data you're triggering on is an Event ID listed in the SDK. These are tied to key events. Alternatively you can request SimObject info using RequestDataOnSimObject. If what you want to trigger on is a Simulation Variable you can change your camera using SimConnect when this info is received if it matches your criteria.

The SimConnect OpenView command is a 2.0 and above feature. 2.0 includes many SimConnect enhancements related to the view system.
Rob McCarthy
Prepar3D® Core Lead
jpinheir
Posts: 7
Joined: Fri Aug 23, 2013 4:30 pm

Post by jpinheir »

Thanks for the quick reply. Just to clarify, is it possible to trigger a specific SimEvent ID in Prepar3D directly from my SimConnect code, without tying it to an InputEvent? It looks like the answer is no.

The data I'm using is coming from an external vehicle simulation via UDP packets. I don't wish to trigger the camera switch based on data coming from Prepar3D, so I believe that means I can't use an Event ID as the trigger.

I was able to get it working using CameraSetRelative6DOF based on logic from my external data. It would be preferable, however, to use the view system Event IDs to toggle between views defined in sim.cfg (so I can set zoom levels), if possible.

Thanks again,

- Jacob
User avatar
Rob McCarthy
Lockheed Martin
Posts: 3704
Joined: Wed Aug 24, 2011 1:37 pm

Post by Rob McCarthy »

Yes, SimEvent IDs would be tied to input events in Prepar3D and with your solution using an external vehicle that approach wouldn't work. I'm glad the CamerSetRelative6DOF approach works. Version 2 does allow for camera zoom control through SimConnect as well as smoothly panning to different viewing angles to make better transitions.
Rob McCarthy
Prepar3D® Core Lead
Locked