RetroFE/RetroFE/Source/Control/KeyboardHandler.cpp
Vincent-FK d23cf74c1d convert to SDL 1.2
Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
2020-11-15 21:07:04 +01:00

32 lines
475 B
C++

#include "KeyboardHandler.h"
KeyboardHandler::KeyboardHandler(SDLKey s)
: scancode_(s)
, pressed_(false)
{
}
void KeyboardHandler::reset()
{
pressed_= false;
}
bool KeyboardHandler::update(SDL_Event &e)
{
if(e.type != SDL_KEYUP && e.type != SDL_KEYDOWN) return false;
if(e.key.keysym.sym == scancode_)
{
pressed_ = (e.type == SDL_KEYDOWN);
return true;
}
return false;
}
bool KeyboardHandler::pressed()
{
return pressed_;
}