Detecting MSFS2024

Is there any way to detect from js at an early stage that we are in MSFS 2024 (or 2020)?

4 Likes

I had the same question but I was too shy to ask it

I think a variable that can tell us on which simulator we are on may be very useful. We could “switch off” functions that do not work in MSFS2024, or enable some that will only work on it.

It should be a function, not a variable because the variable system may not be initialized too early.
There is already GamePlateform() that returns “PC” or “XBOX”.
We could have something like GameVersion() that returns “2020” or “2024”.

2 Likes

For now, the only way I had to determine whether it was 2024 or 2020 was through some detailed file checking of both the 2020’s common.js and the 2024’s common.js, and look for any JS types (classes or functions) declared in the 2024’s common.js file, that are not available on the 2020’s. This is something I made for the EMB-110’s EFB which reports the MSFS version number. However, if the common.js changes from 2024 eventually get backported to 2020, this would cause the detection not to work correctly, hence causing
 let’s say
 an “identity crisis” on either platform.

So, +1 for the idea from @ScorpionFilm422 of having a dedicated JS function declared that can help determine whether it’s 2024 or 2020.

Regards,
Carlos Daniel GonzĂĄlez GĂłmez
NextGen Simulations

1 Like

We would also need to detect the MSFS SDK framework version (2020 or 2024) used to manage the flight plan in the cockpit.

1 Like

BUMP.

we’re learning there are a lot of coding detail changes in MSFS2024 vs MSFS2020 (particularly anything to do with nav) and it’s crucial to be able to tell which sim you’re dealing with.

There must be some coding fragment that will reveal which sim is which, preferably using numeric simvars as that’s about the only thing supported in common between the various programming environments. I have issues in simconnect mods and also issues in html/js gauges (we glider pilots are heavily invested in nav support). The only method for simconnect we’re trying so far is to get the Windows Task List and search that for MSFS 2024. Crazy eh?

Anyone got any idea using in-sim simvars?

I experimented with the ‘new’ simvar “AIRCRAFT AGL” which is in the 2024 sdk docs but not 2020, and discovered that simvar does actually exist in 2020. otherwise AIRCRAFT AGL = 0 would be a winner,

2 Likes

We definitely need a Simvar for it

We are finding this to be essential to deal with the differences between 2020 and 2024.
A SimVar would be ideal, for example SimVersion=1 for 2024
2020 would return 0 because the simvar wouldn’t exist.
Versions after 2024 could be incremented.

Hope this can be added to help with the migration and, appreciate all the work done so far.

1 Like

hey if a simvar can be designed from scratch, SIMVERSION = 1010700 gives us the whole “1.1.7.0”

1 Like

still no official answer? due to large amount of differences between new and old sim, we have to apply exceptions anyhow. adding new simvar with static value is a 5 minutes deal.

best workaround I may think is try to enumerate some of the new variables. in FS2020 it returns 0, but such practice is dangerous as may cause unexpected result.

	ENUM test = get_aircraft_var_enum("GENDER");
	if (!test)
		fprintf(stderr, "MSFS2020 DETECTED!\n");
	else
		fprintf(stderr, "MSFS2024 DETECTED!\n");

Minimal example in C++/WASM:

bool gIsMSFS2024;

void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void* pContext)
{
	switch (pData->dwID)
	{
	case SIMCONNECT_RECV_ID_OPEN:
	{
		SIMCONNECT_RECV_OPEN* pOpen = (SIMCONNECT_RECV_OPEN*)pData;

		const char* applicationName = pOpen->szApplicationName;
		DWORD appVersionMajor = pOpen->dwApplicationVersionMajor;
		gIsMSFS2024 = appVersionMajor == 12 ? true : false;
	}
4 Likes