//------------------------------------------------------------------------------
// Lamp : Open source game middleware
// Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//------------------------------------------------------------------------------

/** @file
 * 入力システム実装
 * @author Junpee
 */

#include "Core/Utility/stdafx.h"
#include "Game/Input/InputSystem.h"
#include "Game/Input/GamePad.h"

// インスタンス
InputSystem* InputSystem::instance_ = NULL;

//------------------------------------------------------------------------------
// 生成、破棄
//------------------------------------------------------------------------------
// コンストラクタ
InputSystem::InputSystem(){
	// インスタンスポインタ設定
	Assert(instance_ == NULL);
	instance_ = this;
	// キーボード初期化
	keyboard = LampInput::getKeyboard();
	// マウスの作成
	mouse_ = LampInput::getMouse();
	// パッドの初期化、1番目のパッドが使用できるなら使用する
	pad_ = NULL;
	if(LampInput::getJoystickCount() > 0){
		if(GamePad::checkCompatibility(LampInput::getJoystick(0))){
			pad_ = new GamePad(LampInput::getJoystick(0));
		}
	}
}
//------------------------------------------------------------------------------
// デストラクタ
InputSystem::~InputSystem(){
	// パッドの破棄
	SafeDelete(pad_);
	// インスタンスポインタ後始末
	Assert(instance_ == this);
	instance_ = NULL;
}
//------------------------------------------------------------------------------
