Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit 85b48a2

Browse files
committed
Without settings fix
1 parent f92e0f4 commit 85b48a2

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

XOutput/Input/Mapper/DirectToXInputMapper.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ public void SetMapping(XInputTypes xInputType, MapperData<DirectInputTypes> to)
6767
/// <returns></returns>
6868
public MapperData<DirectInputTypes> GetMapping(XInputTypes? type)
6969
{
70-
if(!type.HasValue || mappings.ContainsKey(type.Value))
70+
if (!type.HasValue)
71+
return null;
72+
if(!mappings.ContainsKey(type.Value))
7173
{
72-
return mappings[type.Value];
74+
mappings[type.Value] = new MapperData<DirectInputTypes>();
7375
}
74-
return null;
76+
return mappings[type.Value];
7577
}
7678

7779
/// <summary>

XOutput/Input/Mapper/MapperData.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ public class MapperData<T> where T : struct
2424
/// Maximum value
2525
/// </summary>
2626
public double MaxValue { get; set; }
27+
28+
public MapperData()
29+
{
30+
InputType = default(T);
31+
MaxValue = 0;
32+
MaxValue = 100;
33+
}
2734

2835
/// <summary>
2936
/// Gets the value based on minimum and maximum values.

XOutput/Input/XInput/Device.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,13 @@ public bool RefreshInput()
7676
foreach(var type in (XInputTypes[])Enum.GetValues(typeof(XInputTypes)))
7777
{
7878
var mapping = mapper.GetMapping(type);
79-
double value = 0;
80-
if (mapping.InputType != null)
81-
value = source.Get(mapping.InputType.Value);
82-
values[type] = mapping.GetValue(value);
79+
if (mapping != null)
80+
{
81+
double value = 0;
82+
if (mapping.InputType != null)
83+
value = source.Get(mapping.InputType.Value);
84+
values[type] = mapping.GetValue(value);
85+
}
8386
}
8487
dPad = source.GetDPad();
8588
InputChanged?.Invoke();

XOutput/UI/Component/MappingViewModel.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,17 @@ public decimal? Max
8181
public MappingViewModel(MapperData<DirectInputTypes> mapperData)
8282
{
8383
this.mapperData = mapperData;
84-
_min = (decimal)mapperData.MinValue * 100;
85-
_max = (decimal)mapperData.MaxValue * 100;
8684
foreach (var directInput in DirectInputHelper.GetAll())
8785
{
8886
DirectInputs.Add(directInput);
8987
}
90-
if (mapperData.InputType.HasValue)
91-
_selectedDirectInput = mapperData.InputType.Value;
88+
if (mapperData != null)
89+
{
90+
_min = (decimal)mapperData.MinValue * 100;
91+
_max = (decimal)mapperData.MaxValue * 100;
92+
if (mapperData.InputType.HasValue)
93+
_selectedDirectInput = mapperData.InputType.Value;
94+
}
9295
}
9396
}
9497
}

0 commit comments

Comments
 (0)