Skip to content

chrlembeck/simconnect-java-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simconnect-java-util

The simconnect-java-util project contains a java client for the simconnect interface of the microsoft flight simulator 2020. The client connects to the flight simulator directly over an IP network connection, so that it is able to run on the same machine as the simulator or on another machine in the local network. As this java client communicates directly with the flight simulator, it is not necessary to install the Flight Simulators simconnect API written in C++ or C#.

The project is inspired by Marko Harjulas jsimconnect project, which supports the API for Flight Simulator X but does not contain some of the newer methods for Flight Simulator 2020.

https://github.com/EvenAR/node-simconnect/tree/master

https://github.com/EvenAR/node-simconnect/blob/master/src/SimConnectConnection.ts

Supported methods of the simconnect API

ID Name Comment
01 Open ✔️
02 unknown
03 RequestResponseTimes ❌ not yet implemented
04 MapClientEventToSimEvent ✔️
05 TransmitClientEvent ✔️
06 SetSystemEventState ✔️
07 AddClientEventToNotificationGroup ✔️
08 RemoveClientEvent ✔️
09 SetNotificationGroupPriority ✔️
0a ClearNotificationGroup ✔️
0b RequestNotificationGroup ✔️
0c AddToDataDefinition ✔️
0d ClearDataDefinition ✔️
0e RequestDataOnSimObject ✔️
0f RequestDataOnSimObjectType ✔️
10 SetDataOnSimObject ✔️
11 MapInputEventToClientEvent Deprecated, use MapInputEventToClientEvent_EX1 instead
12 SetInputGroupPriority ✔️
13 RemoveInputEvent ✔️
14 ClearInputGroup ✔️
15 SetInputGroupState ✔️
16 RequestReservedKey ✔️
17 SubscribeToSystemEvent ✔️
18 UnsubscribeFromSystemEvent ✔️
19 WeatherRequestInterpolatedObservation Deprecated, not implemented here
1a WeatherRequestObservationAtStation Deprecated, not implemented here
1b WeatherRequestObservationAtNearestStation Deprecated, not implemented here
1c WeatherCreateStation Deprecated, not implemented here
1d WeatherRemoveStation Deprecated, not implemented here
1e WeatherSetObservation Deprecated, not implemented here
1f WeatherSetModeServer Deprecated, not implemented here
20 WeatherSetModeTheme Deprecated, not implemented here
21 WeatherSetModeGlobal Deprecated, not implemented here
22 WeatherSetModeCustom Deprecated, not implemented here
23 WeatherSetDynamicUpdateRate Deprecated, not implemented here
24 WeatherRequestCloudState Deprecated, not implemented here
25 WeatherCreateThermal Deprecated, not implemented here
26 WeatherRemoveThermal Deprecated, not implemented here
27 AICreateParkedATCAircraft ✔️
28 AICreateEnrouteATCAircraft ✔️
29 AICreateNonATCAircraft ✔️
2a AICreateSimulatedObject ✔️
2b AIReleaseControl ✔️
2c AIRemoveObject ✔️
2d AISetAircraftFlightPlan ✔️
2e ExecuteMissionAction Deprecated, not implemented here
2f CompleteCustomMissionAction Deprecated, not implemented here
30 CameraSetRelative6DOF ✔️
31 SimConnect_MenuAddItem Deprecated, not implemented here
32 SimConnect_MenuDeleteItem Deprecated, not implemented here
33 SimConnect_MenuAddSubItem Deprecated, not implemented here
34 SimConnect_MenuDeleteSubItem Deprecated, not implemented here
35 RequestSystemState ✔️
36 SetSystemState ✔️
37 MapClientDataNameToID ✔️
38 CreateClientData ✔️
39 AddToClientDataDefinition ✔️
3a ClearClientDataDefinition ✔️
3b RequestClientData ✔️
3c SetClientData ✔️
3d FlightLoad ✔️
3e FlightSave ✔️
3f FlightPlanLoad ✔️
40 Text Deprecated, not implemented here
41 SubscribeToFacilities ✔️
42 UnsubscribeToFacilities ✔️
43 RequestFacilitiesList ✔️
44 TransmitClientEvent_EX1 ✔️
45 AddToFacilityDefinition ✔️
46 RequestFacilityData ✔️
47 SubscribeToFacilities_EX1 ✔️
48 UnsubscribeToFacilities_EX1 ✔️
49 RequestFacilitiesList_EX1 ✔️
4a RequestFacilityData_EX1 ✔️
4b RequestJetwayData ✔️
4c EnumerateControllers ✔️
4d MapInputEventToClientEvent_EX1 ✔️
4e ? ExecuteAction ? ❌ not implemented due to lack of documentation
4f EnumerateInputEvents ✔️
50 GetInputEvent ✔️
51 SetInputEvent ✔️
52 SubscribeInputEvent ✔️
53 UnsubscribeInputEvent ✔️
54 EnumerateInputEventParams ✔️
55 AddFacilityDataDefinitionFilter ✔️
56 ClearAllFacilityDataDefinitionFiltersRequest ✔️

Supported Events sent from the simconnect API

