/*********************************************************\
         __      __           __  __
        / /     / / _____    / / / / ______   __     __
       / /     / / /___  \  / / / / / ___  | / /    / /
      / /_____/ / _____| / / / / / / /__/ / / /    / /
     / ______  / / ___  / / / / / / _____/ / /    / /
    / /     / / / /__/ / / / / / / |____  / |____/ /
   /_/     /_/ |______/ /_/ /_/  \_____/  \_____  /
                                         ______/ /
            High Level Game Framework   /_______/

  ------------------------------------------------------

  Copyright (c) 2007 - Rodrigo Braz Monteiro.
  This file is subject to the terms of license.txt.

\*********************************************************/

#pragma once

#include "utils.h"
#include "input_base.h"

namespace Halley {
	class InputVirtual : public InputBase {
	public:
		InputVirtual(int nButtons, int nAxes);

		size_t getNumberButtons();
		size_t getNumberAxes();

		bool isButtonPressed(int code);
		bool isButtonReleased(int code);
		bool isButtonDown(int code);

		float getAxis(int n);

		void setVibration(float high, float low);

		void bindButton(int n, spInputBase device, int deviceN);
		void bindAxis(int n, spInputBase device, int deviceN);
		void bindAxisButton(int n, spInputBase device, int negativeButton, int positiveButton);
		void bindVibration(spInputBase joy);

		void unbindButton(int n);
		void unbindAxis(int n);
		void clearBindings();

	private:
		struct Bind {
			spInputBase device;
			int a;
			int b;
			bool isAxis;

			Bind(spInputBase d, int n) : device(d), a(n), b(0), isAxis(true) {}
			Bind(spInputBase d, int _a, int _b) : device(d), a(_a), b(_b), isAxis(false) {}
		};

		std::vector<std::vector<Bind> > buttons;
		std::vector<std::vector<Bind> > axes;
		spInputBase vibration;
	};

	typedef shared_ptr<InputVirtual> spInputVirtual;
}
