00001 //------------------------------------------------------------------------------ 00002 // Lamp : Open source game middleware 00003 // Copyright (C) 2004 Junpei Ohtani ( Email : junpee@users.sourceforge.jp ) 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 //------------------------------------------------------------------------------ 00019 00020 /** @file 00021 * キーボードデバイスヘッダ 00022 * @author Junpee 00023 */ 00024 00025 #ifndef KEYBOARD_DEVICE_H_ 00026 #define KEYBOARD_DEVICE_H_ 00027 00028 #include <Input/System/InputDevice.h> 00029 #include <Input/Keyboard/KeyboardKey.h> 00030 #include <Input/Keyboard/KeyboardState.h> 00031 00032 namespace Lamp{ 00033 00034 //------------------------------------------------------------------------------ 00035 /** 00036 * キーボードデバイス 00037 */ 00038 class KeyboardDevice : public InputDevice, public KeyboardKey{ 00039 friend class LampInput; 00040 friend class BufferedInput; 00041 public: 00042 /** 00043 * キーボードステートの取得 00044 * @return キーボードステート 00045 */ 00046 virtual const KeyboardState& getKeyboardState() const{ 00047 return keyboardState_; 00048 } 00049 00050 /** 00051 * 協調レベルの設定 00052 * @param exclusive 排他モードならtrue 00053 * @param foreground フォアグラウンドモードならtrue 00054 * @return 成功すればtrue 00055 */ 00056 virtual bool setCooperativeLevel(bool exclusive, bool foreground){ 00057 // 不正な組み合わせチェック 00058 Assert(!(exclusive && (!foreground))); 00059 return InputDevice::setCooperativeLevel(exclusive, foreground); 00060 } 00061 00062 /** 00063 * 文字列への変換 00064 * @return 文字列 00065 */ 00066 virtual String toString() const{ 00067 return getInputDeviceString() + keyboardState_.toString(); 00068 } 00069 00070 protected: 00071 //-------------------------------------------------------------------------- 00072 /** 00073 * コンストラクタ 00074 */ 00075 KeyboardDevice(); 00076 00077 /** 00078 * デストラクタ 00079 */ 00080 virtual ~KeyboardDevice(); 00081 00082 /** 00083 * 初期化 00084 * @param inputDevice 入力デバイス 00085 * @param windowHandle ウィンドウハンドル 00086 * @return 成功すればtrue 00087 */ 00088 virtual bool initialize(DirectInputDevice* inputDevice, HWND windowHandle); 00089 00090 /** 00091 * ポーリング 00092 * @return ポーリングが正常であればtrue 00093 */ 00094 virtual bool polling(); 00095 00096 //-------------------------------------------------------------------------- 00097 private: 00098 // キーボードステート 00099 KeyboardState keyboardState_; 00100 00101 }; 00102 00103 //------------------------------------------------------------------------------ 00104 } // End of namespace Lamp 00105 #endif // End of KEYBOARD_DEVICE_H_ 00106 //------------------------------------------------------------------------------