Closed Pomax closed 1 year ago
There is in the readme an indication of the samples folder. The sample folder has very good examples.
The samples folder seems to suggest every dev need to first implement the MSFS ("KittyHawk") simvar set themselves, though... that seems weird, am I reading this right? Is every dev expected to do this for themselves instead of there being a getter/setter class in the package for accessing the official simconnect simvars ?
(Especially given that the only official simconnect SDK is the MS one, so as a base you'd expect the list on https://docs.flightsimulator.com/html/Programming_Tools/SimVars/Simulation_Variables.htm to just be available, even if the enhanced versions of simconnect used by other software tacks on their own things)
It should work exactly equal to the official sim connect SDK, this code it basically a wrapper for the UDP communication. To set and get the sim vars here you should do exactly what you need to do in the official sim connect SDK.
To do that is one abstraction level more, which I think isn't the purpose of this library.
Cheers. That's unfortunate. I was hoping someone'd written a Node library to use SimConnect in a "general JS API" way (normal getter/setters, out of the box addEventListener, etc), rather than a JS emulation of a C++ SDK =)
That said, given that I'm getting kinda fed up with Python's absolute nonsense threading model just to get a simple setTimeout going, I might just wget the MSFS docs, and create the "Feels like JS" wrapper API on top of this myself. Then rewrite my article from "Flying planes with Python and JavaScript" to "Flying planes with JavaScript".
Adding another abstraction level with functions for all available simulation variables etc. would be a quite comprehensive project in itself, I imagine. node-simconnect is supposed to provide only the bare minimums required to interact with SimConnect without having to write dll-bindings or using a .net-application as a proxy. If someone can use node-simconnect as a foundation for developing a more user friendly library on top of it, they are very welcome to do so! π
Since the readme is quire long already, I think it's better to leave most of the samples outside of it. Did you find all you needed in the samples folder?
Fair enough. In the mean time, because I'm disliking python enough at this point, I may have started this anyway.
So if that's something that feels like it might be useful to add as something that other users can file PRs against, I'd be more than happy to submit for inclusion here.
In terms of samples, I think it might even make sense to not have the single mjs file anymore, the TS code is light enough on the typing that any JS dev should be able to read them, without having to wonder which dir to look in.
Created a repo where I'll be plodding along for a bit while I implement the entirety of the MSFS SimConnect simvar list... which is a chore, absolutely, but also not too hard with the Hades OST playing in the background.
https://github.com/Pomax/msfs-simconnect-api-wrapper currently has 845 passing simvars, although I had to comment off a bunch that use the LatLonAlt data type because I did something wrong and it made node-simconnect stall. Decent enough progress for one day though, so I'll pick up the outstanding simvars (some will be missing, but I'd like the camera and system vars in addition to the aircraft vars at least) tomorrow.
And done. https://github.com/Pomax/msfs-simconnect-api-wrapper now supports all simvars, all system events, and allows triggering of all simevents. I'll spend the weekend porting all my python code over, which should hopefully reveal any errors I made with node-simconnect calls, but barring those, this might be a "less powerful, but easy to use" JS package for talking to MSFS
(because of course the more options folks have to write some code against MSFS, the bigger the community gets! =D)
That was quick! Your project looks awesome! I will add a link to it in the README once itβs on npm π
Yeah, it turns out that the MSFS docs are actually really well structured, so you can just copy-paste from the website and have a list that you can relatively easily (with some massaging of course) regex into perfectly servicible JS =D
Just published the project to NPM (with the classic three immediate "oh shit I forgot to..." minor/patch updates!) so it should be live over on https://www.npmjs.com/package/msfs-simconnect-api-wrapper now.
Hm, looks like I'm doing something wrong wrt data request, so I may need to dig through the docs - right now after 1000 get/set, the SDK throws a SIMCONNECT_EXCEPTION_TOO_MANY_OBJECTS
at me, so even though I'm calling handle.clearDataDefinition(REQUEST_ID)
after I've received the associated simObjectData
event , that's not actually clearing what I'm thinking it would clear... =/
never mind, false alarm. Well, "ish": I had written the get()
calls to clean up after themselves, but forgot to do the same for the set
calls, and since the code I'm testing is an autopilot that's setting several trim and control values per second, it ran out of unallocated IDs pretty quickly. Fixed it, pushed up a new version of the library (v1.1.8), and I've had it running a flight set to JS-based autopilot for about 10 minutes now without getting any exceptions.
Good call @Pomax .
Unlike python-simconnect, there does not appear to be anything in the readme that shows how to actually get and set simvars. Can the example be updated to show how to work with those?