Looking for the easiest way to get the button state from a controller in a lua script that I'm running as "Auto" when FSUIPC starts up. My code is working, but things don't fall into place until I put some input on the controller I'm mapping. As soon as I provide any input - everything starts acting as expected.
I tried using the initreport from com.openhid, but I may not be doing this right. Here's what I'm at with this:
handle, rd, rdf, wr, initreport = com.openhid(0x04D8, 0x8A3D);
for i = 0, 3, 1 do
local state = com.testhidbutton(handle, i, initreport);
if (state) then
ipc.log(i .. ": on");
else
ipc.log(i .. ": off");
end
end
Regardless of the actual button state (actual physical switches in my case), all buttons come back as false, until I trigger any button - at which point they all immediately start reporting correctly. Is there a way to force it to "scan" the controller, or maybe I'm just doing it wrong?