Skip to content

Commit 92460b9

Browse files
committed
Reinjected into Data.lua
1 parent 6eee829 commit 92460b9

File tree

1 file changed

+21
-13
lines changed
  • DCS-Input-Command-Injector-Quaggles/DCS-Input-Command-Injector-Quaggles/Scripts/Input

1 file changed

+21
-13
lines changed

DCS-Input-Command-Injector-Quaggles/DCS-Input-Command-Injector-Quaggles/Scripts/Input/Data.lua

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -557,19 +557,19 @@ local wizard_assigments
557557
--[[
558558
Insert this code into "DCSWorld\Scripts\Input\Data.lua" above the function "loadDeviceProfileFromFile"
559559
Then add the line:
560-
QuagglesInputCommandInjector(filename, folder, env, result)
560+
QuagglesInputCommandInjector(deviceGenericName, filename, folder, env, result)
561561
into the "loadDeviceProfileFromFile" function below the line:
562562
status, result = pcall(f)
563563
]]--
564564
local quagglesLogName = 'Quaggles.InputCommandInjector'
565565
local quagglesLoggingEnabled = false
566-
local function QuagglesInputCommandInjector(filename, folder, env, result)
566+
local function QuagglesInputCommandInjector(deviceGenericName, filename, folder, env, result)
567567
-- Returns true if string starts with supplied string
568568
local function StartsWith(String,Start)
569569
return string.sub(String,1,string.len(Start))==Start
570570
end
571571

572-
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, 'Detected loading of: '..filename) end
572+
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, 'Detected loading of type: "'..deviceGenericName..'", filename: "'..filename..'"') end
573573
-- Only operate on files that are in this folder
574574
local targetPrefixForAircrafts = "./Mods/aircraft/"
575575
local targetPrefixForDotConfig = "./Config/Input/"
@@ -585,15 +585,15 @@ local function QuagglesInputCommandInjector(filename, folder, env, result)
585585
if targetPrefix then
586586
-- Transform path to user folder
587587
local newFileName = filename:gsub(targetPrefix, lfs.writedir():gsub('\\','/').."InputCommands/")
588-
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, '--Translated path: '..newFileName) end
588+
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, '--Translated path: "'..newFileName..'"') end
589589

590590
-- If the user has put a file there continue
591591
if lfs.attributes(newFileName) then
592-
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, '----Found merge at: '..newFileName) end
592+
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, '----Found merge at: "'..newFileName..'"') end
593593
--Configure file to run in same environment as the default command entry file
594594
local f, err = loadfile(newFileName)
595595
if err ~= nil then
596-
log.write(quagglesLogName, log.ERROR, '------Failure loading: '..tostring(newFileName).." Error: "..tostring(err))
596+
log.write(quagglesLogName, log.ERROR, '------Failure loading: "'..tostring(newFileName)..'"'..' Error: "'..tostring(err)..'"')
597597
return
598598
else
599599
setfenv(f, env)
@@ -602,11 +602,21 @@ local function QuagglesInputCommandInjector(filename, folder, env, result)
602602

603603
-- Merge resulting tables
604604
if statusInj then
605-
if resultInj.keyCommands then env.join(result.keyCommands, resultInj.keyCommands) end
606-
if resultInj.axisCommands then env.join(result.axisCommands, resultInj.axisCommands) end
605+
if result.axisCommands and resultInj.keyCommands then -- If both exist then join
606+
env.join(result.keyCommands, resultInj.keyCommands)
607+
elseif resultInj.keyCommands then -- If just the injected one exists then use it
608+
result.keyCommands = resultInj.keyCommands
609+
end
610+
if deviceGenericName ~= "Keyboard" then -- Don't add axisCommands for keyboard
611+
if result.axisCommands and resultInj.axisCommands then -- If both exist then join
612+
env.join(result.axisCommands, resultInj.axisCommands)
613+
elseif resultInj.axisCommands then -- If just the injected one exists then use it
614+
result.axisCommands = resultInj.axisCommands
615+
end
616+
end
607617
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, '------Merge successful') end
608618
else
609-
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, '------Merge failed: '..tostring(statusInj)) end
619+
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, '------Merge failed: "'..tostring(statusInj)..'"') end
610620
end
611621
end
612622
end
@@ -826,7 +836,7 @@ local function loadDeviceProfileFromFile(filename, deviceGenericName, folder,kee
826836
local status
827837

828838
status, result = pcall(f)
829-
QuagglesInputCommandInjector(filename, folder, env, result)
839+
QuagglesInputCommandInjector(deviceGenericName, filename, folder, env, result)
830840
if status then
831841
if nonLocalized then
832842
for i, keyCommand in ipairs(result.keyCommands or {}) do
@@ -1245,10 +1255,8 @@ local function createProfile(profileInfo)
12451255
-- например Spitfire
12461256
-- InputProfiles = {
12471257
-- ["SpitfireLFMkIX"] = current_mod_path .. '/Input/SpitfireLFMkIX',
1248-
-- ["SpitfireLFMkIX_easy"] = current_mod_path .. '/Input/SpitfireLFMkIX_easy',
12491258
-- ["SpitfireLFMkIXCW"] = current_mod_path .. '/Input/SpitfireLFMkIX',
1250-
-- ["SpitfireLFMkIXCW_easy"] = current_mod_path .. '/Input/SpitfireLFMkIX_easy',
1251-
-- },
1259+
-- },
12521260
if getProfileUnitName_(profile) ~= profileInfo.unitName then
12531261
aliases_[profileInfo.unitName] = profile
12541262
end

0 commit comments

Comments
 (0)