summaryrefslogtreecommitdiff
path: root/Thronefall_v1.0/Rewired/Rewired.Internal/ControllerTemplateFactory.cs
blob: d1ac2b5d14e7e73c4dd5434fa19639e72bf085cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;

namespace Rewired.Internal;

public static class ControllerTemplateFactory
{
	private static readonly Type[] _defaultTemplateTypes = new Type[6]
	{
		typeof(GamepadTemplate),
		typeof(RacingWheelTemplate),
		typeof(HOTASTemplate),
		typeof(FlightYokeTemplate),
		typeof(FlightPedalsTemplate),
		typeof(SixDofControllerTemplate)
	};

	private static readonly Type[] _defaultTemplateInterfaceTypes = new Type[6]
	{
		typeof(IGamepadTemplate),
		typeof(IRacingWheelTemplate),
		typeof(IHOTASTemplate),
		typeof(IFlightYokeTemplate),
		typeof(IFlightPedalsTemplate),
		typeof(ISixDofControllerTemplate)
	};

	public static Type[] templateTypes => _defaultTemplateTypes;

	public static Type[] templateInterfaceTypes => _defaultTemplateInterfaceTypes;

	public static IControllerTemplate Create(Guid typeGuid, object payload)
	{
		if (typeGuid == GamepadTemplate.typeGuid)
		{
			return new GamepadTemplate(payload);
		}
		if (typeGuid == RacingWheelTemplate.typeGuid)
		{
			return new RacingWheelTemplate(payload);
		}
		if (typeGuid == HOTASTemplate.typeGuid)
		{
			return new HOTASTemplate(payload);
		}
		if (typeGuid == FlightYokeTemplate.typeGuid)
		{
			return new FlightYokeTemplate(payload);
		}
		if (typeGuid == FlightPedalsTemplate.typeGuid)
		{
			return new FlightPedalsTemplate(payload);
		}
		if (typeGuid == SixDofControllerTemplate.typeGuid)
		{
			return new SixDofControllerTemplate(payload);
		}
		return null;
	}
}