mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-24 08:44:48 +01:00
33 lines
609 B
C++
33 lines
609 B
C++
#include "JoyButtonHandler.h"
|
|
|
|
JoyButtonHandler::JoyButtonHandler(SDL_JoystickID joynum, Uint8 button)
|
|
: joynum_(joynum)
|
|
, button_(button)
|
|
, pressed_(false)
|
|
{
|
|
}
|
|
|
|
void JoyButtonHandler::reset()
|
|
{
|
|
pressed_= false;
|
|
}
|
|
|
|
bool JoyButtonHandler::update(SDL_Event &e)
|
|
{
|
|
if(e.type != SDL_JOYBUTTONUP && e.type != SDL_JOYBUTTONDOWN) return false;
|
|
|
|
if((joynum_ == -1 || e.jbutton.which == joynum_) && e.jbutton.button == button_)
|
|
{
|
|
pressed_ = (e.type == SDL_JOYBUTTONDOWN) ? true : false;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool JoyButtonHandler::pressed()
|
|
{
|
|
return pressed_;
|
|
}
|
|
|