private int ResolveProcessors(string processorString) { var firstProcessorIndex = totalProcessorCount; if (!InputControlLayout.ParseNameAndParameterList(processorString, ref m_Parameters)) { return(firstProcessorIndex); } for (var i = 0; i < m_Parameters.Count; ++i) { // Look up processor. var type = InputControlProcessor.s_Processors.LookupTypeRegistration(m_Parameters[i].name); if (type == null) { throw new Exception(string.Format( "No processor with name '{0}' (mentioned in '{1}') has been registered", m_Parameters[i].name, processorString)); } // Instantiate it. var processor = Activator.CreateInstance(type); // Pass parameters to it. InputDeviceBuilder.SetParameters(processor, m_Parameters[i].parameters); // Add to list. ArrayHelpers.AppendWithCapacity(ref processors, ref totalProcessorCount, processor); } return(firstProcessorIndex); }
private int ResolveInteractions(string interactionString) { ////REVIEW: We're piggybacking off the processor parsing here as the two syntaxes are identical. Might consider //// moving the logic to a shared place. //// Alternatively, may split the paths. May help in getting rid of unnecessary allocations. var firstInteractionIndex = totalInteractionCount; if (!InputControlLayout.ParseNameAndParameterList(interactionString, ref m_Parameters)) { return(firstInteractionIndex); } for (var i = 0; i < m_Parameters.Count; ++i) { // Look up interaction. var type = InputInteraction.s_Interactions.LookupTypeRegistration(m_Parameters[i].name); if (type == null) { throw new Exception(string.Format( "No interaction with name '{0}' (mentioned in '{1}') has been registered", m_Parameters[i].name, interactionString)); } // Instantiate it. var interaction = Activator.CreateInstance(type) as IInputInteraction; if (interaction == null) { throw new Exception(string.Format("Interaction '{0}' is not an IInputInteraction", m_Parameters[i].name)); } // Pass parameters to it. InputDeviceBuilder.SetParameters(interaction, m_Parameters[i].parameters); // Add to list. var interactionStateCount = totalInteractionCount; ArrayHelpers.AppendWithCapacity(ref interactionStates, ref interactionStateCount, new InputActionMapState.InteractionState { phase = InputActionPhase.Waiting }); ArrayHelpers.AppendWithCapacity(ref interactions, ref totalInteractionCount, interaction); Debug.Assert(interactionStateCount == totalInteractionCount); } return(firstInteractionIndex); }
private static object InstantiateBindingComposite(string nameAndParameters) { var nameAndParametersParsed = InputControlLayout.ParseNameAndParameters(nameAndParameters); // Look up. var type = InputBindingComposite.s_Composites.LookupTypeRegistration(nameAndParametersParsed.name); if (type == null) { throw new Exception(string.Format("No binding composite with name '{0}' has been registered", nameAndParametersParsed.name)); } // Instantiate. var instance = Activator.CreateInstance(type); ////REVIEW: typecheck for IInputBindingComposite? (at least in dev builds) // Set parameters. InputDeviceBuilder.SetParameters(instance, nameAndParametersParsed.parameters); return(instance); }