/*---------------------------------------------------------------------------* Project: horizon File: hid_AnalogStickClamper.h Copyright 2011 Nintendo. 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_HID_CTR_HID_ANALOG_STICK_CLAMPER_H_ #define NN_HID_CTR_HID_ANALOG_STICK_CLAMPER_H_ #include #include #include #include namespace nn { namespace hid { namespace CTR { const f32 DEFAULT_SCALE_OF_NORMALIZE_STICK = 1.5f; const s16 DEFAULT_THRESHOLD_OF_NORMALIZE_STICK = 141; /* Please see man pages for details */ const s16 MIN_OF_STICK_CLAMP_MODE_CIRCLE = 40; /* Please see man pages for details */ const s16 MIN_OF_STICK_CLAMP_MODE_CROSS = 36; /* Please see man pages for details */ const s16 LIMIT_OF_STICK_CLAMP_MAX = 145; class AnalogStickClamper { public: enum ClampMode { CLAMP_MODE_CIRCLE = 0, CLAMP_MODE_CROSS, CLAMP_MODE_MINIMUM }; public: AnalogStickClamper(); ~AnalogStickClamper(){}; void SetStickClamp(s16 min, s16 max); void GetStickClamp(s16* pMin, s16* pMax) const; ClampMode GetStickClampMode( ) const; void SetStickClampMode(ClampMode mode); f32 NormalizeStick(s16 x); void NormalizeStickWithScale( f32* normalized_x, f32* normalized_y, s16 x, s16 y ); void SetNormalizeStickScaleSettings( f32 scale, s16 threshold ); void GetNormalizeStickScaleSettings( f32* scale, s16* threshold ) const; void ClampValueOfClamp(); void ClampCore(s16* pOutX, s16* pOutY,s32 x,s32 y); private: s16 m_MinOfStickClampCircle; s16 m_MinOfStickClampCross; s16 m_MinOfStickClampMinimum; s16 m_MaxOfStickClampCircle; s16 m_MaxOfStickClampCross; s16 m_MaxOfStickClampMinimum; nn::util::SizedEnum1 m_StickClampMode; NN_PADDING1; s16 m_Threshold; f32 m_Scale; f32 m_Stroke; f32 m_StrokeVelocity; f32 m_LastLength; f32 m_LastDiff; }; }}} #endif /* HID_ANALOGSTICKCLAMPER_H_ */