I just figured it out yesterday from SimConnect B events are not sendable through SimConnect_TransmitClientEvent_EX1 as K events are.
To to that I first retrieve all the InputEvents loaded for the aircaft with SimConnect_EnumerateInputEvents and get the hash for the one that I want to trigger. Then I send * SimConnect_SetInputEvent* with the right value and I was able to emulate the click on the BAT 1 push button in the A320N that way, event ids way was not working since they are inhibited through the preset.
I guess this is why it’s erratic but I don’t know how to solve this. Plus, it seems it works less when the simulator just started (my code was mostly working yesterday but I’m unable to switch the battery on right now)
what’s the point of B events, if the user can’t set a keybind for those anyway?
I.e. why not just ‘set’ an L: var to 1 wherever you want to ‘trigger’ the event, and in the code that ‘handles’ the event you detect the non-zero L:var and the event handling code resets that L:var to zero ready for the next trigger. Super easy, works in every API subsystem.
The MSFS event-handling is a bit hit-and-miss between the different API subsystems, e.g. triggering a K: event in Javascript doesn’t get picked up by the Asobo_GIE event handling code in model XML but triggering the same event in a user controls keybind does get through to the XML.
There would be a benefit at least from a SimConnect perspective
They can be defined by the aircraft designer and you can call and/or observe them directly from SimConnect a bit like regular Key Events
LVars - yes you can read and write but conceptually a Var is not really an event and the LVar handling varies a lot, some expect a 1 to trigger, some expect N+1 to be sent etc. and one never knows…
However my experience is that some (many??) of those InputEvents (B-Events) are registered by aircrafts but then not monitored or they don’t execute as a complete event i.e. not triggering visuals - or only half (button remains pressed) or are just plainly ignored. Some just set an LVar behind scenes.
As with many of the various APIs there is no consistency which is then mostly trial and error when using them as 3rd party dev. (undocumented anyway)
And I don’t know if there is any motivation for acft devs to use, provide, and maintain them. Neither can they be mapped to the controllers attached.
Acft devs chime in and let us know what triggers your design choice to use B-Events (or not using them…)