//------------------------------------------------------------------------------
// 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 MOUSE_DEVICE_H_
#define MOUSE_DEVICE_H_

#include <Input/System/InputDevice.h>
#include <Input/Mouse/MouseState.h>

namespace Lamp{

//------------------------------------------------------------------------------
/**
 * マウスデバイス
 */
class MouseDevice : public InputDevice{
friend class LampInput;
friend class BufferedInput;
public:
	//--------------------------------------------------------------------------
	// 定数
	//--------------------------------------------------------------------------
	/// 最大ボタン数
	static const int maxButtonCount = MouseState::maxButtonCount;

	//--------------------------------------------------------------------------
	/**
	 * マウスステートの取得
	 * @return マウスステート
	 */
	virtual const MouseState& getMouseState() const{ return mouseState_; }

	/**
	 * Z解像度の取得
	 * @return Z解像度
	 */
	int getZResolution() const{ return zResolution_; }

	/**
	 * 協調レベルの設定
	 * @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{
		String deviceString;
		deviceString.format("ZResolution %d\n", getZResolution());
		return getInputDeviceString() + deviceString + mouseState_.toString();
	}

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

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

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

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

private:
	// マウスステート
	MouseState mouseState_;
	// Z解像度
	int zResolution_;
};

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