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

JoystickDevice.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  * ジョイスティックデバイスヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef JOYSTICK_DEVICE_H_
00026 #define JOYSTICK_DEVICE_H_
00027 
00028 #include <Input/System/InputDevice.h>
00029 #include <Input/Joystick/JoystickState.h>
00030 
00031 namespace Lamp{
00032 
00033 //------------------------------------------------------------------------------
00034 /**
00035  * ジョイスティックデバイス
00036  */
00037 class JoystickDevice : public InputDevice{
00038 friend class LampInput;
00039 friend class BufferedInput;
00040 public:
00041     //--------------------------------------------------------------------------
00042     // 定数
00043     //--------------------------------------------------------------------------
00044     /// 最大視点コントローラ数
00045     static const int maxPOVCount = JoystickState::maxPOVCount;
00046 
00047     /// 最大スライダ数
00048     static const int maxSliderCount = JoystickState::maxSliderCount;
00049 
00050     /// 最大ボタン数
00051     static const int maxButtonCount = JoystickState::maxButtonCount;
00052 
00053     /// 軸データ最大値
00054     static const int maxAxisValue = JoystickState::maxAxisValue;
00055 
00056     /// 軸データ最小値
00057     static const int minAxisValue = JoystickState::minAxisValue;
00058 
00059     /// 視点コントローラ最大値
00060     static const int maxPOVValue = JoystickState::maxPOVValue;
00061 
00062     //--------------------------------------------------------------------------
00063     /**
00064      * ジョイスティックステートの取得
00065      * @return ジョイスティックステート
00066      */
00067     virtual const JoystickState& getJoystickState() const{
00068         return joystickState_;
00069     }
00070 
00071     /**
00072      * 文字列への変換
00073      * @return 文字列
00074      */
00075     virtual String toString() const;
00076 
00077     //--------------------------------------------------------------------------
00078     /**
00079      * X軸を持つか
00080      * @return X軸を持てばtrue
00081      */
00082     virtual bool hasXAxis() const{ return hasXAxis_; }
00083 
00084     /**
00085      * Y軸を持つか
00086      * @return Y軸を持てばtrue
00087      */
00088     virtual bool hasYAxis() const{ return hasYAxis_; }
00089 
00090     /**
00091      * Z軸を持つか
00092      * @return Z軸を持てばtrue
00093      */
00094     virtual bool hasZAxis() const{ return hasZAxis_; }
00095 
00096     //--------------------------------------------------------------------------
00097     /**
00098      * X回転を持つか
00099      * @return X回転を持てばtrue
00100      */
00101     virtual bool hasXRotation() const{ return hasXRotation_; }
00102 
00103     /**
00104      * Y回転を持つか
00105      * @return Y回転を持てばtrue
00106      */
00107     virtual bool hasYRotation() const{ return hasYRotation_; }
00108 
00109     /**
00110      * Z回転を持つか
00111      * @return Z回転を持てばtrue
00112      */
00113     virtual bool hasZRotation() const{ return hasZRotation_; }
00114 
00115     //--------------------------------------------------------------------------
00116     /**
00117      * 視点コントローラ数の取得
00118      * @return 視点コントローラ数
00119      */
00120     virtual int getPOVCount() const{ return povCount_; }
00121 
00122     /**
00123      * スライダ数の取得
00124      * @return スライダ数
00125      */
00126     virtual int getSliderCount() const{ return sliderCount_; }
00127 
00128     //--------------------------------------------------------------------------
00129     /**
00130      * ジョイスティックオブジェクトの列挙コールバック
00131      *
00132      * ユーザはこのメソッドを呼び出さないで下さい
00133      * @param instance デバイスオブジェクトインスタンス
00134      * @param userData ユーザデータ
00135      * @return 列挙継続フラグ
00136      */
00137     static int __stdcall joystickObjectEnumeration(
00138         const DIDEVICEOBJECTINSTANCE* instance, void* userData);
00139 
00140 protected:
00141     //--------------------------------------------------------------------------
00142     /**
00143      * コンストラクタ
00144      */
00145     JoystickDevice();
00146 
00147     /**
00148      * デストラクタ
00149      */
00150     virtual ~JoystickDevice();
00151 
00152     /**
00153      * 初期化
00154      * @param inputDevice 入力デバイス
00155      * @param windowHandle ウィンドウハンドル
00156      * @return 成功すればtrue
00157      */
00158     virtual bool initialize(DirectInputDevice* inputDevice, HWND windowHandle);
00159 
00160     /**
00161      * ジョイスティックオブジェクトのチェック
00162      * @param instance ジョイスティックオブジェクト
00163      * @return 成功すればtrue
00164      */
00165     virtual bool checkJoystickObject(const DIDEVICEOBJECTINSTANCE* instance);
00166 
00167     /**
00168      * ポーリング
00169      * @return ポーリングが正常であればtrue
00170      */
00171     virtual bool polling();
00172 
00173 private:
00174     // ジョイスティックステート
00175     JoystickState joystickState_;
00176     // 視点コントローラ数
00177     int povCount_;
00178     // スライダ数
00179     int sliderCount_;
00180     // X軸を持っているか
00181     bool hasXAxis_;
00182     // Y軸を持っているか
00183     bool hasYAxis_;
00184     // Z軸を持っているか
00185     bool hasZAxis_;
00186     // X回転を持っているか
00187     bool hasXRotation_;
00188     // Y回転を持っているか
00189     bool hasYRotation_;
00190     // Z回転を持っているか
00191     bool hasZRotation_;
00192 
00193     // デッドゾーン
00194     static const int deadZone_ = 3000;
00195     // 飽和ゾーン
00196     static const int saturationZone_ = 9500;
00197 };
00198 
00199 //------------------------------------------------------------------------------
00200 } // End of namespace Lamp
00201 #endif // End of JOYSTICK_DEVICE_H_
00202 //------------------------------------------------------------------------------

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