@@ -13,15 +13,15 @@ bool Manager::Override(
1313 Overridable overridableUI,
1414 uint16_t inputKey
1515) {
16- // static UniRelocFunc<decltype(&Manager::Override)> call(2948927698);
17- // call(this, contextName, overridableUI, inputKey);
1816 bool status = false ;
1917 for (auto & action : this ->contextManager ->actions .values ) {
2018 for (auto & mapName : action->data .mapNames ) {
2119 auto mappingCollection = this ->contextManager ->userMapping ->GetMappingCollection (mapName);
2220 for (auto & mapping : mappingCollection->mappings ) {
23- if (mapping.overridableUI == overridableUI && mapping.key16 != inputKey) {
24- mapping.key16 = inputKey;
21+ if (mapping.overridableUI == overridableUI) {
22+ if (mapping.key16 != inputKey) {
23+ mapping.key16 = inputKey;
24+ }
2525 status = true ;
2626 }
2727 }
@@ -30,127 +30,10 @@ bool Manager::Override(
3030 return status;
3131}
3232
33- // enum EMappingType : uint8_t {
34- // Internal = 0, // maybe
35- // Button = 1,
36- // FakeButton = 2,
37- // Axis = 3,
38- // FakeAxis = 4,
39- // Relative = 5,
40- // Unk6 = 6
41- // };
33+ decltype (&ApplyOverrides) ApplyOverrides_Original;
34+ ModModuleHookHash s_ApplyOverrides_Hook (" ApplyOverrides" , 1773342692 , reinterpret_cast <void *>(&ApplyOverrides), reinterpret_cast<void**>(&ApplyOverrides_Original));
4235
43- // #pragma pack(push, 1)
44- // struct Mapping {
45- // EMappingType type;
46- // // 210 / 0xD2 - pre apply 175 25
47- // // 35 / 0x23 - post apply 35 35
48- // // 116 / 0x74 - pre apply 2 252 45
49- // // 35 / 0x23 - post apply 2 35 35
50- // // 35 / 0x23 - pre settings apply
51- // // 35 / 0x23 - post settings apply
52- // uint8_t unk01; // set to 0x23 after apply
53- // EInputKey key16;
54- // EInputKey key32;
55- // uint16_t unk08;
56- // CName name;
57- // CName presetName;
58- // float val;
59- // float thresholdPress;
60- // float thresholdRelease;
61- // uint32_t overridableUI; // Java's String.hashCode()
62- // uint32_t unk28;
63- // uint32_t unk2C;
64- // };
65- // #pragma pack(pop)
66-
67- // struct MappingCollection {
68- // DynArray<Mapping> mappings;
69- // };
70-
71- // struct RawMappingCollection {
72- // DynArray<Mapping> mappings;
73- // // set to 0 after an ApplyOverrides
74- // bool has_update;
75- // };
76-
77- // struct UserMapping {
78- // DynArray<void *> unk00; // 00
79- // uint8_t sorted; // 10
80- // DynArray<void *> unk18; // 18
81- // CString invalid_str; // 28
82- // void * contextManager; // 48
83- // void * buttons; // 50
84- // void * buttonGroups; // 58
85- // void * axes; // 60
86- // void * relativeAxes; // 68
87- // // updated from actionMap on save
88- // Map<EInputKey, MappingCollection> keyMap; // 70
89- // Map<CName, RawMappingCollection> actionMap; // 98
90- // HashMap<CString, EInputKey> stringToKey; // C0
91- // HashMap<CString, EInputKey> inputKeyMap_F0; // F0
92- // HashMap<EInputKey, CString> unk120; // 120
93- // };
94-
95- // after OnStreamingWorldLoaded
96- // unk00 & unk18 empty
97- // baseMap 144
98- // overrides 462
99- // inputKeyMap_C0 272
100- // inputKeyMap_F0 272
101-
102- // .xml binding
103- // ApplyOverrides()
104- // UserSettings.json applied
105-
106- // after OnWorldAttached
107- // updated:
108- // contextManager
109- // buttons
110- // buttonGroups
111- // axes
112- // relativeAxes
113-
114- // .xml binding
115- // ApplyOverrides()
116- // UserSettings.json applied
117-
118- // after "Apply" is hit
119-
120- // class ContextManager {
121-
122- // };
123-
124- // called once after Override
125- REGISTER_HOOK_HASH (void , 1773342692 , ApplyOverrides, Manager * manager) {
126- // manager->Override("VehicleDrive", "vehicleFlight", EInputKey::IK_D);
127- // manager->Override("BaseVehicleFlight", "vehicleFlight", EInputKey::IK_F);
36+ void ApplyOverrides (Manager * manager) {
12837 ModSettings::ModSettings::AddOverrides (manager);
12938 ApplyOverrides_Original (manager);
13039}
131-
132- // called once after Override
133- // REGISTER_HOOK_HASH(void, 3016757648, ApplyOverrides, UserMapping *userMapping) {
134- // auto hash = CalcHash("vehicleFlight");
135- // userMapping->actionMap.ForEach([hash](const CName & action, RawMappingCollection & mappingCollection) {
136- // bool updated = false;
137- // for (auto mapping : mappingCollection.mappings) {
138- // if (mapping.overridableUI == hash) {
139- // updated = true;
140- // mapping.key16 = EInputKey::IK_L;
141- // mapping.key32 = EInputKey::IK_L;
142- // }
143- // }
144- // mappingCollection.has_update = true;
145- // });
146- // ApplyOverrides_Original(userMapping);
147- // }
148-
149- // called per key when updating
150- // REGISTER_HOOK_HASH(void, 1120015283, ContextManager_Override,
151- // ContextManager * contextManager,
152- // CName contextName,
153- // unsigned int overridableUI,
154- // EInputKey inputKey) {
155- // ContextManager_Override_Original(contextManager, contextName, overridableUI, inputKey);
156- // }
0 commit comments