From 39bf84a13c3c76d20f107db695716e161be5ec50 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Fri, 12 Aug 2016 22:37:37 +0200 Subject: [PATCH] onepad: don't duplicate the "GamePad" base class code/member in the "JoystickInfo" derivated class --- plugins/onepad/GamePad.h | 27 +++++++------ plugins/onepad/SDL/joystick.h | 74 +---------------------------------- 2 files changed, 17 insertions(+), 84 deletions(-) diff --git a/plugins/onepad/GamePad.h b/plugins/onepad/GamePad.h index a3681bcf8c..b707490b6f 100644 --- a/plugins/onepad/GamePad.h +++ b/plugins/onepad/GamePad.h @@ -69,22 +69,27 @@ class GamePad return 0; } - virtual const string& GetName() + const string& GetName() { return devname; } - virtual int GetNumButtons() + int GetPAD() + { + return pad; + } + + int GetNumButtons() { return numbuttons; } - virtual int GetNumAxes() + int GetNumAxes() { return numaxes; } - virtual int GetNumHats() + int GetNumHats() { return numhats; } @@ -94,35 +99,35 @@ class GamePad return deadzone; } - virtual void SaveState(){return;} + virtual void SaveState() {} - virtual int GetButtonState(int i) + int GetButtonState(int i) { return vbuttonstate[i]; } - virtual int GetAxisState(int i) + int GetAxisState(int i) { return vaxisstate[i]; } - virtual int GetHatState(int i) + int GetHatState(int i) { //PAD_LOG("Getting POV State of %d.\n", i); return vhatstate[i]; } - virtual void SetButtonState(int i, int state) + void SetButtonState(int i, int state) { vbuttonstate[i] = state; } - virtual void SetAxisState(int i, int value) + void SetAxisState(int i, int 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); vhatstate[i] = value; diff --git a/plugins/onepad/SDL/joystick.h b/plugins/onepad/SDL/joystick.h index 5fe9ece548..8b20d79ae8 100644 --- a/plugins/onepad/SDL/joystick.h +++ b/plugins/onepad/SDL/joystick.h @@ -34,11 +34,7 @@ class JoystickInfo : GamePad { public: - JoystickInfo() : devname(""), _id(-1), numbuttons(0), numaxes(0), numhats(0), - deadzone(1500), pad(-1), joy(NULL) { - vbuttonstate.clear(); - vaxisstate.clear(); - vhatstate.clear(); + JoystickInfo() : GamePad(), joy(NULL) { #if SDL_MAJOR_VERSION >= 2 haptic = NULL; first = true; @@ -71,70 +67,9 @@ class JoystickInfo : GamePad 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(); - 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); static void UpdateReleaseState(); @@ -145,13 +80,6 @@ class JoystickInfo : GamePad return joy; } void GenerateDefaultEffect(); - string devname; // pretty device name - int _id; - int numbuttons, numaxes, numhats; - int deadzone; - int pad; - - vector vbuttonstate, vaxisstate, vhatstate; SDL_Joystick* joy; #if SDL_MAJOR_VERSION >= 2