Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.
You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks!
The community support for MobiFlight has moved exclusively over to our Discord server. Register for free and enjoy more interactive functions like image and video upload, voice chat. More than 7,000 registered users around the world make it a great experience!
See you on our MobiFlight Community Discord server.
A HUGE Thank You to everyone who participated in the forum, especially obviously to Pizman and Stephan who did an outstanding job over so many years providing an incredible service to the MobiFlight community.
The forum is still providing a lot of good content, hence we keep this information accessible.
Code:event.offset(offset, "type", "function-name")
Code:ipc.log("\n\n") ipc.log("MobiFlight: Start") ipc.setowndisplay("MobiFlight Lua", 0, 60, 6, 1) function mfFunction(offset, value) ipc.display("MobiFlight " .. value) end event.offset(0x66C0, "UB", "mfFunction")
Code:ipc.runlua('mobiflight')
When realasing that long press he swaps freq.. I have set up the single press to swap freq, so i guess when i release the long press, he Thinks i wanna swap freq.
Code:-- Example of making a single button give three separate uses: -- To keep things relatively simple, here we deal with one -- specific button (defined as joystick 1, button 0 below). -- But you could generalise this and have multple buttons, -- each with multiple actions -- The multiple use is obtained by a simple method: -- A short press and release (like a mouse click) -- A double short press and release (like a double click) -- A press held for longer (over half second) -- Just for a visible example which can be applied easily, -- here a single button is used to select left view, right -- and forward view, using FS controls. You could just as -- easily send keypresses or sequences of either. -- Single short press = left view (VIEW LEFT = 65680) -- Two short presses = right view (VIEW RIGHT = 65676) -- A longer press = frward view (VIEW FRWARD = 65674) joy = 1 btn = 0 interval = 500 -- 1/2 second press, gap, press limits -- Function to time the button being pressed or left released -- Allow only up to "interval" till decide no change local function timebutton(test) while true do time2 = ipc.elapsedtime() if (time2 - time1) > interval then return false end if ipc.testbutton(joy, btn) == test then time1 = time2 return true end ipc.sleep(20) end end function buttonpress(j, b, du) -- Cancel event so we don't get called again for double press event.cancel("buttonpress") -- Note time button was pressed time1 = ipc.elapsedtime() if timebutton(false) then -- First press / release counts: see if there's another if timebutton(true) then -- got another press in time, look for release if timebutton(false) then -- this was a double press, send VIEW RIGHT ipc.control(65676) end else -- This was a single press, send VIEW LEFT ipc.control(65680) end else -- This was a longer press, send VIEW FORWARD ipc.control(65674) end -- Restore cancelled event event.button(joy, btn, 1, "buttonpress") end -- Enable event on button being pressed (only) event.button(joy, btn, 1, "buttonpress")
Code:joy = 20 btn = 5 interval = 500 -- 1/2 second press, gap, press limits ignorepress = false local function timebutton(test) ignorepress = true while true do time2 = ipc.elapsedtime() if (time2 - time1) > interval then ignorepress = false return false end if ipc.testbutton(joy, btn) == test then time1 = time2 return true end ipc.sleep(20) end end function buttonpress(j, b, du) if ignorepress then ignorepress = false return end -- ipc.log("buttonpress called " .. j .. " " .. b .. " " .. du) time1 = ipc.elapsedtime() time2 = 0 if timebutton(false) then -- First press / release counts: see if there's another if timebutton(true) then -- got another press in time, look for release if timebutton(false) then -- this was a double press, CS6 ipc.keypress(54,11) end else -- This was a single press, send CS7 ipc.keypress(55,11) ignorepress = false end else -- This was a single long press, send CS2 ipc.keypress(50,11) end end event.button(joy, btn, 1, "buttonpress")
I tried the offsets to run a Lua Script without success. Everything was prepared but I was not able to run a lua script e.g. by Name.
I understand the documentation like this:
send "LuaRun:MyLuaScript" to Offset 0x0D70