ID Name Comment
01 SIMCONNECT_RECV_ID_EXCEPTION ✔️
02 SIMCONNECT_RECV_ID_OPEN ✔️
03 SIMCONNECT_RECV_ID_QUIT ✔️
04 SIMCONNECT_RECV_ID_EVENT ✔️
05 SIMCONNECT_RECV_ID_EVENT_OBJECT_ADDREMOVE ✔️
06 SIMCONNECT_RECV_ID_EVENT_FILENAME ✔️
07 SIMCONNECT_RECV_ID_EVENT_FRAME ✔️
08 SIMCONNECT_RECV_ID_SIMOBJECT_DATA ✔️
09 SIMCONNECT_RECV_ID_SIMOBJECT_DATA_BYTYPE ✔️
0a SIMCONNECT_RECV_ID_WEATHER_OBSERVATION Deprecated, not implemented here
0b SIMCONNECT_RECV_ID_CLOUD_STATE Deprecated, not implemented here
0c SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID ✔️
0d SIMCONNECT_RECV_ID_RESERVED_KEY ✔️
0e SIMCONNECT_RECV_ID_CUSTOM_ACTION Deprecated, not implemented here
0f SIMCONNECT_RECV_ID_SYSTEM_STATE ✔️
10 SIMCONNECT_RECV_ID_CLIENT_DATA ✔️
11 SIMCONNECT_RECV_ID_EVENT_WEATHER_MODE Deprecated, not implemented here
12 SIMCONNECT_RECV_ID_AIRPORT_LIST ✔️
13 SIMCONNECT_RECV_ID_VOR_LIST ✔️
14 SIMCONNECT_RECV_ID_NDB_LIST ✔️
15 SIMCONNECT_RECV_ID_WAYPOINT_LIST ✔️
16 SIMCONNECT_RECV_ID_EVENT_MULTIPLAYER_SERVER_STARTED ✔️
17 SIMCONNECT_RECV_ID_EVENT_MULTIPLAYER_CLIENT_STARTED ✔️
18 SIMCONNECT_RECV_ID_EVENT_MULTIPLAYER_SESSION_ENDED ✔️
19 SIMCONNECT_RECV_ID_EVENT_RACE_END
1a SIMCONNECT_RECV_ID_EVENT_RACE_LAP
1b SIMCONNECT_RECV_ID_EVENT_EX1 ✔️
1c SIMCONNECT_RECV_ID_FACILITY_DATA ✔️
1d SIMCONNECT_RECV_ID_FACILITY_DATA_END ✔️
1e SIMCONNECT_RECV_ID_FACILITY_MINIMAL_LIST
1f SIMCONNECT_RECV_ID_JETWAY_DATA ✔️
20 SIMCONNECT_RECV_ID_CONTROLLERS_LIST ✔️
21 SIMCONNECT_RECV_ID_ACTION_CALLBACK
22 SIMCONNECT_RECV_ID_ENUMERATE_INPUT_EVENTS ✔️
23 SIMCONNECT_RECV_ID_GET_INPUT_EVENT
24 SIMCONNECT_RECV_ID_SUBSCRIBE_INPUT_EVENT
25 SIMCONNECT_RECV_ID_ENUMERATE_INPUT_EVENT_PARAMS

How to compile the project?

Just clone the project and compile it with your local maven installation:

git clone https://github.com/chrlembeck/simconnect-java-util.git
cd simconnect-java-util.git
mvn install

How to use the utils in your own java project?

To integrate the simconnect-java-util in your own project just add it to the maven dependencies in the projects pom.xml:

<depenencies>
    <!-- ... other dependencies ... --> 
    <dependency>
        <groupId>org.lembeck</groupId>
        <artifactId>simconnect-java-util</artifactId>
        <version>0.1</version>
    </dependency>
</dependencies

Are there any examples to demonstrate the usage of this project?

Yes, the project contains some example programs to show some of its features. The examples can be found in the package org.lembeck.fs.simconnect.examples.

What do I have to do to establish a connection to my flight simulator instance?

To be able to connect to your instance of Flight Simulator 2020, you have to tell the integrated simconnect server interface to listen for incoming IP connections out of your local network. To do so, you have to inspect and possibly edit the simconnect.xml file of your Flight Simulator installation. This file should be located on the computer, the Flight Simulator is running on. The detailed location is depending on the way, the Flight Simulator was installed.

If you installed the simulator out of the Microsoft Store, the simconnect.xml file ist located here:

C:\Users\<user_name>\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\

Installations of the Steam edition have the simconnect.xml file here:

C:\Users\<user_name>\AppData\Roaming\Microsoft Flight Simulator\

The simconnect.xml file is structured as a usual xml file and should have some <SimConnect.Comm> sections in it. Each of them defines a way to get into contact with the server. To open a listener on a specific network port (for example 12345), you have to add a new SimConnect.Comm entry into the file as shown below:

<?xml version="1.0" encoding="Windows-1252"?>
<SimBase.Document Type="SimConnect" version="1,0">
    <Descr>SimConnect Server Configuration</Descr>
    <Filename>SimConnect.xml</Filename>
    <SimConnect.Comm>
        ...
    </SimConnect.Comm>
    ...
    <SimConnect.Comm>
        <Descr>Static Open IP4 port</Descr>
        <Protocol>IPv4</Protocol>
        <Scope>global</Scope>
        <Port>12345</Port>
        <MaxClients>64</MaxClients>
        <MaxRecvSize>41088</MaxRecvSize>
    </SimConnect.Comm>
</SimBase.Document>

Feel free to use any unused port that is available on your local installation. For connections from outside the local computer it may be necessary to open the port in the firewall of the machine, the flight simulator is running on.

Remember the port, you entered into the simconnect.xml file as it will be required when you want to call the connect method of the simconnect-java-util API.

For more information see the official documentation: https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_XML_Definition.htm

Does this project support connections to Flight Simulator X (FSX)?

This project mainly aims to implement a java client for the newer Flight Simulator 2020. Therefore, methods that were originally used for FSX but are marked as deprecated in the current simconnect API specification are not implemented.

It is possible that some methods are backwards compatible with FSX and these can be used for connections to FSX. However, this has not been tested and correct functioning cannot be guaranteed.

Examples of what you can do with the interface

You can build a panel showing some information about your plane and additional infos of your flight including some switches and instruments to show and use them on another machine or a secondary screen as i did in the following example:

SimViewer.java