//------------------------------------------------------------------------------
// 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
 */

#ifndef KEYBOARD_DEVICE_H_
#define KEYBOARD_DEVICE_H_

#include <Input/System/InputDevice.h>
#include <Input/Keyboard/KeyboardKey.h>
#include <Input/Keyboard/KeyboardState.h>

namespace Lamp{

//------------------------------------------------------------------------------
/**
 * キーボードデバイス
 */
class KeyboardDevice : public InputDevice, public KeyboardKey{
friend class LampInput;
friend class BufferedInput;
public:
	/**
	 * キーボードステートの取得
	 * @return キーボードステート
	 */
	virtual const KeyboardState& getKeyboardState() const{
		return keyboardState_;
	}

	/**
	 * 協調レベルの設定
	 * @param exclusive 排他モードならtrue
	 * @param foreground フォアグラウンドモードならtrue
	 * @return 成功すればtrue
	 */
	virtual bool setCooperativeLevel(bool exclusive, bool foreground){
		// 不正な組み合わせチェック
		Assert(!(exclusive && (!foreground)));
		return InputDevice::setCooperativeLevel(exclusive, foreground);
	}

	/**
	 * 文字列への変換
	 * @return 文字列
	 */
	virtual String toString() const{
		return getInputDeviceString() + keyboardState_.toString();
	}

protected:
	//--------------------------------------------------------------------------
	/**
	 * コンストラクタ
	 */
	KeyboardDevice();

	/**
	 * デストラクタ
	 */
	virtual ~KeyboardDevice();

	/**
	 * 初期化
	 * @param inputDevice 入力デバイス
	 * @param windowHandle ウィンドウハンドル
	 * @return 成功すればtrue
	 */
	virtual bool initialize(DirectInputDevice* inputDevice, HWND windowHandle);

	/**
	 * ポーリング
	 * @return ポーリングが正常であればtrue
	 */
	virtual bool polling();

	//--------------------------------------------------------------------------
private:
	// キーボードステート
	KeyboardState keyboardState_;

};

//------------------------------------------------------------------------------
} // End of namespace Lamp
#endif // End of KEYBOARD_DEVICE_H_
//------------------------------------------------------------------------------
