nguyenquyhy / Flight-Tracker-StreamDeck

A Stream Deck plugin to interact with Microsoft Flight Simulation
https://flightsim.to/file/3178/flight-tracker-streamdeck-plugin
GNU General Public License v3.0
373 stars 68 forks source link

Enums (TOGGLE_VALUE and TOGGLE_EVENT) removal + LVAR reading support added #286

Closed Kirikou974 closed 1 year ago

nguyenquyhy commented 3 years ago

I have been trying to implement this too, but have never managed enough time to finish it. I would like to give you a bit more context on the initial design and some one my concerns when implementing this. I hope you can help me to clarify if the PR already addressed those concerns.

  1. Right now, all variables in a Stream Deck page are registered in 1 data request, and they are returned in a single packet. This allows the plugin to request the data at very high rate without worrying about affecting sim performance, even with many buttons. However, it has a downside that leads to the TOGGLE_VALUE allowlist: if one of the variable is invalid, SimConnect will still return a double array that lacks one element, and there is no clear way to tell which one is lacking. Even the error event is asynchronous and doesn't have enough data to easily tell. As my goal for this plugin is to make sure it is as easy to use as possible, I will insist on handling that kind of error properly. Right now without the list, a single invalid variable can disable the whole page.
  2. Same concern for Event and L-VAR, what happens when someone input an invalid event and hold the button? I have seen SimConnect acted crazy in this scenario, but that might just be some bugs in early sim update.
  3. Not really a concern, but I don't plan to remove TOGGLE_VALUE and TOGGLE_EVENT any time soon, even after I can remove the current restriction on the 2 lists. I am imagining that those 2 lists are to facilitate auto-complete feature in the future. Basically, if users know what they are doing, I don't want to put unnecessary restriction, otherwise, I would like to give some guide on what to fill in.
Kirikou974 commented 3 years ago
  1. For LVARS, MobiFlight WASM module does not complain. For normal feedback values : I didn't check or test thoroughly yet but it looks like with the RequestDataOnSimObject function, we could achieve something good performance wise since it looks like it can be used with a "on data change" kind of way. This is pretty much like the RequestClientData I've been using for LVARS that has a "ON_SET" flag that can be used so that the event handler is only called when something changes in the LVAR which is pretty neat IMHO
  2. I found a way to correlate an error with the mapping of an event with "MapClientEventToSimEvent". This needs testing (and a visual feedback for the user) but it's looking OK. Indeed if those kind of errors are not catched, all sorts of weird things happens with simconnect
  3. Completely agree
nguyenquyhy commented 3 years ago
  1. Yah SimConnect doesn't complain either, it just doesn't include the value in the returned value (hence you might see error message like "Expected array of 12, got array of 11." In this case we have no way to know which item is missing in the array and just ignore the whole array completely.
  2. I checked your commit on this. I have more or less the same change on my local. Should have tried to finish and push that earlier 😅.
Kirikou974 commented 3 years ago

Hey @nguyenquyhy, I've been thinking about how to handle errors for normal vars. I came up with a possible solution. The idea is that :

Let me know what you think about that.

nguyenquyhy commented 1 year ago

Replaced by af37aaf85b82bd35f8cee2dc994840e21f4a24cf with new SimConnect support for L-Var.