RetroFE/RetroFE/Source/Control/KeyboardHandler.cpp

32 lines
487 B
C++

#include "KeyboardHandler.h"
KeyboardHandler::KeyboardHandler(SDL_Scancode 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.scancode == scancode_)
{
pressed_ = (e.type == SDL_KEYDOWN);
return true;
}
return false;
}
bool KeyboardHandler::pressed()
{
return pressed_;
}