/*---------------------------------------------------------------------------* Project: NintendoWare File: demo_PadButton.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_BUTTON_IMPL_H_ #define NW_DEMO_PAD_BUTTON_IMPL_H_ #include namespace nw { namespace demo { namespace internal { //--------------------------------------------------------------------------- //! @brief パッドのボタン状態を管理するクラスです。 //--------------------------------------------------------------------------- class PadButton { public: static const int BUTTON_COUNT_MAX = 32; //!< ボタンを表すビットフラグの桁数の最大値です。 static const int REPEAT_START = 25; //!< キーリピート開始までのフレーム数です。 static const int REPEAT_SPAN = 6; //!< キーリピートの間隔フレーム数です。 //! @brief コンストラクタです。 //! PadButton(); //! @brief パッド状態を更新します。 //! 前回の状態と比較して、DownやRepeatのフラグを立てます。 //! //! @param[in] buttonStatus ボタンが押されている状態を表すビットフラグです。 //! void Update( u32 buttonStatus ); //! @brief 押されている状態はそのままに、 //! DownやRepeatのフラグのみ落とします。 //! void ClearTriggerFlag(); //! @brief パッドの状態を初期状態にします。 //! 次回Update時に、ボタンが押されていても、 //! DownやRepeatのフラグは立ちません。 //! void Reset(); bool IsButtonPress( u32 buttonBit ) const { return ( m_ButtonPress & buttonBit ) != 0; } bool IsButtonDown( u32 buttonBit ) const { return ( m_ButtonDown & buttonBit ) != 0; } bool IsButtonUp( u32 buttonBit ) const { return ( m_ButtonUp & buttonBit ) != 0; } bool IsButtonRepeat( u32 buttonBit ) const { return ( m_ButtonRepeat & buttonBit ) != 0; } bool IsButtonRepeatFast( u32 buttonBit ) const { return ( m_ButtonRepeatFast & buttonBit ) != 0; } private: u32 m_ButtonPress; u32 m_ButtonDown; u32 m_ButtonUp; u32 m_ButtonRepeat; u32 m_ButtonRepeatFast; u8 m_RepeatCounter[ BUTTON_COUNT_MAX ]; u8 m_RepeatCounterFast[ BUTTON_COUNT_MAX ]; bool m_ResetFlag; u8 padding[3]; }; } // namespace nw::demo::internal } // namespace nw::demo } // namespace nw #endif /* NW_DEMO_PAD_BUTTON_IMPL_H_ */