/*---------------------------------------------------------------------------* Project: Horizon File: PadEx.h Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. 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. $Rev:$ *---------------------------------------------------------------------------*/ #ifndef NN_SAMPLE_DEMOS_PHTSEL_PADEX_H_ #define NN_SAMPLE_DEMOS_PHTSEL_PADEX_H_ #include //////////////////////////////////////////////////////////////////////////////////////////////// /// Expand pad /// //////////////////////////////////////////////////////////////////////////////////////////////// class PadEx { public: explicit PadEx( nn::hid::PadStatus& ps_ ) : ps(ps_) , m_repeat(0) , m_repeatCount(0) , m_vcount(0) , m_bCheckedNoHold(false) {} void Tick() { // Input is disabled until pad holds nothing at least once if( !m_bCheckedNoHold ) { if( 0==ps.hold ) m_bCheckedNoHold = true; ps.hold = 0; ps.trigger = 0; } // Repeat processing const GLint vcount = nngxCheckVSync(NN_GX_DISPLAY0); m_repeat = 0; if( ps.trigger ) { m_repeatCount = 0; m_repeat = ps.trigger; } if( m_vcount != vcount ) { m_vcount = vcount; if( !ps.trigger && ps.hold ){ ++m_repeatCount; } else{ m_repeatCount = 0; } static const s32 cDelay = 16; static const s32 cRepeat = 2; if( m_repeatCount < cDelay ){ } else if( (m_repeatCount - cDelay) % cRepeat == 0 ){ m_repeat = ps.hold; } } } /// Get repeat value bit32 GetRepeat() const { return m_repeat; } /// Reset void Reset() { m_bCheckedNoHold = false; ps.hold = 0; ps.trigger = 0; } public: nn::hid::PadStatus& ps; bit32 m_repeat; s32 m_repeatCount; GLint m_vcount; bool m_bCheckedNoHold; NN_PADDING3; }; /* NN_SAMPLE_DEMOS_PHTSEL_PADEX_H_ */ #endif /*---------------------------------------------------------------------------* End of file *---------------------------------------------------------------------------*/