//------------------------------------------------------------------------------
// 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 <LampBasic.h>
#include <Framework/System/BasicFramework.h>
#include <Input/System/LampInput.h>
#include <Input/Keyboard/Keyboard.h>
#include <Core/Utility/FPSController.h>

// Lampのネームスペースを有効にする
using namespace Lamp;

//------------------------------------------------------------------------------
// クラス定義。通常はヘッダファイルに格納する
//------------------------------------------------------------------------------
/**
 * 入力サンプル キーボード
 */
class SampleInputKeyboard : public BasicFramework{
public:
	/**
	 * コンストラクタ
	 */
	SampleInputKeyboard() : BasicFramework("SampleInputKeyboard"){}

	/**
	 * 初期化
	 * @return 初期化に成功すればtrueを返す
	 */
	virtual bool initialize();

	/**
	 * 実行
	 */
	virtual void run();

	/**
	 * 情報描画
	 */
	virtual void drawInformation();

private:
	// 情報文字列
	String informationString_;

};
//------------------------------------------------------------------------------
// プログラムエントリポイント
//------------------------------------------------------------------------------
// メイン関数
int WINAPI WinMain(
	HINSTANCE instance, HINSTANCE previousInstance, LPSTR command, int show){
	SampleInputKeyboard tutorial;
	return tutorial.execute(instance);
}
//------------------------------------------------------------------------------
// クラス実装
//------------------------------------------------------------------------------
// 初期化
bool SampleInputKeyboard::initialize(){
	// FPSの設定(描画30FPSに落としてもゲームが60FPSで動く事を確認できる)
	fpsController_->setTargetInterval(FPSController::interval30FPS);
	return true;
}
//------------------------------------------------------------------------------
// 実行
void SampleInputKeyboard::run(){
	informationString_ += keyboard_->toString();
}
//------------------------------------------------------------------------------
// 情報描画
void SampleInputKeyboard::drawInformation(){
	BasicFramework::drawInformation();
	drawInformationString(informationString_);
	informationString_ = "";
}
//------------------------------------------------------------------------------
