Matthew Twomey Posted October 26, 2020 Report Share Posted October 26, 2020 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? Link to comment Share on other sites More sharing options...
Matthew Twomey Posted October 26, 2020 Author Report Share Posted October 26, 2020 Ok - this seems to take care of it: handle, rd, rdf, wr, initreport = com.openhid(0x04D8, 0x8A3D); initreport = com.readreport(handle, 0); 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 ipc.log("val1: " .. com.gethidbuttons(handle, initreport)); I'm not sure if that com.readreport is the right approach, but it's working. If anyone has a thought on this, please share. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now