onepad: don't duplicate the "GamePad" base class code/member in the "JoystickInfo" derivated class

This commit is contained in:
Gregory Hainaut 2016-08-12 22:37:37 +02:00
parent 2d8a0dc59c
commit 39bf84a13c
2 changed files with 17 additions and 84 deletions

View File

@ -69,22 +69,27 @@ class GamePad
return 0; return 0;
} }
virtual const string& GetName() const string& GetName()
{ {
return devname; return devname;
} }
virtual int GetNumButtons() int GetPAD()
{
return pad;
}
int GetNumButtons()
{ {
return numbuttons; return numbuttons;
} }
virtual int GetNumAxes() int GetNumAxes()
{ {
return numaxes; return numaxes;
} }
virtual int GetNumHats() int GetNumHats()
{ {
return numhats; return numhats;
} }
@ -94,35 +99,35 @@ class GamePad
return deadzone; return deadzone;
} }
virtual void SaveState(){return;} virtual void SaveState() {}
virtual int GetButtonState(int i) int GetButtonState(int i)
{ {
return vbuttonstate[i]; return vbuttonstate[i];
} }
virtual int GetAxisState(int i) int GetAxisState(int i)
{ {
return vaxisstate[i]; return vaxisstate[i];
} }
virtual int GetHatState(int i) int GetHatState(int i)
{ {
//PAD_LOG("Getting POV State of %d.\n", i); //PAD_LOG("Getting POV State of %d.\n", i);
return vhatstate[i]; return vhatstate[i];
} }
virtual void SetButtonState(int i, int state) void SetButtonState(int i, int state)
{ {
vbuttonstate[i] = state; vbuttonstate[i] = state;
} }
virtual void SetAxisState(int i, int value) void SetAxisState(int i, int value)
{ {
vaxisstate[i] = value; vaxisstate[i] = value;
} }
virtual void SetHatState(int i, int value) void SetHatState(int i, int value)
{ {
//PAD_LOG("We should set %d to %d.\n", i, value); //PAD_LOG("We should set %d to %d.\n", i, value);
vhatstate[i] = value; vhatstate[i] = value;

View File

@ -34,11 +34,7 @@
class JoystickInfo : GamePad class JoystickInfo : GamePad
{ {
public: public:
JoystickInfo() : devname(""), _id(-1), numbuttons(0), numaxes(0), numhats(0), JoystickInfo() : GamePad(), joy(NULL) {
deadzone(1500), pad(-1), joy(NULL) {
vbuttonstate.clear();
vaxisstate.clear();
vhatstate.clear();
#if SDL_MAJOR_VERSION >= 2 #if SDL_MAJOR_VERSION >= 2
haptic = NULL; haptic = NULL;
first = true; first = true;
@ -71,70 +67,9 @@ class JoystickInfo : GamePad
int GetButton(int key_to_button); int GetButton(int key_to_button);
const string& GetName()
{
return devname;
}
int GetNumButtons()
{
return numbuttons;
}
int GetNumAxes()
{
return numaxes;
}
int GetNumHats()
{
return numhats;
}
int GetPAD()
{
return pad;
}
int GetDeadzone()
{
return deadzone;
}
void SaveState(); void SaveState();
int GetButtonState(int i)
{
return vbuttonstate[i];
}
int GetAxisState(int i)
{
return vaxisstate[i];
}
int GetHatState(int i)
{
//PAD_LOG("Getting POV State of %d.\n", i);
return vhatstate[i];
}
void SetButtonState(int i, int state)
{
vbuttonstate[i] = state;
}
void SetAxisState(int i, int value)
{
vaxisstate[i] = value;
}
void SetHatState(int i, int value)
{
//PAD_LOG("We should set %d to %d.\n", i, value);
vhatstate[i] = value;
}
int GetAxisFromKey(int pad, int index); int GetAxisFromKey(int pad, int index);
static void UpdateReleaseState(); static void UpdateReleaseState();
@ -145,13 +80,6 @@ class JoystickInfo : GamePad
return joy; return joy;
} }
void GenerateDefaultEffect(); void GenerateDefaultEffect();
string devname; // pretty device name
int _id;
int numbuttons, numaxes, numhats;
int deadzone;
int pad;
vector<int> vbuttonstate, vaxisstate, vhatstate;
SDL_Joystick* joy; SDL_Joystick* joy;
#if SDL_MAJOR_VERSION >= 2 #if SDL_MAJOR_VERSION >= 2