summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2021-06-04 00:40:04 -0700
committerGravatar GitHub2021-06-04 00:40:04 -0700
commitc8b3d928368b12dba3bf0f4221f7013e464540dd (patch)
tree7b1c952c994c35ba70f6df2c0764e26b7e0cc3ec /src
parentMerge pull request #6389 from german77/Analog_button_fix (diff)
parentsettings: Disable controller preview if controller is not active (diff)
downloadyuzu-c8b3d928368b12dba3bf0f4221f7013e464540dd.tar.gz
yuzu-c8b3d928368b12dba3bf0f4221f7013e464540dd.tar.xz
yuzu-c8b3d928368b12dba3bf0f4221f7013e464540dd.zip
Merge pull request #6392 from german77/controller-widget
settings: Disable controller preview if controller is not active
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/configuration/configure_input_player_widget.cpp19
-rw-r--r--src/yuzu/configuration/configure_input_player_widget.h2
-rw-r--r--src/yuzu/debugger/controller.cpp6
3 files changed, 25 insertions, 2 deletions
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 61ba91cef..f50cda2f3 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -85,6 +85,8 @@ void PlayerControlPreview::SetConnectedStatus(bool checked) {
85 led_color[1] = led_pattern.position2 ? colors.led_on : colors.led_off; 85 led_color[1] = led_pattern.position2 ? colors.led_on : colors.led_off;
86 led_color[2] = led_pattern.position3 ? colors.led_on : colors.led_off; 86 led_color[2] = led_pattern.position3 ? colors.led_on : colors.led_off;
87 led_color[3] = led_pattern.position4 ? colors.led_on : colors.led_off; 87 led_color[3] = led_pattern.position4 ? colors.led_on : colors.led_off;
88 is_enabled = checked;
89 ResetInputs();
88} 90}
89 91
90void PlayerControlPreview::SetControllerType(const Settings::ControllerType type) { 92void PlayerControlPreview::SetControllerType(const Settings::ControllerType type) {
@@ -108,6 +110,7 @@ void PlayerControlPreview::EndMapping() {
108 analog_mapping_index = Settings::NativeAnalog::NumAnalogs; 110 analog_mapping_index = Settings::NativeAnalog::NumAnalogs;
109 mapping_active = false; 111 mapping_active = false;
110 blink_counter = 0; 112 blink_counter = 0;
113 ResetInputs();
111} 114}
112 115
113void PlayerControlPreview::UpdateColors() { 116void PlayerControlPreview::UpdateColors() {
@@ -156,7 +159,23 @@ void PlayerControlPreview::UpdateColors() {
156 // colors.right = QColor(Settings::values.players.GetValue()[player_index].body_color_right); 159 // colors.right = QColor(Settings::values.players.GetValue()[player_index].body_color_right);
157} 160}
158 161
162void PlayerControlPreview::ResetInputs() {
163 for (std::size_t index = 0; index < button_values.size(); ++index) {
164 button_values[index] = false;
165 }
166
167 for (std::size_t index = 0; index < axis_values.size(); ++index) {
168 axis_values[index].properties = {0, 1, 0};
169 axis_values[index].value = {0, 0};
170 axis_values[index].raw_value = {0, 0};
171 }
172 update();
173}
174
159void PlayerControlPreview::UpdateInput() { 175void PlayerControlPreview::UpdateInput() {
176 if (!is_enabled && !mapping_active) {
177 return;
178 }
160 bool input_changed = false; 179 bool input_changed = false;
161 const auto& button_state = buttons; 180 const auto& button_state = buttons;
162 for (std::size_t index = 0; index < button_values.size(); ++index) { 181 for (std::size_t index = 0; index < button_values.size(); ++index) {
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h
index 51bb84eb6..5fc16d8af 100644
--- a/src/yuzu/configuration/configure_input_player_widget.h
+++ b/src/yuzu/configuration/configure_input_player_widget.h
@@ -100,6 +100,7 @@ private:
100 100
101 static LedPattern GetColorPattern(std::size_t index, bool player_on); 101 static LedPattern GetColorPattern(std::size_t index, bool player_on);
102 void UpdateColors(); 102 void UpdateColors();
103 void ResetInputs();
103 104
104 // Draw controller functions 105 // Draw controller functions
105 void DrawHandheldController(QPainter& p, QPointF center); 106 void DrawHandheldController(QPainter& p, QPointF center);
@@ -176,6 +177,7 @@ private:
176 using StickArray = 177 using StickArray =
177 std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID>; 178 std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID>;
178 179
180 bool is_enabled{};
179 bool mapping_active{}; 181 bool mapping_active{};
180 int blink_counter{}; 182 int blink_counter{};
181 QColor button_color{}; 183 QColor button_color{};
diff --git a/src/yuzu/debugger/controller.cpp b/src/yuzu/debugger/controller.cpp
index d85408ac6..c1fc69578 100644
--- a/src/yuzu/debugger/controller.cpp
+++ b/src/yuzu/debugger/controller.cpp
@@ -28,6 +28,7 @@ ControllerDialog::ControllerDialog(QWidget* parent) : QWidget(parent, Qt::Dialog
28 // Configure focus so that widget is focusable and the dialog automatically forwards focus to 28 // Configure focus so that widget is focusable and the dialog automatically forwards focus to
29 // it. 29 // it.
30 setFocusProxy(widget); 30 setFocusProxy(widget);
31 widget->SetConnectedStatus(false);
31 widget->setFocusPolicy(Qt::StrongFocus); 32 widget->setFocusPolicy(Qt::StrongFocus);
32 widget->setFocus(); 33 widget->setFocus();
33} 34}
@@ -36,9 +37,8 @@ void ControllerDialog::refreshConfiguration() {
36 const auto& players = Settings::values.players.GetValue(); 37 const auto& players = Settings::values.players.GetValue();
37 constexpr std::size_t player = 0; 38 constexpr std::size_t player = 0;
38 widget->SetPlayerInputRaw(player, players[player].buttons, players[player].analogs); 39 widget->SetPlayerInputRaw(player, players[player].buttons, players[player].analogs);
39 widget->SetConnectedStatus(players[player].connected);
40 widget->SetControllerType(players[player].controller_type); 40 widget->SetControllerType(players[player].controller_type);
41 widget->repaint(); 41 widget->SetConnectedStatus(players[player].connected);
42} 42}
43 43
44QAction* ControllerDialog::toggleViewAction() { 44QAction* ControllerDialog::toggleViewAction() {
@@ -56,6 +56,7 @@ void ControllerDialog::showEvent(QShowEvent* ev) {
56 if (toggle_view_action) { 56 if (toggle_view_action) {
57 toggle_view_action->setChecked(isVisible()); 57 toggle_view_action->setChecked(isVisible());
58 } 58 }
59 refreshConfiguration();
59 QWidget::showEvent(ev); 60 QWidget::showEvent(ev);
60} 61}
61 62
@@ -63,5 +64,6 @@ void ControllerDialog::hideEvent(QHideEvent* ev) {
63 if (toggle_view_action) { 64 if (toggle_view_action) {
64 toggle_view_action->setChecked(isVisible()); 65 toggle_view_action->setChecked(isVisible());
65 } 66 }
67 widget->SetConnectedStatus(false);
66 QWidget::hideEvent(ev); 68 QWidget::hideEvent(ev);
67} 69}