Implement input config loading and saving.
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Cryville.Common.Unity.Input {
|
||||
};
|
||||
// TODO set private
|
||||
public readonly List<InputHandler> _handlers = new List<InputHandler>();
|
||||
readonly Dictionary<Type, InputHandler> _typemap = new Dictionary<Type, InputHandler>();
|
||||
readonly Dictionary<InputHandler, double> _timeOrigins = new Dictionary<InputHandler, double>();
|
||||
readonly object _lock = new object();
|
||||
readonly Dictionary<InputIdentifier, InputVector> _vectors = new Dictionary<InputIdentifier, InputVector>();
|
||||
@@ -22,6 +23,7 @@ namespace Cryville.Common.Unity.Input {
|
||||
try {
|
||||
if (!typeof(InputHandler).IsAssignableFrom(t)) continue;
|
||||
var h = (InputHandler)ReflectionHelper.InvokeEmptyConstructor(t);
|
||||
_typemap.Add(t, h);
|
||||
h.OnInput += OnInput;
|
||||
_handlers.Add(h);
|
||||
_timeOrigins.Add(h, 0);
|
||||
@@ -32,6 +34,9 @@ namespace Cryville.Common.Unity.Input {
|
||||
}
|
||||
}
|
||||
}
|
||||
public InputHandler GetHandler(string name) {
|
||||
return _typemap[Type.GetType(name)];
|
||||
}
|
||||
public void Activate() {
|
||||
lock (_lock) {
|
||||
_events.Clear();
|
||||
|
Reference in New Issue
Block a user