init
This commit is contained in:
commit
9b2c46c776
2 files changed
+387
No files matched your search
@@ -0,0 +1,343 @@
|
||||
-- Garmin GNS430 overlay for X-Plane --
|
||||
-- Message Raspberry Pi and tablet
|
||||
if instrument_prop("PLATFORM") == "RASPBERRY_PI" or instrument_prop("PLATFORM") == "ANDROID" or instrument_prop("PLATFORM") == "IPAD" then
|
||||
canvas_add(195, 40, 437, 239, function()
|
||||
_rect(0,0,437,239)
|
||||
_fill("black")
|
||||
end)
|
||||
canv_message = canvas_add(195, 40, 437, 239, function()
|
||||
_rect(0,0,437,239)
|
||||
_fill("blue")
|
||||
_txt("THIS X-PLANE 11 AND FS2020 GPS OVERLAY", "font:roboto_bold.ttf; size:26; color: white; halign:center;", 218, 60)
|
||||
_txt("WORKS ON THE DESKTOP ONLY", "font:roboto_bold.ttf; size:26; color: white; halign:center;", 218, 90)
|
||||
_txt("BUTTONS AND DIALS STILL WORK", "font:roboto_bold.ttf; size:26; color: white; halign:center;", 218, 120)
|
||||
_txt("CLICK HERE TO HIDE THIS MESSAGE", "font:roboto_bold.ttf; size:26; color: white; halign:center;", 218, 150)
|
||||
end)
|
||||
butn_hide = button_add(nil, nil, 195, 40, 437, 239, function()
|
||||
visible(canv_message, false)
|
||||
visible(butn_hide, false)
|
||||
end)
|
||||
end
|
||||
-- Message desktop
|
||||
pers_msg_read = persist_add("msg_read", false)
|
||||
if (instrument_prop("PLATFORM") == "WINDOWS" or instrument_prop("PLATFORM") == "MAC" or instrument_prop("PLATFORM") == "LINUX") and not persist_get(pers_msg_read) then
|
||||
canv_message = canvas_add(195, 40, 437, 239, function()
|
||||
_rect(0,0,437,239)
|
||||
_fill("blue")
|
||||
_txt("THIS IS AN OVERLAY ONLY", "font:roboto_bold.ttf; size:26; color: white; halign:center;", 218, 60)
|
||||
_txt("IT REQUIRES THE FLIGHTSIM GPS POP OUT", "font:roboto_bold.ttf; size:26; color: white; halign:center;", 218, 90)
|
||||
_txt("SEE OUR WIKI FOR MORE INFORMATION", "font:roboto_bold.ttf; size:26; color: white; halign:center;", 218, 120)
|
||||
_txt("CLICK HERE TO HIDE THIS MESSAGE", "font:roboto_bold.ttf; size:26; color: white; halign:center;", 218, 150)
|
||||
end)
|
||||
butn_hide = button_add(nil, nil, 195, 40, 437, 239, function()
|
||||
visible(canv_message, false)
|
||||
visible(butn_hide, false)
|
||||
persist_put(pers_msg_read, true)
|
||||
end)
|
||||
end
|
||||
|
||||
img_add_fullscreen("Garmin_430_2d.png")
|
||||
|
||||
gps_no = user_prop_add_enum("Selected GPS unit","GPS 1,GPS 2","GPS 2","Select GPS Unit to control")
|
||||
rxp_ctrl = user_prop_add_enum("Type","Default,Reality XP","Default","For X-Plane select default or Reality XP")
|
||||
local g_unit = fif(user_prop_get(gps_no)=="GPS 1", 1, 2)
|
||||
local g_unit_fsx = fif(user_prop_get(gps_no)=="GPS 1", 0, 8)
|
||||
local g_ctrl = fif(user_prop_get(rxp_ctrl)=="Default", 1, 2)
|
||||
|
||||
--volume dials
|
||||
pwr_knob = dial_add("pwr_off.png", 50,36,38,38,function (position)
|
||||
if position == 1 then
|
||||
fsx_event("GPS_POWER_BUTTON", 4 + g_unit_fsx)
|
||||
elseif position == -1 then
|
||||
fsx_event("GPS_POWER_BUTTON", 2 + g_unit_fsx)
|
||||
end
|
||||
end)
|
||||
|
||||
vvol_knob = dial_add("vvol.png", 50,109,38,38,function (position)
|
||||
if position == 1 then
|
||||
fsx_event("GPS_ACTIVATE_BUTTON", 4 + g_unit_fsx)
|
||||
elseif position == -1 then
|
||||
fsx_event("GPS_ACTIVATE_BUTTON", 2 + g_unit_fsx)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Buttons --
|
||||
button_com = button_add(nil, nil, 55,41,28,28,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_cvol")
|
||||
else
|
||||
xpl_command("RXP/GNS/PWR_PUSH_" .. g_unit)
|
||||
end
|
||||
end)
|
||||
|
||||
button_vlc = button_add(nil, nil, 55,114,28,28,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_vvol")
|
||||
else
|
||||
xpl_command("RXP/GNS/VOL_PUSH_" .. g_unit)
|
||||
end
|
||||
end)
|
||||
|
||||
button_swc = button_add(nil, nil, 135,50,38,60,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_com_ff")
|
||||
else
|
||||
xpl_command("RXP/GNS/CFLP_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_COMSWAP_Push")
|
||||
|
||||
if g_unit_fsx == 0 then
|
||||
fsx_event("COM_STBY_RADIO_SWAP")
|
||||
elseif g_unit_fsx == 8 then
|
||||
fsx_event("COM2_RADIO_SWAP")
|
||||
end
|
||||
end)
|
||||
|
||||
button_swn = button_add(nil, nil, 135,133,38,60,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_nav_ff")
|
||||
else
|
||||
xpl_command("RXP/GNS/VFLP_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_NAVSWAP_Push")
|
||||
|
||||
if g_unit_fsx == 0 then
|
||||
fsx_event("NAV1_RADIO_SWAP")
|
||||
elseif g_unit_fsx == 8 then
|
||||
fsx_event("NAV2_RADIO_SWAP")
|
||||
end
|
||||
end)
|
||||
|
||||
button_cdi = button_add(nil, nil, 204,290,58,34,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_cdi")
|
||||
else
|
||||
xpl_command("RXP/GNS/CDI_" .. g_unit)
|
||||
end
|
||||
fs2020_event("TOGGLE_GPS_DRIVES_NAV1")
|
||||
fsx_event("GPS_NEAREST_BUTTON", g_unit_fsx)
|
||||
end)
|
||||
|
||||
button_obs = button_add(nil, nil, 295,290,58,34,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_obs")
|
||||
else
|
||||
xpl_command("RXP/GNS/OBS_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_OBS_Push")
|
||||
fsx_event("GPS_OBS_BUTTON", g_unit_fsx)
|
||||
end)
|
||||
|
||||
button_msg = button_add(nil, nil, 384,290,58,34,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_msg")
|
||||
else
|
||||
xpl_command("RXP/GNS/MSG_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_MSG_Push")
|
||||
fsx_event("GPS_MSG_BUTTON", g_unit_fsx)
|
||||
end)
|
||||
|
||||
button_fpl = button_add(nil, nil, 476,290,58,34,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_fpl")
|
||||
else
|
||||
xpl_command("RXP/GNS/FPL_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_FPL_Push")
|
||||
fsx_event("GPS_FLIGHTPLAN_BUTTON", g_unit_fsx)
|
||||
end)
|
||||
|
||||
button_prc = button_add(nil, nil, 565,290,58,34,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_proc")
|
||||
else
|
||||
xpl_command("RXP/GNS/PROC_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_PROC_Push")
|
||||
fsx_event("GPS_PROCEDURE_BUTTON", g_unit_fsx)
|
||||
end)
|
||||
|
||||
button_rup = button_add(nil, nil, 653,30,64,40,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_zoom_out")
|
||||
else
|
||||
xpl_command("RXP/GNS/RUP_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_RNG_Dezoom")
|
||||
fsx_event("GPS_ZOOMOUT_BUTTON", g_unit_fsx)
|
||||
end)
|
||||
|
||||
button_rdn = button_add(nil, nil, 717,30,64,40,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_zoom_in")
|
||||
else
|
||||
xpl_command("RXP/GNS/RDN_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_RNG_Zoom")
|
||||
fsx_event("GPS_ZOOMIN_BUTTON", g_unit_fsx)
|
||||
end)
|
||||
|
||||
button_dir = button_add(nil, nil, 652,80,58,38,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_direct")
|
||||
else
|
||||
xpl_command("RXP/GNS/DTO_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_DirectTo_Push")
|
||||
fsx_event("GPS_DIRECTTO_BUTTON", g_unit_fsx)
|
||||
end)
|
||||
|
||||
button_men = button_add(nil, nil, 725,80,58,38,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_menu")
|
||||
else
|
||||
xpl_command("RXP/GNS/MNU_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_MENU_Push")
|
||||
fsx_event("GPS_MENU_BUTTON", g_unit_fsx)
|
||||
end)
|
||||
|
||||
function callback_clr_down()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_clr", 1)
|
||||
else
|
||||
xpl_command("RXP/GNS/CLR_" .. g_unit, 1)
|
||||
end
|
||||
timer_clear = timer_start(2000, function()
|
||||
fs2020_event("H:AS430_CLR_Push_Long")
|
||||
fsx_event("GPS_CLEAR_ALL_BUTTON", g_unit_fsx)
|
||||
end)
|
||||
end
|
||||
function callback_clr_up()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_clr", 0)
|
||||
else
|
||||
xpl_command("RXP/GNS/CLR_" .. g_unit, 0)
|
||||
end
|
||||
if timer_running(timer_clear) then
|
||||
timer_stop(timer_clear)
|
||||
fs2020_event("H:AS430_CLR_Push")
|
||||
fsx_event("GPS_CLEAR_BUTTON", g_unit_fsx)
|
||||
end
|
||||
end
|
||||
|
||||
button_clr = button_add(nil, nil, 652,130,58,38,callback_clr_down,callback_clr_up)
|
||||
|
||||
button_ent = button_add(nil, nil, 725,130,58,38,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_ent")
|
||||
else
|
||||
xpl_command("RXP/GNS/ENT_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_ENT_Push")
|
||||
fsx_event("GPS_ENTER_BUTTON", g_unit_fsx)
|
||||
end)
|
||||
|
||||
-- Dial PUSH C/V
|
||||
dial_cv_big = dial_add(nil, 2,200,130,130,function(direction)
|
||||
if direction == 1 then
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_coarse_up")
|
||||
else
|
||||
xpl_command("RXP/GNS/COM_OUTR_CW_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_LeftLargeKnob_Right")
|
||||
fsx_event("GPS_BUTTON2", g_unit_fsx)
|
||||
elseif direction == -1 then
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_coarse_down")
|
||||
else
|
||||
xpl_command("RXP/GNS/COM_OUTR_CCW_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_LeftLargeKnob_Left")
|
||||
fsx_event("GPS_BUTTON3", g_unit_fsx)
|
||||
end
|
||||
end)
|
||||
|
||||
dial_cv_sml = dial_add(nil, 28,228,78,78,function(direction)
|
||||
if direction == 1 then
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_fine_up")
|
||||
else
|
||||
xpl_command("RXP/GNS/COM_INNR_CW_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_LeftSmallKnob_Right")
|
||||
fsx_event("GPS_BUTTON4", g_unit_fsx)
|
||||
elseif direction == -1 then
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_fine_down")
|
||||
else
|
||||
xpl_command("RXP/GNS/COM_INNR_CCW_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_LeftSmallKnob_Left")
|
||||
fsx_event("GPS_BUTTON5", g_unit_fsx)
|
||||
end
|
||||
end)
|
||||
|
||||
mouse_setting(dial_cv_sml, "CURSOR_LEFT", "ctr_cursor_ccw.png")
|
||||
mouse_setting(dial_cv_sml, "CURSOR_RIGHT", "ctr_cursor_cw.png")
|
||||
|
||||
button_pcv = button_add(nil, nil, 47,247,40,40,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_nav_com_tog")
|
||||
else
|
||||
xpl_command("RXP/GNS/COM_PUSH_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_LeftSmallKnob_Push")
|
||||
fsx_event("GPS_BUTTON1", g_unit_fsx)
|
||||
end)
|
||||
|
||||
-- Dial PUSH CRSR
|
||||
dial_cr_big = dial_add(nil, 668,196,130,130,function(direction)
|
||||
if direction == 1 then
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_chapter_up")
|
||||
else
|
||||
xpl_command("RXP/GNS/GPS_OUTR_CW_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_RightLargeKnob_Right")
|
||||
fsx_event("GPS_GROUP_KNOB_INC", g_unit_fsx)
|
||||
elseif direction == -1 then
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_chapter_dn")
|
||||
else
|
||||
xpl_command("RXP/GNS/GPS_OUTR_CCW_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_RightLargeKnob_Left")
|
||||
fsx_event("GPS_GROUP_KNOB_DEC", g_unit_fsx)
|
||||
end
|
||||
end)
|
||||
|
||||
dial_cr_sml = dial_add(nil, 694,224,78,78,function(direction)
|
||||
if direction == 1 then
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_page_up")
|
||||
else
|
||||
xpl_command("RXP/GNS/GPS_INNR_CW_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_RightSmallKnob_Right")
|
||||
fsx_event("GPS_PAGE_KNOB_INC", g_unit_fsx)
|
||||
elseif direction == -1 then
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_page_dn")
|
||||
else
|
||||
xpl_command("RXP/GNS/GPS_INNR_CCW_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_RightSmallKnob_Left")
|
||||
fsx_event("GPS_PAGE_KNOB_DEC", g_unit_fsx)
|
||||
end
|
||||
end)
|
||||
|
||||
mouse_setting(dial_cr_sml, "CURSOR_LEFT", "ctr_cursor_ccw.png")
|
||||
mouse_setting(dial_cr_sml, "CURSOR_RIGHT", "ctr_cursor_cw.png")
|
||||
|
||||
button_pcr = button_add(nil, nil, 713,243,40,40,function()
|
||||
if g_ctrl == 1 then
|
||||
xpl_command("sim/GPS/g430n" .. g_unit .. "_cursor")
|
||||
else
|
||||
xpl_command("RXP/GNS/GPS_PUSH_" .. g_unit)
|
||||
end
|
||||
fs2020_event("H:AS430_RightSmallKnob_Push")
|
||||
fsx_event("GPS_CURSOR_BUTTON", g_unit_fsx)
|
||||
end)
|
||||
Reference in new issue
Block a user