Skip to content

Commit

Permalink
Merge pull request #716 from FalcoGer/master
Browse files Browse the repository at this point in the history
Fix broken display IDs for AH-64D causing selected radio detection not working
  • Loading branch information
ciribob authored Aug 11, 2024
2 parents 7e80289 + d4d9a47 commit d9c477e
Showing 1 changed file with 20 additions and 40 deletions.
60 changes: 20 additions & 40 deletions Scripts/DCS-SRS/Scripts/DCS-SimpleRadioStandalone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -739,24 +739,19 @@ function SR.exportRadioAH64D(_data)
_data.radios[6].encMode = 2 -- As of DCS ver 2.9.4.53627 the HF preset functionality is bugged, but I'll leave this here in hopes ED fixes the bug

local _seat = get_param_handle("SEAT"):get() -- PLT/CPG ?
local _eufdDevice = nil
local _mpdLeft = nil
local _mpdRight = nil
local _iffIdentBtn = nil
local _iffEmergency = nil

-- devices -- is plt? -- plt device -- cpg device
local _eufdDevice = (_seat == 0) and SR.getListIndicatorValue(18) or SR.getListIndicatorValue(19)
local _mpdLeft = (_seat == 0) and SR.getListIndicatorValue(7) or SR.getListIndicatorValue(11)
local _mpdRight = (_seat == 0) and SR.getListIndicatorValue(9) or SR.getListIndicatorValue(13)
local _iffIdentBtn = (_seat == 0) and SR.getButtonPosition(347) or SR.getButtonPosition(388) -- comm panel ident button
local _iffEmergency = (_seat == 0) and GetDevice(0):get_argument_value(404) or GetDevice(0):get_argument_value(428) -- Emergency Panel XPNDR Indicator

-- volume
local _masterVolume = (_seat == 0) and SR.getRadioVolume(0, 344, { 0.0, 1.0 }, false) or SR.getRadioVolume(0, 385, { 0.0, 1.0 }, false)
--intercom
_data.radios[1].volume = ((_seat == 0) and SR.getRadioVolume(0, 345, { 0.0, 1.0 }, false) or SR.getRadioVolume(0, 386, { 0.0, 1.0 }, false)) * _masterVolume

if _seat == 0 then
_eufdDevice = SR.getListIndicatorValue(18)
_mpdLeft = SR.getListIndicatorValue(7)
_mpdRight = SR.getListIndicatorValue(9)
_iffIdentBtn = SR.getButtonPosition(347) -- PLT comm panel ident button
_iffEmergency = GetDevice(0):get_argument_value(404) -- PLT Emergency Panel XPNDR Indicator

local _masterVolume = SR.getRadioVolume(0, 344, { 0.0, 1.0 }, false)

--intercom
_data.radios[1].volume = SR.getRadioVolume(0, 345, { 0.0, 1.0 }, false) * _masterVolume

-- VHF
if SR.getButtonPosition(449) == 0 then
_data.radios[2].volume = SR.getRadioVolume(0, 334, { 0.0, 1.0 }, false) * _masterVolume
Expand Down Expand Up @@ -797,17 +792,6 @@ function SR.exportRadioAH64D(_data)
end

else
_eufdDevice = SR.getListIndicatorValue(19)
_mpdLeft = SR.getListIndicatorValue(11)
_mpdRight = SR.getListIndicatorValue(13)
_iffIdentBtn = SR.getButtonPosition(388) -- CPG comm panel ident button
_iffEmergency = GetDevice(0):get_argument_value(428) -- CPG Emergency Panel XPNDR Indicator

local _masterVolume = SR.getRadioVolume(0, 385, { 0.0, 1.0 }, false)

--intercom
_data.radios[1].volume = SR.getRadioVolume(0, 386, { 0.0, 1.0 }, false) * _masterVolume

-- VHF
if SR.getButtonPosition(459) == 0 then
_data.radios[2].volume = SR.getRadioVolume(0, 375, { 0.0, 1.0 }, false) * _masterVolume
Expand Down Expand Up @@ -902,21 +886,17 @@ function SR.exportRadioAH64D(_data)
_data.radios[6].encKey = _eufdDevice["Cipher_HF"] and string.format("%01d", string.match(_eufdDevice["Cipher_HF"], "%d+"))
end

if (_mpdLeft or _mpdRight) then
if _mpdLeft["Mode_S_Codes_Window_text_1"] then -- We're on the XPNDR page on the LEFT MPD
_ah64Mode1Persist = _mpdLeft["PB24_9"] == "}1" and -1 or string.format("%02d", _mpdLeft["PB7_23"])
end

if _mpdRight["Mode_S_Codes_Window_text_1"] then -- We're on the XPNDR page on the RIGHT MPD
_ah64Mode1Persist = _mpdRight["PB24_9"] == "}1" and -1 or string.format("%02d", _mpdRight["PB7_23"])
end
if _mpdLeft and _mpdLeft["Mode_S_Codes_Window_text_1"] then
-- We're on the XPNDR page on the LEFT MPD
-- set to -1 (off) if Mode 1 is disabled, otherwise to mode 1 code
_ah64Mode1Persist = _mpdLeft["PB24_9"] == "}1" and -1 or string.format("%02d", _mpdLeft["PB7_23"])
elseif _mpdRight and _mpdRight["Mode_S_Codes_Window_text_1"] then
-- We're on the XPNDR page on the RIGHT MPD
_ah64Mode1Persist = _mpdRight["PB24_9"] == "}1" and -1 or string.format("%02d", _mpdRight["PB7_23"])
end

--CYCLIC_RTS_SW_LEFT 573 CPG 531 PLT
local _pttButtonId = 573
if _seat == 0 then
_pttButtonId = 531
end
local _pttButtonId = (_seat == 0) and 531 or 573

local _pilotPTT = SR.getButtonPosition(_pttButtonId)
if _pilotPTT >= 0.5 then
Expand Down

0 comments on commit d9c477e

Please sign in to comment.