1
0
Fork 0
forked from suyu/suyu

configure_input_player: Show/hide motion buttons based on the controller

This commit is contained in:
Morph 2020-09-02 12:33:37 -04:00 committed by german
parent df3cbd4758
commit 8e18b61972
3 changed files with 141 additions and 103 deletions

View file

@ -421,9 +421,11 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
UpdateControllerIcon(); UpdateControllerIcon();
UpdateControllerAvailableButtons(); UpdateControllerAvailableButtons();
UpdateMotionButtons();
connect(ui->comboControllerType, qOverload<int>(&QComboBox::currentIndexChanged), [this](int) { connect(ui->comboControllerType, qOverload<int>(&QComboBox::currentIndexChanged), [this](int) {
UpdateControllerIcon(); UpdateControllerIcon();
UpdateControllerAvailableButtons(); UpdateControllerAvailableButtons();
UpdateMotionButtons();
}); });
connect(ui->comboDevices, qOverload<int>(&QComboBox::currentIndexChanged), this, connect(ui->comboDevices, qOverload<int>(&QComboBox::currentIndexChanged), this,
@ -893,6 +895,37 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
} }
} }
void ConfigureInputPlayer::UpdateMotionButtons() {
if (debug) {
// Motion isn't used with the debug controller, hide both groupboxes.
ui->buttonMotionLeftGroup->hide();
ui->buttonMotionRightGroup->hide();
return;
}
// Show/hide the "Motion 1/2" groupboxes depending on the currently selected controller.
switch (GetControllerTypeFromIndex(ui->comboControllerType->currentIndex())) {
case Settings::ControllerType::ProController:
case Settings::ControllerType::LeftJoycon:
case Settings::ControllerType::Handheld:
// Show "Motion 1" and hide "Motion 2".
ui->buttonMotionLeftGroup->show();
ui->buttonMotionRightGroup->hide();
break;
case Settings::ControllerType::RightJoycon:
// Show "Motion 2" and hide "Motion 1".
ui->buttonMotionLeftGroup->hide();
ui->buttonMotionRightGroup->show();
break;
case Settings::ControllerType::DualJoyconDetached:
default:
// Show both "Motion 1/2".
ui->buttonMotionLeftGroup->show();
ui->buttonMotionRightGroup->show();
break;
}
}
void ConfigureInputPlayer::showEvent(QShowEvent* event) { void ConfigureInputPlayer::showEvent(QShowEvent* event) {
if (bottom_row == nullptr) { if (bottom_row == nullptr) {
return; return;

View file

@ -107,6 +107,9 @@ private:
/// Hides and disables controller settings based on the current controller type. /// Hides and disables controller settings based on the current controller type.
void UpdateControllerAvailableButtons(); void UpdateControllerAvailableButtons();
/// Shows or hides motion groupboxes based on the current controller type.
void UpdateMotionButtons();
/// Gets the default controller mapping for this device and auto configures the input to match. /// Gets the default controller mapping for this device and auto configures the input to match.
void UpdateMappingWithDefaults(); void UpdateMappingWithDefaults();

View file

@ -1983,6 +1983,9 @@
<property name="spacing"> <property name="spacing">
<number>3</number> <number>3</number>
</property> </property>
<property name="topMargin">
<number>0</number>
</property>
<item> <item>
<spacer name="horizontalSpacerMiscButtons1"> <spacer name="horizontalSpacerMiscButtons1">
<property name="orientation"> <property name="orientation">
@ -1990,12 +1993,110 @@
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>20</width>
<height>0</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QGroupBox" name="buttonMotionLeftGroup">
<property name="title">
<string>Motion 1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QVBoxLayout" name="buttonDpadLeftVerticalLayout_2">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QPushButton" name="buttonMotionLeft">
<property name="minimumSize">
<size>
<width>57</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>55</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">min-width: 55px;</string>
</property>
<property name="text">
<string>Left</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="buttonMotionRightGroup">
<property name="title">
<string>Motion 2</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QVBoxLayout" name="buttonDpadRightVerticalLayout_2">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QPushButton" name="buttonMotionRight">
<property name="minimumSize">
<size>
<width>57</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>55</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">min-width: 55px;</string>
</property>
<property name="text">
<string>Right</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacerMiscButtons4"> <spacer name="horizontalSpacerMiscButtons4">
<property name="orientation"> <property name="orientation">
@ -2003,8 +2104,8 @@
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>20</width>
<height>0</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -2264,105 +2365,6 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item alignment="Qt::AlignHCenter">
<widget class="QGroupBox" name="buttonMotionLeftGroup">
<property name="title">
<string>Motion left</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QVBoxLayout" name="buttonMotionLeftVerticalLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QPushButton" name="buttonMotionLeft">
<property name="minimumSize">
<size>
<width>57</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>55</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">min-width: 55px;</string>
</property>
<property name="text">
<string>Motion left</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QGroupBox" name="buttonMotionRightGroup">
<property name="title">
<string>Motion right</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QVBoxLayout" name="buttonMotionRightVerticalLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QPushButton" name="buttonMotionRight">
<property name="minimumSize">
<size>
<width>57</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>55</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">min-width: 55px;</string>
</property>
<property name="text">
<string>Motion right</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>