pcsx2/plugins/onepad/GamePad.cpp

56 lines
1.2 KiB
C++
Raw Normal View History

#include "GamePad.h"
2016-09-04 12:10:02 +00:00
#ifdef SDL_BUILD
#include "SDL/joystick.h"
#endif
2016-09-04 12:10:02 +00:00
vector<GamePad *> s_vgamePad;
bool GamePadIdWithinBounds(int GamePadId)
{
2016-09-04 12:10:02 +00:00
return ((GamePadId >= 0) && (GamePadId < (int)s_vgamePad.size()));
}
/**
* Following static methods are just forwarders to their backend
* This is where link between agnostic and specific code is done
**/
/**
* Find every interesting devices and create right structure for them(depend on backend)
**/
2016-09-04 12:10:02 +00:00
void GamePad::EnumerateGamePads(vector<GamePad *> &vgamePad)
{
2016-09-04 12:10:02 +00:00
#ifdef SDL_BUILD
JoystickInfo::EnumerateJoysticks(vgamePad);
#endif
}
void GamePad::UpdateReleaseState()
{
2016-09-04 12:10:02 +00:00
#ifdef SDL_BUILD
JoystickInfo::UpdateReleaseState();
#endif
}
/**
* Safely dispatch to the Rumble method above
**/
void GamePad::DoRumble(int type, int pad)
{
2016-09-04 12:10:02 +00:00
u32 id = conf->get_joyid(pad);
if (GamePadIdWithinBounds(id)) {
GamePad *gamePad = s_vgamePad[id];
if (gamePad)
gamePad->Rumble(type, pad);
}
}
/**
* Update state of every attached devices
**/
void GamePad::UpdateGamePadState()
{
2016-09-04 12:10:02 +00:00
#ifdef SDL_BUILD
SDL_JoystickUpdate(); // No need to make yet another function call for that
#endif
}