/*---------------------------------------------------------------------------* Project: NintendoWare File: demo_Pad.h Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo and/or its licensed developers and are protected by national and international copyright laws. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. The content herein is highly confidential and should be handled accordingly. $Revision: $ *---------------------------------------------------------------------------*/ #ifndef NW_DEMO_PAD_H_ #define NW_DEMO_PAD_H_ #include #include #include #include #include #include namespace nw { namespace demo { class PadFactory; //--------------------------------------------------------------------------- //! @brief デモ用のゲームパッドを表すクラスです。 //--------------------------------------------------------------------------- class Pad { private: NW_DISALLOW_COPY_AND_ASSIGN(Pad); public: friend class PadFactory; //! @brief ボタンを表すビット値です。 enum Button { BUTTON_A = nn::hid::CTR::BUTTON_A, //!< @brief A ボタンです。 BUTTON_B = nn::hid::CTR::BUTTON_B, //!< @brief B ボタンです。 BUTTON_START = nn::hid::CTR::BUTTON_START, //!< @brief START ボタンです。 BUTTON_RIGHT = nn::hid::CTR::BUTTON_RIGHT, //!< @brief 十字ボタンの右です。 BUTTON_LEFT = nn::hid::CTR::BUTTON_LEFT, //!< @brief 十字ボタンの左です。 BUTTON_UP = nn::hid::CTR::BUTTON_UP, //!< @brief 十字ボタンの上です。 BUTTON_DOWN = nn::hid::CTR::BUTTON_DOWN, //!< @brief 十字ボタンの下です。 BUTTON_R = nn::hid::CTR::BUTTON_R, //!< @brief R ボタンです。 BUTTON_L = nn::hid::CTR::BUTTON_L, //!< @brief L ボタンです。 BUTTON_X = nn::hid::CTR::BUTTON_X, //!< @brief X ボタンです。 BUTTON_Y = nn::hid::CTR::BUTTON_Y, //!< @brief Y ボタンです。 BUTTON_DEBUG = nn::hid::CTR::BUTTON_DEBUG, //!< @brief DEBUG ボタンです。 // BUTTON_HEADPHONE = nn::hid::CTR::BUTTON_HEADPHONE, BUTTON_EMULATION_RIGHT = nn::hid::CTR::BUTTON_RIGHT, //!< @brief アナログスティックによる十字ボタンエミュレーションの右です。 BUTTON_EMULATION_LEFT = nn::hid::CTR::BUTTON_RIGHT, //!< @brief アナログスティックによる十字ボタンエミュレーションの左です。 BUTTON_EMULATION_UP = nn::hid::CTR::BUTTON_RIGHT, //!< @brief アナログスティックによる十字ボタンエミュレーションの上です。 BUTTON_EMULATION_DOWN = nn::hid::CTR::BUTTON_RIGHT, //!< @brief アナログスティックによる十字ボタンエミュレーションの下です。 BUTTON_SELECT = nn::hid::CTR::PSEUDO_BUTTON_SELECT //!< @brief SELECT ボタンです。 }; //! @brief パッド状態を初期化します。 //! void Initialize(); //! @brief パッド状態の終了処理を行います。 //! void Finalize(); //! @brief パッド状態を更新します。 //! void Update(); //! @brief パッドの状態を初期状態にします。 //! void Reset(); //! @brief ボタンが押されている間を判定します。 //! //! @param[in] button ボタンを表すビット列です。 //! //! @return ボタンを押している間、trueを返します。 //! bool IsButtonPress( Button button ) const; //! @brief ボタンが押された時を判定します。 //! //! @param[in] button ボタンを表すビット列です。 //! //! @return ボタンを押した時だけ、trueを返します。 //! bool IsButtonDown( Button button ) const; //! @brief ボタンが離された時を判定します。 //! //! @param[in] button ボタンを表すビット列です。 //! //! @return ボタンを離した時だけ、trueを返します。 //! bool IsButtonUp( Button button ) const; //! @brief ボタンが押され続けられている間、一定間隔でtrueを返します。 //! //! @param[in] button ボタンを表すビット列です。 //! //! @return ボタンが押され続けられている間、trueを返します。 //! bool IsButtonRepeat( Button button ) const; //! @brief ボタンが押され続けられている間、一定間隔でtrueを返します。 //! IsButtonRepeat()より早い間隔となります。 //! //! @param[in] button ボタンを表すビット列です。 //! //! @return ボタンが押され続けられている間、trueを返します。 //! bool IsButtonRepeatFast( Button button ) const; //! @brief アナログスティックのx値を得ます。 //! //! @return アナログスティックのx値を返します。 //! s16 GetAnalogStickX() const { return m_AnalogStickX; } //! @brief アナログスティックのy値を得ます。 //! //! @return アナログスティックのy値を返します。 //! s16 GetAnalogStickY() const { return m_AnalogStickY; } //! @brief アナログスティックの値を得ます。 //! //! @return アナログスティックの値をnw::math::VEC2型で返します。 //! 各要素の値の範囲は -1 ~ 1 です。 //! nw::math::VEC2 GetAnalogStick() const { return m_AnalogStick; } //! @brief テストモードを切り替えます。 //! //! テストモードにすると、このクラスはパッドの出力を無視して、 //! SetTestPadStatus の入力を使用するようになります。 //! //! @param[in] enabled true を指定すると、テストモードを有効にします。 void EnableTestMode(bool enabled) { m_IsTestMode = enabled; } //! @brief テストモードのパッド入力を設定します。 //! //! @param[in] status nn::hid::PadStatus.hold に相当する値です。 void SetTestPadStatus(u32 status) { m_TestPadStatus = status; } protected: //! @brief デモ用ゲームパッドを生成します。 //! //! @return 生成したデモ用ゲームパッドを返します。 //! static Pad* Create(os::IAllocator* allocator); //! @brief デモ用ゲームパッドを破棄します。 //! void Destroy(); private: //! @brief コンストラクタです。 //! Pad() : m_AnalogStickX(0), m_AnalogStickY(0), m_AnalogStick(math::VEC2::Zero()), m_IsTestMode(false), m_TestPadStatus(0) {} private: internal::PadButton m_PadButton; os::IAllocator* m_Allocator; nn::hid::PadStatus m_PadStatus; s16 m_AnalogStickX; s16 m_AnalogStickY; nw::math::VEC2 m_AnalogStick; bool m_IsTestMode; u32 m_TestPadStatus; }; //--------------------------------------------------------------------------- //! @brief デモ用のゲームパッドをひとつだけ生成するクラスです。 //--------------------------------------------------------------------------- class PadFactory { public: //! @brief 初期化します。 //! //! @param[in] allocator アロケーターです。 //! static void Initialize(os::IAllocator* allocator); //! @brief 終了処理を行います。 //! static void Finalize(); //! @brief ゲームパッドを取得します。 //! //! @return ゲームパッドへのポインタを返します。 //! static Pad* GetPad(); private: //! @brief コンストラクタです。 //! PadFactory(){} static Pad* s_pPad; }; } // namespace nw::demo } // namespace nw #endif /* NW_DEMO_PAD_H_ */