/// <summary>
		/// Adds an input handler.
		/// </summary>
		/// <param name="type">the type of input handler</param>
		/// <param name="inputName">the name of the input handler</param>
		/// <returns><c>true</c>if the handler was added</returns>
		/// 
		public bool AddMapping(InputManager.InputType type, string inputName)
		{
			IDevice device = null;
			// create specific device subtype
			switch (type)
			{
				case InputManager.InputType.UnityInput:  device = new Device_UnityInput(); break;
				case InputManager.InputType.Keyboard:    device = new Device_Keyboard(); break;
#if !NO_MOCAP_INPUT 
				case InputManager.InputType.MoCapDevice: device = new Device_MoCap(); break;
#endif
				default:
					{
						Debug.LogWarning("Input Type " + type.ToString() + " not supported.");
						break;
					}
			}
			// try to initialise given the parameter string
			if ((device != null) && device.Initialise(inputName))
			{
				// success
				devices.Add(device);
			}
			else
			{
				// failed
				device = null;
			}
			return (device != null);
		}
Exemplo n.º 2
0
        private IDevice CreateDevice(InputManager.InputType type, string inputName)
        {
            IDevice device = null;

            // create specific device subtype
            switch (type)
            {
            case InputManager.InputType.UnityInput:  device = new Device_UnityInput(); break;

            case InputManager.InputType.Keyboard:    device = new Device_Keyboard(); break;

#if !NO_MOCAP_INPUT
            case InputManager.InputType.MoCapDevice: device = new Device_MoCap(); break;
#endif
            default:
            {
                Debug.LogWarning("Input Type " + type.ToString() + " not supported.");
                break;
            }
            }
            // try to initialise given the parameter string
            if (device != null)
            {
                inputName = inputName.Trim();
                if (!device.Initialise(inputName))
                {
                    // failed
                    device = null;
                }
            }
            return(device);
        }