Jump to content
The simFlight Network Forums

Henrik Bergvin

Members
  • Posts

    25
  • Joined

  • Last visited

1 Follower

Profile Information

  • Gender
    Male
  • Location
    Norway

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Henrik Bergvin's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. This I fully get behind, there's no reason to operate a queue for an IPCparam since it's not really supposed to handle rapid presses. On the reverser levers on my Honeycomb Bravo, I just place my hands behind and pull them both simultaneously. It is most probably not simultaneous by millisecond, but their status is most probably handled by the same poll of the hid device, and as such it will appear as if they were triggered simultaneously. That could work, but that would mean two identical files with different names, doing the same thing... I'll stick to event.button, it seems robust 🙂
  2. Perfect, so event.button shouldn't miss any presses even if the script is busy. Thank you for your help!
  3. Cheers! Are there any drawbacks for using event.button? I quite like having as much as possible in lua files (since I can work on them without the sim running and do logic based on which buttons are held etc), and it wouldn't be a big matter for me to make some form of system where I define button presses like this: left_reverser_activate = { button = { 4, 9, 1 }, -- button 4,9 is pressed action = { "B777.ReverserLever", "left", "activate" }, -- B777.ReverserLever("left", "activate") }, left_reverser_off = { button = { 4, 9, 0 }, -- button 4,9 is released action = { "B777.ReverserLever", "left", "off" }, -- B777.ReverserLever("left", "off") } Using the above, I could just loop through all the actions and register events for the presses. I know the binding facility built into FSUIPC is nice and all, but once you start doing something more complex (like, tracking several variables), Lua is really the way to go. Oh! If a lua script is running something and a button press happens, will event.button be queued and run when the script is "awake" again?
  4. Correct, the problem is that there are two LuaValue params sent to the same script at the same time, and only one is captured. By using event.param, it's simply not able to capture both if they are immediate/simultaneous. Unless you have a better suggestion, I'll use event.button, since it seems fast enough to capture the buttons rapidly. Speed isn't the issue here at all 🙂
  5. I tried on .12, but didn't get any particular better LuaValue/event.param triggers. I did, however, get a lot better result using event.button, those would trigger almost at the same time and the script would capture them even faster than event.param.
  6. I was on 6.0.9, I'm now updating to 6.0.12 to give it a try. I'll report back!
  7. Maybe @Pete Dowson can shed some light on this: 32283172 Button changed: bRef=0, Joy=4 (E), Btn=9, Pressed 32283172 [Buttons.PMDG 777F Arctic Air] 104=PE,9,C65820,-1 32283172 FS Control Sent: Ctrl=65820, Param=-1 THROTTLE1_SET 32283172 Button changed: bRef=0, Joy=4 (E), Btn=10, Pressed 32283172 [Buttons.PMDG 777F Arctic Air] 108=PE,10,C65821,-1 32283172 FS Control Sent: Ctrl=65821, Param=-1 THROTTLE2_SET 32283172 Button changed: bRef=0, Joy=4 (E), Btn=9, Pressed 32283172 Button changed: bRef=0, Joy=4 (E), Btn=10, Pressed 32486672 Button changed: bRef=0, Joy=4 (E), Btn=9, Pressed 32486672 [Buttons.PMDG 777F Arctic Air] 104=PE,9,CL41:V,406 32486672 Button changed: bRef=0, Joy=4 (E), Btn=10, Pressed 32486672 [Buttons.PMDG 777F Arctic Air] 108=PE,10,CL41:V,409 32486672 Button changed: bRef=0, Joy=4 (E), Btn=9, Pressed 32486672 Button changed: bRef=0, Joy=4 (E), Btn=10, Pressed 32486672 LUA.3: Param: 409 Above are two log excerpts - one where I am sending FS Controls, and one where I'm sending a LuaValue change. As you can see, only param 409 comes through on the LuaValue example... Can Lua capture changes faster somehow? The buttons are definitely caught.
  8. so, I changed to a poll rate of 10, and it still wouldn’t update the lua script enough. However, I can do normal controls and standard Fs actions at near simultaneous trigger. So it lies in the communication with the Lua script. I’ll keep digging. Maybe event.button might be a thing here.
  9. Honeycomb Bravo for the reversers, so each reverse lever is a button push/release. While it would work setting the controls directly (throttle set to -1 to activate rev, throttle cut or set to 0 to cancel reverse), I have other logic I want to run (such as moving the thrust levers I to their bottom detent to command max reverse, but only if I have already flipped reverse levers...) What I have found in today’s testing is that the LuaValue and LuaToggle functionality isn’t being processed fast enough. Button presses and binds work fine but the lua script isn’t receiving and processing the events fast enough on near simultaneous presses.
  10. I'll give that a shot, see if a 15ms interval helps. I've dabbled a bit with hid reading through the com library, and in that I could always capture all the buttons changed even with 40ms polling.. It's not as simple though for the bravo, since it seems to be sending some "ghost" presses now and then that I can't just filter - therefore I went for the standard binding and passing params via LuaValue.
  11. I've picked up the Honeycomb Bravo throttle, which is a really amazing piece of software. Not before having had something that can do reversers properly, I set about programming it. I have a LUA script with an event.param listening for LuaValue (ipcParam) changes. I then have a function as described below to handle the reverser states (for further logic that is not relevant for this support question). -- this is in pmdg_b777_functions.lua B777 = { engines = { [1] = { name = "left", rev = false, rev_fraction_offset = 0x207C, control = 65820 }, [2] = { name = "right", rev = false, rev_fraction_offset = 0x217C, control = 65821 }, function B777.Reverser(engine, mode) if mode == "off" then -- reversers to off ipc.control(B777.engines[engine].control, 0) elseif mode == "activate" then -- reversers from off to idle ipc.control(B777.engines[engine].control, -1) end end return B777 -- The following is in the main script B777 = require('pmdg_b777_functions') param_table = { [406] = function() B777.Reverser(1, "activate") end, [407] = function() B777.Reverser(1, "off") end, [409] = function() B777.Reverser(2, "activate") end, [410] = function() B777.Reverser(2, "off") end, } function b777_param(param) ipc.log("Param: " .. param) if param_table[param] ~= nil then param_table[param]() return end end event.param("b777_param") Now, individually each reverser lever works exactly as they should. I set it to reverse, it sets the axis to -1 (which is basically reverser idle), and when I release the button it sets it to idle (axis to 0). Now to my issue - when landing you tend to flip the reverse levers more or less simultaneously. This does not always seem to trigger both of them. If I flip both left and right engine reverser levers at the same time, I tend to get param 406, but not 409. Sometimes it is the other way around and I get 409, but not 406. Note - I'm using a table for parameter lookup here, but it isn't exclusive to this script. I'm also using the hidAlphaButtons and hidBravoButtons scripts (from here https://forum.simflight.com/topic/91599-lua-scripts-for-honeycomb-bravo-quadrant-and-alpha-flight-controls-buttons-32/) Is there a good way to catch multiple button presses that are nigh on simultaneous? This goes for both press and releases in this case..
  12. Yeah, I'll do that. While I have you here, I'm doing polling at a rate of 25 per second. Right now it's on 2 devices, but will that be safe to do on 3-4 devices without causing any issues? I have absolutely no issues with delays using the COM library, but as with everything, as you increase the amount of devices... yeah. I was also considering a faster poll rate to accommodate for a 20ms delay, 10ms repeat on held buttons (that's default in FSUIPC isn't it?).
  13. Since I like to do things the hard way around, I have written a "generic" HID device handler for advanced button functionality, using the COM library. I've got tracking of button presses and releases right now, and events firing based on what button is pressed (B1_Press, B1_Release, etc), and fairly simple handling for this from lua scripts. Next up for me is to implement repeats and double presses. Right now, I'm polling the devices using an event.timer call on a poll rate of 1000/25 (that should be every 40ms?), and it feels very stable and I never seem to "miss" any events. However, I'm at a bit of a loss here regarding what event.timer is sending to the poll function. In the documentation it says "The time provided is NOT the same as the one returned by the ipc.elapsedtime function", but it actually doesn't say what time is provided. This information is rather vital for me if I'm to track double clicks or repeats in the script. Is it elapsed time, or is it time since last time the timer fired?
  14. Understood. I do find using LuaValue a bit faster than Lua for param based scripts, so I'll stick to that in the future. I'll bind a push button to kill and restart the script for testing purposes.
  15. It seems that using that method is a little better, I haven't had any issues with focus after trying those. As for Lua scripts, is it better to call scripts using "Lua ScriptName" and a param, or do you recommend using the param event and passing LuaValue? I imagine events are queued and read one by one, so if two fire rapidly the script will run for the second once it is done with the first?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.