#include "key_down_cdt.h"

namespace roy {

    namespace ih {

        key_down_cdt::key_down_cdt(void)
        {
            _vk = -1;
            _init_down = false;
        }

        key_down_cdt::key_down_cdt(UINT vk, bool init_down)
        {
            _vk = vk;
            _init_down = init_down;
        }

        void key_down_cdt::OnEntering(void)
        {
            _down = _init_down;
        }

        bool key_down_cdt::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
        {
            if (nChar == _vk) {
                _down = true;
            }

            return false;
        }

        bool key_down_cdt::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
        {
            if (nChar == _vk) {
                _down = false;
            }

            return false;
        }

        bool key_down_cdt::is_valid(void)
        {
            return _down;
        }
   }

}