Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

LampInput.h

Go to the documentation of this file.
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  * Lamp入力ヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef LAMP_INPUT_H_
00026 #define LAMP_INPUT_H_
00027 
00028 #include <Core/Container/ArrayList.h>
00029 
00030 namespace Lamp{
00031 
00032 class BufferedInput;
00033 class Keyboard;
00034 class KeyboardDevice;
00035 class Mouse;
00036 class MouseDevice;
00037 class Joystick;
00038 class JoystickDevice;
00039 class BinaryWriter;
00040 class BinaryReader;
00041 
00042 //------------------------------------------------------------------------------
00043 /**
00044  * Lamp入力
00045  */
00046 class LampInput{
00047 friend class LampCore;
00048 public:
00049     /// 入力モード
00050     enum InputMode{
00051         modePolling,
00052         modeBuffering,
00053     };
00054 
00055     //--------------------------------------------------------------------------
00056     // 初期化、後始末
00057     //--------------------------------------------------------------------------
00058     /**
00059      * 初期化
00060      * @param instanceHandle インスタンスハンドル
00061      * @param windowHandle ウィンドウハンドル
00062      * @param inputMode 入力モード
00063      * @return 初期化に成功すればtrue
00064      */
00065     static bool initialize(HINSTANCE instanceHandle, HWND windowHandle,
00066         InputMode inputMode = modeBuffering);
00067 
00068     /**
00069      * 後始末
00070      */
00071     static void finalize();
00072 
00073     /**
00074      * クリア
00075      * 現在の入力をクリアします
00076      */
00077     static void clear();
00078 
00079     /**
00080      * バッファクリア
00081      * バッファと現在の入力をクリアします
00082      */
00083     static void bufferClear();
00084 
00085     //--------------------------------------------------------------------------
00086     // 入力モード
00087     //--------------------------------------------------------------------------
00088     /**
00089      * 入力モードの設定
00090      * @param inputMode 入力モード
00091      */
00092     static void setInputMode(InputMode inputMode);
00093 
00094     /**
00095      * 入力モードの取得
00096      * @return 入力モード
00097      */
00098     static InputMode getInputMode(){ return inputMode_; }
00099 
00100     //--------------------------------------------------------------------------
00101     // ポーリング入力
00102     //--------------------------------------------------------------------------
00103     /**
00104      * ポーリング
00105      * @return ポーリングが正常であればtrue
00106      */
00107     static bool polling();
00108 
00109     //--------------------------------------------------------------------------
00110     // バッファ入力
00111     //--------------------------------------------------------------------------
00112     /**
00113      * 入力があるか
00114      * @return 入力があればtrue
00115      */
00116     static bool hasMoreInput();
00117 
00118     /**
00119      * 入力を待つ
00120      */
00121     static void waitForInput();
00122 
00123     /**
00124      * 次の入力
00125      */
00126     static void nextInput();
00127 
00128     /**
00129      * 入力数の取得
00130      * @return 入力数
00131      */
00132     static int getInputCount();
00133 
00134     //--------------------------------------------------------------------------
00135     // ログ取得
00136     //--------------------------------------------------------------------------
00137     /**
00138      * ログ取得の開始
00139      * @param filePath ファイルパス
00140      */
00141     static void startLogging(const String& filePath = "LampInputLog.log");
00142 
00143     /**
00144      * ログ取得の開始
00145      * @param binaryWriter バイナリライタ
00146      */
00147     static void startLogging(BinaryWriter* binaryWriter);
00148 
00149     /**
00150      * ログ取得の終了
00151      */
00152     static void endLogging();
00153 
00154     /**
00155      * ログ取得中かどうか
00156      * @return ログ取得中ならtrue
00157      */
00158     static bool isLogging(){ return isLogging_; }
00159 
00160     //--------------------------------------------------------------------------
00161     // ログ再生
00162     //--------------------------------------------------------------------------
00163     /**
00164      * ログ再生の開始
00165      * @param filePath ファイルパス
00166      */
00167     static void playLog(const String& filePath = "LampInputLog.log");
00168 
00169     /**
00170      * ログ再生の開始
00171      * @param binaryReader バイナリリーダ
00172      */
00173     static void playLog(BinaryReader* binaryReader);
00174 
00175     /**
00176      * ログ再生の停止
00177      */
00178     static void stopLog();
00179 
00180     /**
00181      * ログ再生中かどうか
00182      * @return ログ再生中ならtrue
00183      */
00184     static bool isLogPlaying(){ return isLogPlaying_; }
00185 
00186     //--------------------------------------------------------------------------
00187     // 各種デバイス
00188     //--------------------------------------------------------------------------
00189     /**
00190      * キーボードの取得
00191      * @return キーボード
00192      */
00193     static Keyboard* getKeyboard(){ return keyboard_; }
00194 
00195     /**
00196      * キーボードデバイスの取得
00197      * @return キーボードデバイス
00198      */
00199     static KeyboardDevice* getKeyboardDevice(){ return keyboardDevice_; }
00200 
00201     //--------------------------------------------------------------------------
00202     /**
00203      * マウスの取得
00204      * @return マウス
00205      */
00206     static Mouse* getMouse(){ return mouse_; }
00207 
00208     /**
00209      * マウスデバイスの取得
00210      * @return マウスデバイス
00211      */
00212     static MouseDevice* getMouseDevice(){ return mouseDevice_; }
00213 
00214     //--------------------------------------------------------------------------
00215     /**
00216      * ジョイスティック数の取得
00217      * @return ジョイスティック数
00218      */
00219     static int getJoystickCount(){ return joysticks_.getCount(); }
00220 
00221     /**
00222      * ジョイスティックの取得
00223      * @param index ジョイスティックインデックス
00224      * @return ジョイスティック
00225      */
00226     static Joystick* getJoystick(int index){ return joysticks_[index]; }
00227 
00228     /**
00229      * ジョイスティックデバイス数の取得
00230      * @return ジョイスティックデバイス数
00231      */
00232     static int getJoystickDeviceCount(){ return joystickDevices_.getCount(); }
00233 
00234     /**
00235      * ジョイスティックデバイスの取得
00236      * @param index ジョイスティックデバイスインデックス
00237      * @return ジョイスティックデバイス
00238      */
00239     static JoystickDevice* getJoystickDevice(int index){
00240         return joystickDevices_[index];
00241     }
00242 
00243     //--------------------------------------------------------------------------
00244     /**
00245      * ジョイスティックの列挙コールバック
00246      *
00247      * ユーザはこのメソッドを呼び出さないで下さい
00248      * @param instance デバイスインスタンス
00249      * @param userData ユーザデータ
00250      * @return 列挙継続フラグ
00251      */
00252     static int __stdcall joystickEnumeration(
00253         const DIDEVICEINSTANCE* instance, void* userData);
00254 
00255 private:
00256     //--------------------------------------------------------------------------
00257     /**
00258      * ウィンドウプロシージャ
00259      * @param windowHandle ウィンドウハンドル
00260      * @param message メッセージ
00261      * @param wParam wメッセージパラメータ
00262      * @param lParam lメッセージパラメータ
00263      * @return メッセージを処理し、それ以上の処理が必要無いならば0以外を返す。
00264      */
00265     static LRESULT windowProcedure(
00266         HWND windowHandle, u_int message, WPARAM wParam, LPARAM lParam);
00267 
00268     //--------------------------------------------------------------------------
00269     // デバイスポーリング
00270     static bool devicePolling();
00271     // ログポーリング
00272     static void logPolling();
00273     // ログの書き出し
00274     static void writeLog();
00275 
00276     // バッファ入力初期化
00277     static void initializeBufferInput();
00278     // バッファ入力後始末
00279     static void finalizeBufferInput();
00280     // コンストラクタの隠蔽
00281     LampInput();
00282 
00283     // ウィンドウハンドル
00284     static HWND windowHandle_;
00285     // DirectInput
00286     static DirectInput* directInput_;
00287     // 入力モード
00288     static InputMode inputMode_;
00289     // バッファ入力
00290     static BufferedInput* bufferedInput_;
00291 
00292     // ログライタ
00293     static BinaryWriter* logWriter_;
00294     // バイナリファイルライタ
00295     static BinaryWriter* binaryFileWriter_;
00296     // ログリーダ
00297     static BinaryReader* logReader_;
00298     // バイナリファイルリーダ
00299     static BinaryReader* binaryFileReader_;
00300 
00301     // キーボード
00302     static Keyboard* keyboard_;
00303     // キーボードデバイス
00304     static KeyboardDevice* keyboardDevice_;
00305     // マウス
00306     static Mouse* mouse_;
00307     // マウスデバイス
00308     static MouseDevice* mouseDevice_;
00309     // ジョイスティック
00310     static ArrayList<Joystick*> joysticks_;
00311     // ジョイスティックデバイス
00312     static ArrayList<JoystickDevice*> joystickDevices_;
00313 
00314     // 初期化フラグ
00315     static bool isInitialized_;
00316     // ログ取得中フラグ
00317     static bool isLogging_;
00318     // ログ再生中フラグ
00319     static bool isLogPlaying_;
00320 };
00321 
00322 //------------------------------------------------------------------------------
00323 } // End of namespace Lamp
00324 #endif // End of LAMP_INPUT_H_
00325 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:31 2005 for Lamp by doxygen 1.3.2