13{
14
15 const FString SourceSection = TEXT("CommonInputPlatformSettings_Windows CommonInputPlatformSettings");
16 const FString SourceIni = FPaths::Combine(IPluginManager::Get().FindPlugin("CommonUIStyle")->GetBaseDir(), TEXT("Config/DefaultCommonUIStyle.ini"));
17 TArray<FString> Keys = {
18 TEXT("DefaultInputType"),
19 TEXT("bSupportsMouseAndKeyboard"),
20 TEXT("bSupportsTouch"),
21 TEXT("bSupportsGamepad"),
22 TEXT("DefaultGamepadName"),
23 TEXT("bCanChangeGamepadType"),
24 TEXT("+ControllerData")
25 };
26 const FString SourceTargetIni = FPaths::Combine(FPaths::ProjectConfigDir(), TEXT("DefaultGame.ini"));
27 FString TargetIni = FConfigCacheIni::NormalizeConfigIniPath(SourceTargetIni);
28 for(const FString& Key : Keys)
29 {
30 TArray<FString> Values;
31 if (GConfig->GetArray(*SourceSection, *Key, Values, *SourceIni))
32 {
33
34 if(Key == TEXT("+ControllerData"))
35 {
36 GConfig->SetArray(*SourceSection, TEXT("+ControllerData"), Values, *TargetIni);
37 }
38 else
39 {
40 GConfig->SetArray(*SourceSection, *Key, Values, *TargetIni);
41 }
42 }
43 else
44 {
45 FString Value;
46 if (GConfig->GetString(*SourceSection, *Key, Value, *SourceIni))
47 {
48 GConfig->SetString(*SourceSection, *Key, *Value, *TargetIni);
49 }
50 }
51 }
52
53 const FString CustomSection = TEXT("CommonUIStyle");
54 const FString CustomKey = TEXT("InputData");
55 FString StyleInputData;
56
57 if(GConfig->GetString(*CustomSection, *CustomKey, StyleInputData, *SourceIni))
58 {
59
60 const FString TargetSection = TEXT("/Script/CommonInput.CommonInputSettings");
61 const FString TargetKey = TEXT("InputData");
62 GConfig->SetString(*TargetSection, *TargetKey, *StyleInputData, *TargetIni);
63
64 UE_LOG(LogTemp, Log, TEXT("Set InputData to %s from DefaultCommonUIStyle.ini"), *StyleInputData);
65 }
66 else
67 {
68 UE_LOG(LogTemp,
Warning, TEXT(
"Could not find InputData in %s"), *SourceIni);
69 }
70 GConfig->Flush(false, *TargetIni);
71}