summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Narr the Reg2022-02-02 12:22:22 -0600
committerGravatar Narr the Reg2022-02-02 13:18:06 -0600
commit064aa3de117085ec20bef57ef1d4be76a29a7a57 (patch)
tree9267efe679785b016c7f8df296f68b48c35fb90d
parentMerge pull request #7833 from lioncash/file-sys (diff)
downloadyuzu-064aa3de117085ec20bef57ef1d4be76a29a7a57.tar.gz
yuzu-064aa3de117085ec20bef57ef1d4be76a29a7a57.tar.xz
yuzu-064aa3de117085ec20bef57ef1d4be76a29a7a57.zip
yuzu: ui: Improve battery symbols
-rw-r--r--src/core/hid/input_converter.cpp2
-rw-r--r--src/input_common/drivers/sdl_driver.cpp5
-rw-r--r--src/yuzu/configuration/configure_input_player_widget.cpp89
-rw-r--r--src/yuzu/configuration/configure_input_player_widget.h2
4 files changed, 59 insertions, 39 deletions
diff --git a/src/core/hid/input_converter.cpp b/src/core/hid/input_converter.cpp
index 860aab400..cd41607a7 100644
--- a/src/core/hid/input_converter.cpp
+++ b/src/core/hid/input_converter.cpp
@@ -28,7 +28,7 @@ Common::Input::BatteryStatus TransformToBattery(const Common::Input::CallbackSta
28 if (value > 0.8f) { 28 if (value > 0.8f) {
29 battery = Common::Input::BatteryLevel::Full; 29 battery = Common::Input::BatteryLevel::Full;
30 } 30 }
31 if (value >= 1.0f) { 31 if (value >= 0.95f) {
32 battery = Common::Input::BatteryLevel::Charging; 32 battery = Common::Input::BatteryLevel::Charging;
33 } 33 }
34 break; 34 break;
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index 577bf5c31..b031a8523 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -181,11 +181,10 @@ public:
181 case SDL_JOYSTICK_POWER_EMPTY: 181 case SDL_JOYSTICK_POWER_EMPTY:
182 return BatteryLevel::Empty; 182 return BatteryLevel::Empty;
183 case SDL_JOYSTICK_POWER_LOW: 183 case SDL_JOYSTICK_POWER_LOW:
184 return BatteryLevel::Critical;
185 case SDL_JOYSTICK_POWER_MEDIUM:
186 return BatteryLevel::Low; 184 return BatteryLevel::Low;
187 case SDL_JOYSTICK_POWER_FULL: 185 case SDL_JOYSTICK_POWER_MEDIUM:
188 return BatteryLevel::Medium; 186 return BatteryLevel::Medium;
187 case SDL_JOYSTICK_POWER_FULL:
189 case SDL_JOYSTICK_POWER_MAX: 188 case SDL_JOYSTICK_POWER_MAX:
190 return BatteryLevel::Full; 189 return BatteryLevel::Full;
191 case SDL_JOYSTICK_POWER_UNKNOWN: 190 case SDL_JOYSTICK_POWER_UNKNOWN:
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 6630321cb..fb168b2ca 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -70,7 +70,6 @@ void PlayerControlPreview::UpdateColors() {
70 colors.slider_arrow = QColor(14, 15, 18); 70 colors.slider_arrow = QColor(14, 15, 18);
71 colors.font2 = QColor(255, 255, 255); 71 colors.font2 = QColor(255, 255, 255);
72 colors.indicator = QColor(170, 238, 255); 72 colors.indicator = QColor(170, 238, 255);
73 colors.indicator2 = QColor(100, 255, 100);
74 colors.deadzone = QColor(204, 136, 136); 73 colors.deadzone = QColor(204, 136, 136);
75 colors.slider_button = colors.button; 74 colors.slider_button = colors.button;
76 } 75 }
@@ -88,7 +87,6 @@ void PlayerControlPreview::UpdateColors() {
88 colors.slider_arrow = QColor(65, 68, 73); 87 colors.slider_arrow = QColor(65, 68, 73);
89 colors.font2 = QColor(0, 0, 0); 88 colors.font2 = QColor(0, 0, 0);
90 colors.indicator = QColor(0, 0, 200); 89 colors.indicator = QColor(0, 0, 200);
91 colors.indicator2 = QColor(0, 150, 0);
92 colors.deadzone = QColor(170, 0, 0); 90 colors.deadzone = QColor(170, 0, 0);
93 colors.slider_button = QColor(153, 149, 149); 91 colors.slider_button = QColor(153, 149, 149);
94 } 92 }
@@ -101,6 +99,8 @@ void PlayerControlPreview::UpdateColors() {
101 colors.font = QColor(255, 255, 255); 99 colors.font = QColor(255, 255, 255);
102 colors.led_on = QColor(255, 255, 0); 100 colors.led_on = QColor(255, 255, 0);
103 colors.led_off = QColor(170, 238, 255); 101 colors.led_off = QColor(170, 238, 255);
102 colors.indicator2 = QColor(59, 165, 93);
103 colors.charging = QColor(250, 168, 26);
104 104
105 colors.left = colors.primary; 105 colors.left = colors.primary;
106 colors.right = colors.primary; 106 colors.right = colors.primary;
@@ -357,7 +357,7 @@ void PlayerControlPreview::DrawLeftController(QPainter& p, const QPointF center)
357 DrawCircle(p, center + QPoint(26, 71), 5); 357 DrawCircle(p, center + QPoint(26, 71), 5);
358 358
359 // Draw battery 359 // Draw battery
360 DrawBattery(p, center + QPoint(-170, -140), 360 DrawBattery(p, center + QPoint(-160, -140),
361 battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); 361 battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]);
362} 362}
363 363
@@ -484,7 +484,7 @@ void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center
484 DrawSymbol(p, center + QPoint(-26, 66), Symbol::House, 5); 484 DrawSymbol(p, center + QPoint(-26, 66), Symbol::House, 5);
485 485
486 // Draw battery 486 // Draw battery
487 DrawBattery(p, center + QPoint(110, -140), 487 DrawBattery(p, center + QPoint(120, -140),
488 battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]); 488 battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]);
489} 489}
490 490
@@ -621,9 +621,9 @@ void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center)
621 DrawSymbol(p, center + QPoint(50, 60), Symbol::House, 4.2f); 621 DrawSymbol(p, center + QPoint(50, 60), Symbol::House, 4.2f);
622 622
623 // Draw battery 623 // Draw battery
624 DrawBattery(p, center + QPoint(-100, -160), 624 DrawBattery(p, center + QPoint(-200, -10),
625 battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); 625 battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]);
626 DrawBattery(p, center + QPoint(40, -160), 626 DrawBattery(p, center + QPoint(160, -10),
627 battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]); 627 battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]);
628} 628}
629 629
@@ -694,12 +694,12 @@ void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF cen
694 694
695 // ZL and ZR buttons 695 // ZL and ZR buttons
696 p.setPen(colors.outline); 696 p.setPen(colors.outline);
697 DrawTriggerButton(p, center + QPoint(-210, -130), Direction::Left, button_values[ZL]); 697 DrawTriggerButton(p, center + QPoint(-210, -120), Direction::Left, button_values[ZL]);
698 DrawTriggerButton(p, center + QPoint(210, -130), Direction::Right, button_values[ZR]); 698 DrawTriggerButton(p, center + QPoint(210, -120), Direction::Right, button_values[ZR]);
699 p.setPen(colors.transparent); 699 p.setPen(colors.transparent);
700 p.setBrush(colors.font); 700 p.setBrush(colors.font);
701 DrawSymbol(p, center + QPoint(-210, -130), Symbol::ZL, 1.5f); 701 DrawSymbol(p, center + QPoint(-210, -120), Symbol::ZL, 1.5f);
702 DrawSymbol(p, center + QPoint(210, -130), Symbol::ZR, 1.5f); 702 DrawSymbol(p, center + QPoint(210, -120), Symbol::ZR, 1.5f);
703 703
704 // Minus and Plus button 704 // Minus and Plus button
705 p.setPen(colors.outline); 705 p.setPen(colors.outline);
@@ -725,9 +725,9 @@ void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF cen
725 DrawSymbol(p, center + QPoint(161, 37), Symbol::House, 2.75f); 725 DrawSymbol(p, center + QPoint(161, 37), Symbol::House, 2.75f);
726 726
727 // Draw battery 727 // Draw battery
728 DrawBattery(p, center + QPoint(-200, 110), 728 DrawBattery(p, center + QPoint(-188, 95),
729 battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); 729 battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]);
730 DrawBattery(p, center + QPoint(130, 110), 730 DrawBattery(p, center + QPoint(150, 95),
731 battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]); 731 battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]);
732} 732}
733 733
@@ -781,12 +781,12 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center)
781 781
782 // ZL and ZR buttons 782 // ZL and ZR buttons
783 p.setPen(colors.outline); 783 p.setPen(colors.outline);
784 DrawTriggerButton(p, center + QPoint(-210, -130), Direction::Left, button_values[ZL]); 784 DrawTriggerButton(p, center + QPoint(-210, -120), Direction::Left, button_values[ZL]);
785 DrawTriggerButton(p, center + QPoint(210, -130), Direction::Right, button_values[ZR]); 785 DrawTriggerButton(p, center + QPoint(210, -120), Direction::Right, button_values[ZR]);
786 p.setPen(colors.transparent); 786 p.setPen(colors.transparent);
787 p.setBrush(colors.font); 787 p.setBrush(colors.font);
788 DrawSymbol(p, center + QPoint(-210, -130), Symbol::ZL, 1.5f); 788 DrawSymbol(p, center + QPoint(-210, -120), Symbol::ZL, 1.5f);
789 DrawSymbol(p, center + QPoint(210, -130), Symbol::ZR, 1.5f); 789 DrawSymbol(p, center + QPoint(210, -120), Symbol::ZR, 1.5f);
790 790
791 // Minus and Plus buttons 791 // Minus and Plus buttons
792 p.setPen(colors.outline); 792 p.setPen(colors.outline);
@@ -818,7 +818,7 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center)
818 DrawSymbol(p, center + QPoint(29, -56), Symbol::House, 3.9f); 818 DrawSymbol(p, center + QPoint(29, -56), Symbol::House, 3.9f);
819 819
820 // Draw battery 820 // Draw battery
821 DrawBattery(p, center + QPoint(-30, -160), 821 DrawBattery(p, center + QPoint(-20, -160),
822 battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); 822 battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]);
823} 823}
824 824
@@ -875,7 +875,7 @@ void PlayerControlPreview::DrawGCController(QPainter& p, const QPointF center) {
875 DrawCircleButton(p, center + QPoint(0, -44), button_values[Plus], 8); 875 DrawCircleButton(p, center + QPoint(0, -44), button_values[Plus], 8);
876 876
877 // Draw battery 877 // Draw battery
878 DrawBattery(p, center + QPoint(-30, -165), 878 DrawBattery(p, center + QPoint(-20, 110),
879 battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); 879 battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]);
880} 880}
881 881
@@ -1030,6 +1030,10 @@ constexpr std::array<float, 30 * 2> symbol_c = {
1030 -2.37f, 5.64f, -0.65f, 6.44f, 1.25f, 6.47f, 3.06f, 5.89f, 4.63f, 4.92f, 4.63f, 6.83f, 1030 -2.37f, 5.64f, -0.65f, 6.44f, 1.25f, 6.47f, 3.06f, 5.89f, 4.63f, 4.92f, 4.63f, 6.83f,
1031}; 1031};
1032 1032
1033constexpr std::array<float, 6 * 2> symbol_charging = {
1034 6.5f, -1.0f, 1.0f, -1.0f, 1.0f, -3.0f, -6.5f, 1.0f, -1.0f, 1.0f, -1.0f, 3.0f,
1035};
1036
1033constexpr std::array<float, 12 * 2> house = { 1037constexpr std::array<float, 12 * 2> house = {
1034 -1.3f, 0.0f, -0.93f, 0.0f, -0.93f, 1.15f, 0.93f, 1.15f, 0.93f, 0.0f, 1.3f, 0.0f, 1038 -1.3f, 0.0f, -0.93f, 0.0f, -0.93f, 1.15f, 0.93f, 1.15f, 0.93f, 0.0f, 1.3f, 0.0f,
1035 0.0f, -1.2f, -1.3f, 0.0f, -0.43f, 0.0f, -0.43f, .73f, 0.43f, .73f, 0.43f, 0.0f, 1039 0.0f, -1.2f, -1.3f, 0.0f, -0.43f, 0.0f, -0.43f, .73f, 0.43f, .73f, 0.43f, 0.0f,
@@ -2674,36 +2678,43 @@ void PlayerControlPreview::DrawBattery(QPainter& p, QPointF center,
2674 if (battery == Common::Input::BatteryLevel::None) { 2678 if (battery == Common::Input::BatteryLevel::None) {
2675 return; 2679 return;
2676 } 2680 }
2677 p.setPen(colors.outline); 2681 // Draw outline
2682 p.setPen(QPen(colors.button, 5));
2683 p.setBrush(colors.transparent);
2684 p.drawRoundedRect(center.x(), center.y(), 34, 16, 2, 2);
2685
2686 p.setPen(QPen(colors.button, 3));
2687 p.drawRect(center.x() + 35, center.y() + 4.5f, 4, 7);
2688
2689 // Draw Battery shape
2690 p.setPen(QPen(colors.indicator2, 3));
2678 p.setBrush(colors.transparent); 2691 p.setBrush(colors.transparent);
2679 p.drawRect(center.x(), center.y(), 56, 20); 2692 p.drawRoundedRect(center.x(), center.y(), 34, 16, 2, 2);
2680 p.drawRect(center.x() + 56, center.y() + 6, 3, 8); 2693
2681 p.setBrush(colors.deadzone); 2694 p.setPen(QPen(colors.indicator2, 1));
2695 p.setBrush(colors.indicator2);
2696 p.drawRect(center.x() + 35, center.y() + 4.5f, 4, 7);
2682 switch (battery) { 2697 switch (battery) {
2683 case Common::Input::BatteryLevel::Charging: 2698 case Common::Input::BatteryLevel::Charging:
2684 p.setBrush(colors.indicator2); 2699 p.drawRect(center.x(), center.y(), 34, 16);
2685 p.drawText(center + QPoint(2, 14), tr("Charging")); 2700 p.setPen(colors.slider);
2701 p.setBrush(colors.charging);
2702 DrawSymbol(p, center + QPointF(17.0f, 8.0f), Symbol::Charging, 2.1f);
2686 break; 2703 break;
2687 case Common::Input::BatteryLevel::Full: 2704 case Common::Input::BatteryLevel::Full:
2688 p.drawRect(center.x() + 42, center.y(), 14, 20); 2705 p.drawRect(center.x(), center.y(), 34, 16);
2689 p.drawRect(center.x() + 28, center.y(), 14, 20);
2690 p.drawRect(center.x() + 14, center.y(), 14, 20);
2691 p.drawRect(center.x(), center.y(), 14, 20);
2692 break; 2706 break;
2693 case Common::Input::BatteryLevel::Medium: 2707 case Common::Input::BatteryLevel::Medium:
2694 p.drawRect(center.x() + 28, center.y(), 14, 20); 2708 p.drawRect(center.x(), center.y(), 25, 16);
2695 p.drawRect(center.x() + 14, center.y(), 14, 20);
2696 p.drawRect(center.x(), center.y(), 14, 20);
2697 break; 2709 break;
2698 case Common::Input::BatteryLevel::Low: 2710 case Common::Input::BatteryLevel::Low:
2699 p.drawRect(center.x() + 14, center.y(), 14, 20); 2711 p.drawRect(center.x(), center.y(), 17, 16);
2700 p.drawRect(center.x(), center.y(), 14, 20);
2701 break; 2712 break;
2702 case Common::Input::BatteryLevel::Critical: 2713 case Common::Input::BatteryLevel::Critical:
2703 p.drawRect(center.x(), center.y(), 14, 20); 2714 p.drawRect(center.x(), center.y(), 6, 16);
2704 break; 2715 break;
2705 case Common::Input::BatteryLevel::Empty: 2716 case Common::Input::BatteryLevel::Empty:
2706 p.drawRect(center.x(), center.y(), 5, 20); 2717 p.drawRect(center.x(), center.y(), 3, 16);
2707 break; 2718 break;
2708 default: 2719 default:
2709 break; 2720 break;
@@ -2724,6 +2735,7 @@ void PlayerControlPreview::DrawSymbol(QPainter& p, const QPointF center, Symbol
2724 std::array<QPointF, symbol_sl.size() / 2> sl_icon; 2735 std::array<QPointF, symbol_sl.size() / 2> sl_icon;
2725 std::array<QPointF, symbol_zr.size() / 2> zr_icon; 2736 std::array<QPointF, symbol_zr.size() / 2> zr_icon;
2726 std::array<QPointF, symbol_sr.size() / 2> sr_icon; 2737 std::array<QPointF, symbol_sr.size() / 2> sr_icon;
2738 std::array<QPointF, symbol_charging.size() / 2> charging_icon;
2727 switch (symbol) { 2739 switch (symbol) {
2728 case Symbol::House: 2740 case Symbol::House:
2729 for (std::size_t point = 0; point < house.size() / 2; ++point) { 2741 for (std::size_t point = 0; point < house.size() / 2; ++point) {
@@ -2809,6 +2821,13 @@ void PlayerControlPreview::DrawSymbol(QPainter& p, const QPointF center, Symbol
2809 } 2821 }
2810 p.drawPolygon(sr_icon.data(), static_cast<int>(sr_icon.size())); 2822 p.drawPolygon(sr_icon.data(), static_cast<int>(sr_icon.size()));
2811 break; 2823 break;
2824 case Symbol::Charging:
2825 for (std::size_t point = 0; point < symbol_charging.size() / 2; ++point) {
2826 charging_icon[point] = center + QPointF(symbol_charging[point * 2] * icon_size,
2827 symbol_charging[point * 2 + 1] * icon_size);
2828 }
2829 p.drawPolygon(charging_icon.data(), static_cast<int>(charging_icon.size()));
2830 break;
2812 } 2831 }
2813} 2832}
2814 2833
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h
index 4cd5c3be0..3582ef77a 100644
--- a/src/yuzu/configuration/configure_input_player_widget.h
+++ b/src/yuzu/configuration/configure_input_player_widget.h
@@ -72,6 +72,7 @@ private:
72 ZL, 72 ZL,
73 ZR, 73 ZR,
74 SR, 74 SR,
75 Charging,
75 }; 76 };
76 77
77 struct ColorMapping { 78 struct ColorMapping {
@@ -94,6 +95,7 @@ private:
94 QColor slider_button{}; 95 QColor slider_button{};
95 QColor slider_arrow{}; 96 QColor slider_arrow{};
96 QColor deadzone{}; 97 QColor deadzone{};
98 QColor charging{};
97 }; 99 };
98 100
99 void UpdateColors(); 101 void UpdateColors();