Ejemplo n.º 1
0
        public void SaveControllers()
        {
            foreach (var device in Devices)
            {
                var filename = Path.Combine(PresetsDirectory, device.Device.InstanceGuid + ".ini");

                var ini = new IniFile {
                    ["CONTROLLER"] =
                    {
                        ["NAME"]    = device.DisplayName,
                        ["PRODUCT"] = device.Device.ProductGuid.ToString()
                    }
                };

                foreach (var entry in WheelAxleEntries.Where(x => x.Input?.Device == device))
                {
                    ini[entry.Id].Set("AXLE", entry.Input?.Id);
                }

                foreach (var entry in WheelButtonEntries.Select(x => x.WheelButton).Where(x => x.Input?.Device == device))
                {
                    ini[entry.Id].Set("BUTTON", entry.Input?.Id);
                }

                foreach (var entry in WheelHShifterButtonEntries.Where(x => x.Input?.Device == device))
                {
                    ini["SHIFTER"].Set(entry.Id, entry.Input?.Id);
                }

                ini.Save(filename);
            }
        }
Ejemplo n.º 2
0
 private void UpdateWheelHShifterDevice()
 {
     WheelHShifterDevice = WheelHShifterButtonEntries.Select(x => x.Input?.Device).FirstOrDefault(x => x != null);
     foreach (var entry in WheelHShifterButtonEntries.Where(x => x.Input != null && x.Input.Device != WheelHShifterDevice))
     {
         entry.Clear();
     }
 }
Ejemplo n.º 3
0
        protected override void SetToIni()
        {
#if DEBUG
            var sw = Stopwatch.StartNew();
#endif
            Ini["HEADER"].Set("INPUT_METHOD", InputMethod);

            UpdatePlaceholders();
            Ini["CONTROLLERS"] = Devices
                                 .Select(x => (IDirectInputDevice)x)
                                 .Union(_placeholderDevices)
                                 .Aggregate(new IniFileSection(), (s, d, i) => {
                s.Set("CON" + d.Index, d.DisplayName);
                s.Set("PGUID" + d.Index, d.Id ?? ProductGuids.GetValueOrDefault(d.DisplayName));
                return(s);
            });

            Ini["ADVANCED"].Set("COMBINE_WITH_KEYBOARD_CONTROL", CombineWithKeyboardInput);
            Ini["SHIFTER"].Set("ACTIVE", WheelUseHShifter);
            Ini["SHIFTER"].Set("JOY", WheelHShifterButtonEntries.FirstOrDefault(x => x.Input != null)?.Input?.Device.Index);
            Ini["STEER"].Set("DEBOUNCING_MS", DebouncingInterval);

            foreach (var entry in Entries.OfType <IDirectInputEntry>())
            {
                Ini[entry.Id]["JOY"] = -1;
            }

            foreach (var entry in Entries)
            {
                entry.Save(Ini);
            }

            SaveFfbToIni(Ini);

            var section = Ini["KEYBOARD"];
            section.Set("STEERING_SPEED", KeyboardSteeringSpeed);
            section.Set("STEERING_OPPOSITE_DIRECTION_SPEED", KeyboardOppositeLockSpeed);
            section.Set("STEER_RESET_SPEED", KeyboardReturnRate);
            section.Set("MOUSE_STEER", KeyboardMouseSteering);
            section.Set("MOUSE_ACCELERATOR_BRAKE", KeyboardMouseButtons);
            section.Set("MOUSE_SPEED", KeyboardMouseSteeringSpeed);

            section = Ini["__LAUNCHER_CM"];
            section.Set("PRESET_NAME", CurrentPresetFilename?.SubstringExt(PresetsDirectory.Length + 1));
            section.Set("PRESET_CHANGED", CurrentPresetChanged);

            SaveControllers();

#if DEBUG
            Logging.Write($"Controls saving time: {sw.Elapsed.TotalMilliseconds:F2} ms");
#endif
        }