Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove hardcoded values for Gamepad class #555

Merged
merged 1 commit into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions src/gamecontroller/gamecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,6 @@ void GameController::closeSDLDevice()
}
}

int GameController::getNumberRawButtons() { return SDL_CONTROLLER_BUTTON_MAX; }

int GameController::getNumberRawAxes()
{
qDebug() << "Controller has " << SDL_CONTROLLER_AXIS_MAX << " raw axes";

return SDL_CONTROLLER_AXIS_MAX;
}

/**
* @brief Queries the data rate of the given sensor from SDL.
* @returns Data rate in events per second or zero if data rate is unavailable.
Expand Down Expand Up @@ -223,8 +214,6 @@ bool GameController::hasRawSensor(JoySensorType type)
return false;
}

int GameController::getNumberRawHats() { return 0; }

void GameController::setCounterUniques(int counter) { counterUniques = counter; }

void GameController::fillContainers(QHash<int, SDL_GameControllerButton> &buttons, QHash<int, SDL_GameControllerAxis> &axes,
Expand Down
3 changes: 0 additions & 3 deletions src/gamecontroller/gamecontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ class GameController : public InputDevice
virtual void closeSDLDevice() override;
virtual SDL_JoystickID getSDLJoystickID() override;

virtual int getNumberRawButtons() override;
virtual int getNumberRawAxes() override;
virtual int getNumberRawHats() override;
virtual double getRawSensorRate(JoySensorType type) override;
virtual bool hasRawSensor(JoySensorType type) override;
void setCounterUniques(int counter) override;
Expand Down
6 changes: 6 additions & 0 deletions src/inputdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,12 @@ QString InputDevice::getDescription()
return full_desc;
}

int InputDevice::getNumberRawAxes() { return SDL_JoystickNumAxes(m_joyhandle); }

int InputDevice::getNumberRawButtons() { return SDL_JoystickNumButtons(m_joyhandle); }

int InputDevice::getNumberRawHats() { return SDL_JoystickNumHats(m_joyhandle); }

QString InputDevice::getSDLPlatform()
{
QString temp = SDL_GetPlatform();
Expand Down
6 changes: 3 additions & 3 deletions src/inputdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ class InputDevice : public QObject
void setDPadName(int dpadIndex, QString tempName); // InputDeviceHat class
void setVDPadName(int vdpadIndex, QString tempName); // InputDeviceVDPad class

virtual int getNumberRawButtons() = 0;
virtual int getNumberRawAxes() = 0;
virtual int getNumberRawHats() = 0;
virtual int getNumberRawButtons();
virtual int getNumberRawAxes();
virtual int getNumberRawHats();
virtual double getRawSensorRate(JoySensorType type) = 0;
virtual bool hasRawSensor(JoySensorType type) = 0;

Expand Down
18 changes: 0 additions & 18 deletions src/joystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,6 @@ void Joystick::closeSDLDevice()
}
}

int Joystick::getNumberRawButtons()
{
int numbuttons = SDL_JoystickNumButtons(m_joyhandle);
return numbuttons;
}

int Joystick::getNumberRawAxes()
{
int numaxes = SDL_JoystickNumAxes(m_joyhandle);
return numaxes;
}

int Joystick::getNumberRawHats()
{
int numhats = SDL_JoystickNumHats(m_joyhandle);
return numhats;
}

double Joystick::getRawSensorRate(JoySensorType _) { return 0; }

bool Joystick::hasRawSensor(JoySensorType _) { return false; }
Expand Down
3 changes: 0 additions & 3 deletions src/joystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ class Joystick : public InputDevice
virtual void closeSDLDevice() override;
virtual SDL_JoystickID getSDLJoystickID() override;

virtual int getNumberRawButtons() override;
virtual int getNumberRawAxes() override;
virtual int getNumberRawHats() override;
virtual double getRawSensorRate(JoySensorType type) override;
virtual bool hasRawSensor(JoySensorType type) override;

Expand Down