pcsx2/plugins/onepad/GamePad.h

65 lines
1.4 KiB
C
Raw Normal View History

#pragma once
#include "onepad.h"
#include "controller.h"
2016-09-04 12:10:02 +00:00
#ifdef SDL_BUILD
#include <SDL.h>
#endif
class GamePad
{
2016-09-04 12:10:02 +00:00
public:
GamePad()
2017-04-16 12:57:23 +00:00
: m_deadzone(1500)
2016-09-04 12:10:02 +00:00
{
}
virtual ~GamePad()
{
return;
}
GamePad(const GamePad &); // copy constructor
GamePad &operator=(const GamePad &); // assignment
2016-09-04 12:10:02 +00:00
/*
* Find every interesting devices and create right structure for them(depend on backend)
*/
static void EnumerateGamePads(std::vector<std::unique_ptr<GamePad>> &vgamePad);
/*
* Update state of every attached devices
*/
2017-04-16 12:57:23 +00:00
virtual void UpdateGamePadState() = 0;
/*
* Causes devices to rumble
* Rumble will differ according to type which is either 0(small motor) or 1(big motor)
*/
virtual void Rumble(unsigned type, unsigned pad) { return; }
/*
* Safely dispatch to the Rumble method above
*/
static void DoRumble(unsigned type, unsigned pad);
/*
* Used for GUI checkbox to give feedback to the user
*/
2016-09-04 12:10:02 +00:00
virtual bool TestForce(float strength = 0.6) { return false; }
2017-04-16 12:57:23 +00:00
virtual const char *GetName() = 0;
virtual int GetInput(gamePadValues input) = 0;
2016-09-04 12:10:02 +00:00
virtual int GetDeadzone()
{
2017-04-16 12:57:23 +00:00
return m_deadzone;
2016-09-04 12:10:02 +00:00
}
protected:
2017-04-16 12:57:23 +00:00
int m_deadzone;
};
extern std::vector<std::unique_ptr<GamePad>> s_vgamePad;
extern bool GamePadIdWithinBounds(int joyid);