RMG-Input: use c++ style casts

This commit is contained in:
Rosalie Wanders
2025-10-16 21:27:43 +02:00
parent 66f5962494
commit a38866563b
5 changed files with 18 additions and 14 deletions
@@ -25,17 +25,19 @@ bool EventFilter::eventFilter(QObject *object, QEvent *event)
{
case QEvent::Type::KeyPress:
{
if (((QKeyEvent *)event)->key() != Qt::Key_Escape)
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() != Qt::Key_Escape)
{
emit this->on_EventFilter_KeyPressed((QKeyEvent *)event);
emit this->on_EventFilter_KeyPressed(keyEvent);
return true;
}
} break;
case QEvent::Type::KeyRelease:
{
if (((QKeyEvent *)event)->key() != Qt::Key_Escape)
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() != Qt::Key_Escape)
{
emit this->on_EventFilter_KeyReleased((QKeyEvent *)event);
emit this->on_EventFilter_KeyReleased(keyEvent);
return true;
}
} break;
@@ -45,3 +47,4 @@ bool EventFilter::eventFilter(QObject *object, QEvent *event)
return QObject::eventFilter(object, event);
}
;
@@ -87,7 +87,7 @@ HotkeysDialog::HotkeysDialog(QWidget* parent, QList<HotkeySettingMapping> hotkey
for (size_t y = 0; y < givenMapping.inputTypes.size(); y++)
{
buttonMapping.button->AddInputData(
(InputType)givenMapping.inputTypes.at(y),
static_cast<InputType>(givenMapping.inputTypes.at(y)),
givenMapping.inputData.at(y),
givenMapping.extraInputData.at(y),
QString::fromStdString(givenMapping.inputText.at(y))
@@ -355,8 +355,8 @@ void MainDialog::on_EventFilter_KeyPressed(QKeyEvent *event)
SDL_KeyboardEvent keyboardEvent;
keyboardEvent.down = true;
keyboardEvent.type = SDL_EVENT_KEY_DOWN;
keyboardEvent.scancode = (SDL_Scancode)key;
keyboardEvent.key = (SDL_Keycode)key;
keyboardEvent.scancode = static_cast<SDL_Scancode>(key);
keyboardEvent.key = static_cast<SDL_Keycode>(key);
keyboardEvent.mod = mod;
SDL_Event sdlEvent;
@@ -374,8 +374,8 @@ void MainDialog::on_EventFilter_KeyReleased(QKeyEvent *event)
SDL_KeyboardEvent keyboardEvent;
keyboardEvent.down = false;
keyboardEvent.type = SDL_EVENT_KEY_UP;
keyboardEvent.scancode = (SDL_Scancode)key;
keyboardEvent.key = (SDL_Keycode)key;
keyboardEvent.scancode = static_cast<SDL_Scancode>(key);
keyboardEvent.key = static_cast<SDL_Keycode>(key);
keyboardEvent.mod = mod;
SDL_Event sdlEvent;
@@ -266,7 +266,7 @@ void ControllerWidget::disableAllChildren()
continue;
}
QWidget* widget = (QWidget*)object;
QWidget* widget = static_cast<QWidget*>(object);
if (widget->isEnabled())
{
widget->setEnabled(false);
@@ -1049,7 +1049,7 @@ void ControllerWidget::on_MainDialog_SdlEvent(SDL_Event* event)
inputType = InputType::GamepadButton;
sdlButton = event->gbutton.button;
sdlButtonPressed = (event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN);
sdlButtonName = SDL_GetGamepadStringForButton((SDL_GamepadButton)sdlButton);
sdlButtonName = SDL_GetGamepadStringForButton(static_cast<SDL_GamepadButton>(sdlButton));
}
else if ((event->type == SDL_EVENT_JOYSTICK_BUTTON_DOWN) ||
(event->type == SDL_EVENT_JOYSTICK_BUTTON_UP))
@@ -1303,7 +1303,7 @@ void ControllerWidget::on_MainDialog_SdlEvent(SDL_Event* event)
inputType = InputType::GamepadAxis;
sdlAxis = event->gaxis.axis;
sdlAxisValue = event->gaxis.value;
sdlAxisName = SDL_GetGamepadStringForAxis((SDL_GamepadAxis)sdlAxis);
sdlAxisName = SDL_GetGamepadStringForAxis(static_cast<SDL_GamepadAxis>(sdlAxis));
sdlAxisName += sdlAxisValue > 0 ? "+" : "-";
}
else
@@ -1419,7 +1419,7 @@ void ControllerWidget::on_MainDialog_SdlEvent(SDL_Event* event)
break;
}
const SDL_Scancode sdlButton = (SDL_Scancode)event->key.scancode;
const SDL_Scancode sdlButton = static_cast<SDL_Scancode>(event->key.scancode);
const bool sdlButtonPressed = (event->type == SDL_EVENT_KEY_DOWN);
// handle button widget
@@ -1718,7 +1718,7 @@ void ControllerWidget::LoadSettings(QString sectionQString, bool loadUserProfile
// add all input data
for (int i = 0; i < count; i++)
{
buttonSetting.button->AddInputData((InputType)types[i], data[i], extraData[i], QString::fromStdString(names.at(i)));
buttonSetting.button->AddInputData(static_cast<InputType>(types[i]), data[i], extraData[i], QString::fromStdString(names.at(i)));
}
}
@@ -173,6 +173,7 @@ void HotkeyButton::on_countDownTimer_triggered()
this->currentCountDownNum = 5;
this->countDownTimer->stop();
emit this->hotkeysDialog->on_HotkeyButton_TimerFinished(this);
return;
}
this->currentCountDownNum--;