2015-10-14 13:05:02 +00:00
|
|
|
#include "GamePad.h"
|
2016-09-04 12:10:02 +00:00
|
|
|
#ifdef SDL_BUILD
|
2015-10-14 13:05:02 +00:00
|
|
|
#include "SDL/joystick.h"
|
|
|
|
#endif
|
|
|
|
|
2017-04-10 16:19:23 +00:00
|
|
|
std::vector<std::unique_ptr<GamePad>> s_vgamePad;
|
|
|
|
|
2015-10-14 13:05:02 +00:00
|
|
|
bool GamePadIdWithinBounds(int GamePadId)
|
|
|
|
{
|
2016-09-04 12:10:02 +00:00
|
|
|
return ((GamePadId >= 0) && (GamePadId < (int)s_vgamePad.size()));
|
2015-10-14 13:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
**/
|
2017-04-10 16:19:23 +00:00
|
|
|
void GamePad::EnumerateGamePads(std::vector<std::unique_ptr<GamePad>> &vgamePad)
|
2015-10-14 13:05:02 +00:00
|
|
|
{
|
2016-09-04 12:10:02 +00:00
|
|
|
#ifdef SDL_BUILD
|
|
|
|
JoystickInfo::EnumerateJoysticks(vgamePad);
|
2015-10-14 13:05:02 +00:00
|
|
|
#endif
|
|
|
|
}
|
2015-11-10 07:12:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Safely dispatch to the Rumble method above
|
|
|
|
**/
|
2017-04-14 18:14:42 +00:00
|
|
|
void GamePad::DoRumble(unsigned type, unsigned pad)
|
2015-11-10 07:12:20 +00:00
|
|
|
{
|
2016-09-04 12:10:02 +00:00
|
|
|
u32 id = conf->get_joyid(pad);
|
|
|
|
if (GamePadIdWithinBounds(id)) {
|
2017-04-10 16:19:23 +00:00
|
|
|
s_vgamePad[id]->Rumble(type, pad);
|
2016-09-04 12:10:02 +00:00
|
|
|
}
|
2015-11-10 07:12:20 +00:00
|
|
|
}
|