@@ -13,6 +13,20 @@ namespace XOutput.Input.Mapper
13
13
/// </summary>
14
14
public sealed class DirectToXInputMapper : InputMapperBase
15
15
{
16
+ private const string EXCLUSIVE = "Exclusive" ;
17
+ private bool isExclusive ;
18
+ public override bool IsExclusive
19
+ {
20
+ get => isExclusive ;
21
+ set
22
+ {
23
+ if ( isExclusive != value )
24
+ {
25
+ isExclusive = value ;
26
+ }
27
+ }
28
+ }
29
+
16
30
/// <summary>
17
31
/// Gets a new mapper from dictionary.
18
32
/// </summary>
@@ -21,32 +35,27 @@ public sealed class DirectToXInputMapper : InputMapperBase
21
35
public static DirectToXInputMapper Parse ( Dictionary < string , string > data )
22
36
{
23
37
DirectToXInputMapper mapper = new DirectToXInputMapper ( ) ;
24
- foreach ( var mapping in FromDictionary ( data , typeof ( DirectInputTypes ) ) )
38
+ if ( data . ContainsKey ( EXCLUSIVE ) )
39
+ {
40
+ mapper . IsExclusive = data [ EXCLUSIVE ] == "true" ;
41
+ data . Remove ( EXCLUSIVE ) ;
42
+ }
43
+ else
44
+ {
45
+ mapper . IsExclusive = false ;
46
+ }
47
+ foreach ( var mapping in FromDictionary ( data , typeof ( DirectInputTypes ) ) )
25
48
{
26
49
mapper . mappings . Add ( mapping . Key , mapping . Value ) ;
27
50
}
28
51
return mapper ;
29
52
}
30
53
31
- /// <summary>
32
- /// Serializes the mapper object into string.
33
- /// </summary>
34
- /// <returns></returns>
35
- public override string ToString ( )
54
+ public override Dictionary < string , string > ToDictionary ( )
36
55
{
37
- StringBuilder sb = new StringBuilder ( ) ;
38
- foreach ( var mapping in mappings )
39
- {
40
- sb . Append ( mapping . Key ) ;
41
- sb . Append ( ";" ) ;
42
- sb . Append ( mapping . Value . InputType ) ;
43
- sb . Append ( ";" ) ;
44
- sb . Append ( ( int ) Math . Round ( mapping . Value . MinValue * 100 ) ) ;
45
- sb . Append ( ";" ) ;
46
- sb . Append ( ( int ) Math . Round ( mapping . Value . MaxValue * 100 ) ) ;
47
- sb . Append ( Environment . NewLine ) ;
48
- }
49
- return sb . ToString ( ) ;
56
+ var dict = base . ToDictionary ( ) ;
57
+ dict [ EXCLUSIVE ] = IsExclusive ? "true" : "false" ;
58
+ return dict ;
50
59
}
51
60
}
52
61
}
0 commit comments