using UnityEngine;
using System.Collections.Generic;
using System.Collections;

public abstract class DD_Input_Device {

  public Dictionary<string, DD_Input.Axis> _axes = new Dictionary<string, DD_Input.Axis>();
  public Dictionary<string, DD_Input.Button> _buttons = new Dictionary<string, DD_Input.Button>();

  public virtual void UpdateInput() {}

  public DD_Input.Axis GetAxis(string name) {
    return _axes[name];
  }

  public bool GetKey(string name) {
    return (_buttons[name].pressed && _buttons[name].last);
  }

  public bool GetKeyDown(string name) {
    return (_buttons[name].pressed && !_buttons[name].last);
  }

  public bool GetKeyUp(string name) {
    return (!_buttons[name].pressed && _buttons[name].last);
  }

  protected void AddAxis(string name) {
    _axes.Add(name, new DD_Input.Axis());
  }

  protected void AddButton(string name) {
    _buttons.Add(name, new DD_Input.Button());
  }

  protected void UpdateAxis(string name, float v, float h) {
    _axes[name].Update(v, h);
  }

  protected void UpdateButton(string name, bool toggle) {
    _buttons[name].Update(toggle);
  }

}

