mirror of
https://github.com/Rosalie241/RMG.git
synced 2026-11-12 17:18:43 +01:00
RMG-Input: implement 'Test Rumble' button in the options dialog
This commit is contained in:
1 parent
042717c3a4
commit
9155faf1d2
6 files changed
+72
-8
No files matched your search
@@ -10,11 +10,15 @@
|
||||
#include "OptionsDialog.hpp"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <RMG-Core/Core.hpp>
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
using namespace UserInterface;
|
||||
|
||||
OptionsDialog::OptionsDialog(QWidget* parent, OptionsDialogSettings settings) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint)
|
||||
OptionsDialog::OptionsDialog(QWidget* parent, OptionsDialogSettings settings,
|
||||
SDL_Joystick* joystick, SDL_GameController* controller) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint)
|
||||
{
|
||||
this->setupUi(this);
|
||||
|
||||
@@ -31,6 +35,11 @@ OptionsDialog::OptionsDialog(QWidget* parent, OptionsDialogSettings settings) :
|
||||
{
|
||||
this->hideEmulationInfoText();
|
||||
}
|
||||
|
||||
this->currentJoystick = joystick;
|
||||
this->currentController = controller;
|
||||
|
||||
this->testRumbleButton->setEnabled(this->currentJoystick != nullptr || this->currentController != nullptr);
|
||||
}
|
||||
|
||||
OptionsDialogSettings OptionsDialog::GetSettings()
|
||||
@@ -100,3 +109,27 @@ void OptionsDialog::on_changeGameboySaveButton_clicked()
|
||||
this->gameboySaveLineEdit->setText(QDir::toNativeSeparators(gameBoySave));
|
||||
}
|
||||
}
|
||||
|
||||
void OptionsDialog::on_testRumbleButton_clicked()
|
||||
{
|
||||
if ((this->currentJoystick != nullptr && SDL_JoystickHasRumble(this->currentJoystick) != SDL_TRUE) ||
|
||||
(this->currentController != nullptr && SDL_GameControllerHasRumble(this->currentController) != SDL_TRUE))
|
||||
{
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setIcon(QMessageBox::Icon::Critical);
|
||||
msgBox.setWindowTitle("Error");
|
||||
msgBox.setText("Controller doesn't support rumble");
|
||||
msgBox.addButton(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->currentJoystick != nullptr)
|
||||
{
|
||||
SDL_JoystickRumble(this->currentJoystick, 0xFFFF, 0xFFFF, 1500);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_GameControllerRumble(this->currentController, 0xFFFF, 0xFFFF, 1500);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user