Esempio n. 1
0
    void RefreshJoystickDevicesWithConfig(UnGamepadConfig config)
    {
        string[] joystickNames = Input.GetJoystickNames();

        for (int i = 0; i < joystickNames.Length; i++)
        {
            if (config.IsCompatibleTo(joystickNames [i]))
            {
                bool alreadyExists = false;
                foreach (GamepadDevice d in gamepads)
                {
                    if ((d as UnGamepadDevice).config == config && d.deviceId == i + 1)
                    {
                        alreadyExists = true;                         // already existing
                        break;
                    }
                }

                if (!alreadyExists)
                {
                    CreateGamepad(i + 1, config);
                }
            }
        }
    }
	public UnGamepadConfig.InputMapping GetInputMapping (UnGamepadConfig.InputTarget target)
	{
		for (int i = 0; i < inputMappings.Length; i++)
		{
			if (inputMappings [i].target == target)
				return inputMappings [i];
		}
		return null;
	}
Esempio n. 3
0
    void CreateGamepad(int deviceId, UnGamepadConfig config)
    {
        UnGamepadDevice gamepad = new UnGamepadDevice();

        gamepad.config   = config;
        gamepad.deviceId = deviceId;

        AddDevice(gamepad);
    }
Esempio n. 4
0
    void RemoveIfDisconnected(GamepadDevice gamepad)
    {
        UnGamepadConfig config = (UnGamepadConfig)((UnGamepadDevice)gamepad).config;

        if (Input.GetJoystickNames().Length < gamepad.deviceId ||
            !config.IsCompatibleTo(Input.GetJoystickNames() [gamepad.deviceId - 1]))
        {
            RemoveDevice(gamepad);
        }
    }
	public void SetInputNormalized (UnGamepadConfig.InputTarget input, float valNormalized)
	{
		values [(int)input] = Mathf.Lerp (outputMin [(int)input], outputMax [(int)input], valNormalized); // map to output values
	}
	float GetInputValue (UnGamepadConfig.InputTarget input)
	{
		return values [(int)input];
	}
	bool GetInputBool (UnGamepadConfig.InputTarget input)
	{		
		return values [(int)input] == 1;
	}
	void CreateGamepad (int deviceId, UnGamepadConfig config)
	{
		UnGamepadDevice gamepad = new UnGamepadDevice ();
		gamepad.config = config;
		gamepad.deviceId = deviceId;

		AddDevice (gamepad);
	}
	void RefreshJoystickDevicesWithConfig (UnGamepadConfig config)
	{	
		string[] joystickNames = Input.GetJoystickNames ();
		
		for (int i = 0; i < joystickNames.Length; i++)
		{
			if (config.IsCompatibleTo (joystickNames [i]))
			{
				bool alreadyExists = false;
				foreach (GamepadDevice d in gamepads)
				{
					if ((d as UnGamepadDevice).config == config && d.deviceId == i + 1)
					{
						alreadyExists = true; // already existing
						break;
					}
				}
				
				if (!alreadyExists)
				{
					CreateGamepad (i + 1, config);
				}
			}
			
		}
	}