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

SFPad.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  * SF互換パッドヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef SF_PAD_H_
00026 #define SF_PAD_H_
00027 
00028 #include <Input/Pad/Pad.h>
00029 
00030 namespace Lamp{
00031 
00032 //------------------------------------------------------------------------------
00033 /**
00034  * SF互換パッド
00035  */
00036 class SFPad : public Pad{
00037 public:
00038     /**
00039      * 互換性チェック
00040      * @param joystick 互換性をチェックするジョイスティック
00041      * @return 互換性があればtrueを返す
00042      */
00043     static bool checkCompatibility(Joystick* joystick);
00044 
00045     /// ボタン
00046     enum Button{
00047         button0 = 0,
00048         button1,
00049         button2,
00050         button3,
00051         buttonL,
00052         buttonR,
00053         buttonStart,
00054         buttonSelect,
00055         maxButtonCount,
00056         buttonUnknown = -1,
00057         buttonA = 0,
00058         buttonB = 1,
00059         buttonX = 2,
00060         buttonY = 3,
00061     };
00062 
00063     //--------------------------------------------------------------------------
00064     // 生成、破棄
00065     //--------------------------------------------------------------------------
00066     /**
00067      * コンストラクタ
00068      * @param joystick 使用するジョイスティック
00069      */
00070     SFPad(Joystick* joystick);
00071 
00072     /**
00073      * デストラクタ
00074      */
00075     virtual ~SFPad();
00076 
00077     //--------------------------------------------------------------------------
00078     // ボタンマップ
00079     //--------------------------------------------------------------------------
00080     /**
00081      * ボタンマップの変更
00082      * @param button ボタンマップを変更するボタン
00083      * @param id 変更するボタンID
00084      */
00085     virtual void changeButtonMap(Button button, int id);
00086 
00087     /**
00088      * ボタンマップの取得
00089      * @param button ボタンマップを取得するボタン
00090      * @return ボタンID
00091      */
00092     virtual int getButtonMap(const Button button){
00093         Assert((button >= 0) && (button < maxButtonCount));
00094         return buttonMap_[button];
00095     }
00096 
00097     //--------------------------------------------------------------------------
00098     // デジタル境界
00099     //--------------------------------------------------------------------------
00100     /**
00101      * デジタル境界の設定
00102      * @param digitalBoundary デジタル境界
00103      */
00104     virtual void setDigitalBoundary(float digitalBoundary){
00105         Assert((digitalBoundary > 0.f) && (digitalBoundary <= 1.f));
00106         digitalBoundary_ = digitalBoundary;
00107     }
00108 
00109     /**
00110      * デジタル境界の取得
00111      * @return デジタル境界
00112      */
00113     virtual float setDigitalBoundary() const{ return digitalBoundary_; }
00114 
00115     //--------------------------------------------------------------------------
00116     // 軸データの取得
00117     //--------------------------------------------------------------------------
00118     /**
00119      * X軸の取得
00120      * @return 1から-1の値をとるX軸
00121      */
00122     virtual float getXAxis() const;
00123 
00124     /**
00125      * Y軸の取得
00126      * @return 1から-1の値をとるY軸
00127      */
00128     virtual float getYAxis() const;
00129 
00130     //--------------------------------------------------------------------------
00131     // 十字キーデータの取得
00132     //--------------------------------------------------------------------------
00133     /**
00134      * 上キーが押されているか
00135      * @return 上キーが押されていればtrue
00136      */
00137     virtual bool upKeyPressed() const;
00138 
00139     /**
00140      * 上キーが下がった
00141      * @return 上キーが下がったならばtrue
00142      */
00143     virtual bool upKeyDown() const;
00144 
00145     /**
00146      * 上キーが上がった
00147      * @return 上キーが上がったならばtrue
00148      */
00149     virtual bool upKeyUp() const;
00150 
00151     //--------------------------------------------------------------------------
00152     /**
00153      * 下キーが押されているか
00154      * @return 下キーが押されていればtrue
00155      */
00156     virtual bool downKeyPressed() const;
00157 
00158     /**
00159      * 下キーが下がった
00160      * @return 下キーが下がったならばtrue
00161      */
00162     virtual bool downKeyDown() const;
00163 
00164     /**
00165      * 下キーが上がった
00166      * @return 下キーが上がったならばtrue
00167      */
00168     virtual bool downKeyUp() const;
00169 
00170     //--------------------------------------------------------------------------
00171     /**
00172      * 左キーが押されているか
00173      * @return 左キーが押されていればtrue
00174      */
00175     virtual bool leftKeyPressed() const;
00176 
00177     /**
00178      * 左キーが下がった
00179      * @return 左キーが下がったならばtrue
00180      */
00181     virtual bool leftKeyDown() const;
00182 
00183     /**
00184      * 左キーが上がった
00185      * @return 左キーが上がったならばtrue
00186      */
00187     virtual bool leftKeyUp() const;
00188 
00189     //--------------------------------------------------------------------------
00190     /**
00191      * 右キーが押されているか
00192      * @return 右キーが押されていればtrue
00193      */
00194     virtual bool rightKeyPressed() const;
00195 
00196     /**
00197      * 右キーが下がった
00198      * @return 右キーが下がったならばtrue
00199      */
00200     virtual bool rightKeyDown() const;
00201 
00202     /**
00203      * 右キーが上がった
00204      * @return 右キーが上がったならばtrue
00205      */
00206     virtual bool rightKeyUp() const;
00207 
00208     //--------------------------------------------------------------------------
00209     // ボタンデータの取得
00210     //--------------------------------------------------------------------------
00211     /**
00212      * ボタンが押されているか
00213      * @param button ボタン
00214      * @return ボタンが押されていればtrue
00215      */
00216     virtual bool buttonPressed(Button button) const;
00217 
00218     /**
00219      * ボタンが下がった
00220      * @param button ボタン
00221      * @return ボタンが下がったならばtrue
00222      */
00223     virtual bool buttonDown(Button button) const;
00224 
00225     /**
00226      * ボタンが上がった
00227      * @param button ボタン
00228      * @return ボタンが上がったならばtrue
00229      */
00230     virtual bool buttonUp(Button button) const;
00231 
00232     //--------------------------------------------------------------------------
00233     // 文字列データ取得
00234     //--------------------------------------------------------------------------
00235     /**
00236      * ボタン文字列の取得
00237      * @param button ボタン
00238      * @return ボタン文字列
00239      */
00240     static String getButtonString(Button button);
00241 
00242     /**
00243      * 文字列への変換
00244      * @return 文字列
00245      */
00246     virtual String toString() const;
00247 
00248 protected:
00249     //--------------------------------------------------------------------------
00250     /**
00251      * Y軸値から上キーへの変換
00252      * @param yAxis Y軸値
00253      * @return 上キーが押されていればtrue
00254      */
00255     inline bool yAxisToUpKey(float yAxis) const{
00256         return (yAxis < (-digitalBoundary_));
00257     }
00258 
00259     /**
00260      * Y軸値から下キーへの変換
00261      * @param yAxis Y軸値
00262      * @return 下キーが押されていればtrue
00263      */
00264     inline bool yAxisToDownKey(float yAxis) const{
00265         return (yAxis > digitalBoundary_);
00266     }
00267 
00268     /**
00269      * X軸値から左キーへの変換
00270      * @param xAxis X軸値
00271      * @return 左キーが押されていればtrue
00272      */
00273     inline bool xAxisToLeftKey(float xAxis) const{
00274         return (xAxis < (-digitalBoundary_));
00275     }
00276 
00277     /**
00278      * X軸値から右キーへの変換
00279      * @param xAxis X軸値
00280      * @return 右キーが押されていればtrue
00281      */
00282     inline bool xAxisToRightKey(float xAxis) const{
00283         return (xAxis > digitalBoundary_);
00284     }
00285 
00286     /// ボタンマップ
00287     int buttonMap_[maxButtonCount];
00288     /// デジタル境界
00289     float digitalBoundary_;
00290 
00291 private:
00292 
00293 };
00294 
00295 //------------------------------------------------------------------------------
00296 } // End of namespace Lamp
00297 #endif // End of SF_PAD_H_
00298 //------------------------------------------------------------------------------

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