@@ -277,7 +277,7 @@ local function loadDeviceProfileFromFile(filename, deviceName, folder,keep_G_unt
277277 end
278278 end
279279 end
280-
280+
281281 local f , err = loadfile (filename )
282282 local result
283283 local deviceGenericName
@@ -1198,11 +1198,10 @@ end
11981198
11991199local function validateProfileCommandCombos (profileName , command )
12001200 local result = not command .updated
1201- if result then
1202- local profile = findProfile_ (profileName )
1203-
1204- local modifiers = profile .modifiers
1205-
1201+ local profile = findProfile_ (profileName )
1202+ local modifiers = profile .modifiers
1203+
1204+ if result then
12061205 for deviceName , combos in pairs (command .combos ) do
12071206 for i , combo in ipairs (combos ) do
12081207 local warnings = {}
@@ -1225,6 +1224,38 @@ local function validateProfileCommandCombos(profileName, command)
12251224 return result
12261225end
12271226
1227+ local function checkDeviceCombosIntersectionInProfile (profileName , deviceName , commandsHashTable )
1228+ local profile = findProfile_ (profileName )
1229+ local modifiers = profile .modifiers
1230+
1231+ for commandHash1 , command1 in pairs (commandsHashTable ) do
1232+ if command1 .combos and command1 .combos [deviceName ] then
1233+ for i , combo1 in ipairs (command1 .combos [deviceName ]) do
1234+ local combo1Hash = createComboHash_ (deviceName , combo1 , modifiers )
1235+ for commandHash2 , command2 in pairs (commandsHashTable ) do
1236+ if command1 .name ~= command2 .name and command2 .combos and command2 .combos [deviceName ] then
1237+ for i , combo2 in ipairs (command2 .combos [deviceName ]) do
1238+ if combo1Hash == createComboHash_ (deviceName , combo2 , modifiers ) then
1239+ printLog (' Profile [' .. profileName .. ' ] command [' .. command1 .name .. ' ] contains combo [' .. InputUtils .createComboString (combo1 , deviceName ) .. ' ] equal to combo in [' .. command2 .name .. ' ]' )
1240+ combo1 .valid = false
1241+ command1 .valid = false
1242+ combo1 .warnings = combo1 .warnings and combo1 .warnings .. " \n " or " "
1243+ combo1 .warnings = combo1 .warnings .. string.format (_ (' Is equal to combo in command %s' ), command2 .name )
1244+ end
1245+ end
1246+ end
1247+ end
1248+ end
1249+ end
1250+ end
1251+ end
1252+
1253+ local function updateCommandValidation (profileName , deviceName , command , isAxisCommand )
1254+ local profile = getLoadedProfile_ (profileName )
1255+ command .valid = validateProfileCommandCombos (profileName , command )
1256+ checkDeviceCombosIntersectionInProfile (profileName , deviceName , isAxisCommand and profile .axisCommands or profile .keyCommands )
1257+ end
1258+
12281259local function findCommandByHash_ (commands , commandHash )
12291260 if commands then
12301261 return commands [commandHash ]
@@ -1303,6 +1334,7 @@ local function removeCombosFromCommand_(profileName, command, deviceName)
13031334 end
13041335 end
13051336
1337+ command .updated = false
13061338 command .valid = validateProfileCommandCombos (profileName , command )
13071339 end
13081340end
@@ -1372,6 +1404,8 @@ local function addProfileKeyCommands(profileName, deviceName, deviceProfile, com
13721404 for i , keyCommand in ipairs (keyCommands ) do
13731405 addProfileKeyCommand (profileName , deviceName , keyCommand , commandsHashTable , combosHashTable )
13741406 end
1407+
1408+ checkDeviceCombosIntersectionInProfile (profileName , deviceName , commandsHashTable )
13751409 end
13761410end
13771411
@@ -1411,6 +1445,8 @@ local function addProfileAxisCommands(profileName, deviceName, deviceProfile, co
14111445 for i , axisCommand in ipairs (deviceProfile .axisCommands ) do
14121446 addProfileAxisCommand (profileName , deviceName , axisCommand , commandsHashTable , combosHashTable )
14131447 end
1448+
1449+ checkDeviceCombosIntersectionInProfile (profileName , deviceName , commandsHashTable )
14141450 end
14151451end
14161452
@@ -1430,7 +1466,7 @@ local function getProfileForceFeedbackSettings(profileName, deviceName)
14301466end
14311467
14321468local function validateCommands_ (profileName , commands )
1433- if commands then
1469+ if commands then -- check
14341470 for commandHash , command in pairs (commands ) do
14351471 command .valid = validateProfileCommandCombos (profileName , command )
14361472 end
@@ -2690,6 +2726,7 @@ local module_interface = {
26902726 local profile = getLoadedProfile_ (profileName )
26912727 return U .copyTable (nil , profile .defaultAxisCommands )
26922728 end ,
2729+ updateCommandValidation = updateCommandValidation ,
26932730}
26942731---- --------------------------------------------------------------------------
26952732return module_interface
0 commit comments