From e0a0f1dbdaf4e92c5ae9b028d85fad5772770a22 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Mon, 30 Oct 2023 02:46:39 +0100 Subject: [PATCH] early-access version 3952 --- README.md | 2 +- dist/org.yuzu_emu.yuzu.desktop | 1 + .../fragments/HomeSettingsFragment.kt | 5 ++-- .../src/main/res/layout/card_home_option.xml | 3 +- src/common/nvidia_flags.cpp | 1 + .../renderer_vulkan/vk_state_tracker.cpp | 2 +- src/yuzu/main.cpp | 30 ++++++++++++++++++- src/yuzu/main.h | 25 +++++++++++++++- 8 files changed, 62 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ef8a4e77f..542968b01 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3951. +This is the source code for early-access 3952. ## Legal Notice diff --git a/dist/org.yuzu_emu.yuzu.desktop b/dist/org.yuzu_emu.yuzu.desktop index 44cc6463b..c29fcacd2 100755 --- a/dist/org.yuzu_emu.yuzu.desktop +++ b/dist/org.yuzu_emu.yuzu.desktop @@ -13,3 +13,4 @@ Exec=yuzu %f Categories=Game;Emulator;Qt; MimeType=application/x-nx-nro;application/x-nx-nso;application/x-nx-nsp;application/x-nx-xci; Keywords=Nintendo;Switch; +StartupWMClass=yuzu diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt index fd9785075..f273c880a 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt @@ -26,7 +26,7 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.navigation.findNavController import androidx.navigation.fragment.findNavController -import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.GridLayoutManager import com.google.android.material.transition.MaterialSharedAxis import org.yuzu.yuzu_emu.BuildConfig import org.yuzu.yuzu_emu.HomeNavigationDirections @@ -186,7 +186,8 @@ class HomeSettingsFragment : Fragment() { } binding.homeSettingsList.apply { - layoutManager = LinearLayoutManager(requireContext()) + layoutManager = + GridLayoutManager(requireContext(), resources.getInteger(R.integer.grid_columns)) adapter = HomeSettingAdapter( requireActivity() as AppCompatActivity, viewLifecycleOwner, diff --git a/src/android/app/src/main/res/layout/card_home_option.xml b/src/android/app/src/main/res/layout/card_home_option.xml index f9f1d89fb..6e8a232f9 100755 --- a/src/android/app/src/main/res/layout/card_home_option.xml +++ b/src/android/app/src/main/res/layout/card_home_option.xml @@ -16,7 +16,8 @@ + android:layout_height="wrap_content" + android:layout_gravity="center_vertical"> layout()->addWidget(volume_slider); - volume_button = new QPushButton(); + volume_button = new VolumeButton(); volume_button->setObjectName(QStringLiteral("TogglableStatusBarButton")); volume_button->setFocusPolicy(Qt::NoFocus); volume_button->setCheckable(true); @@ -1103,6 +1103,8 @@ void GMainWindow::InitializeWidgets() { context_menu.exec(volume_button->mapToGlobal(menu_location)); volume_button->repaint(); }); + connect(volume_button, &VolumeButton::VolumeChanged, this, &GMainWindow::UpdateVolumeUI); + statusBar()->insertPermanentWidget(0, volume_button); // setup AA button @@ -5126,6 +5128,32 @@ void GMainWindow::changeEvent(QEvent* event) { QWidget::changeEvent(event); } +void VolumeButton::wheelEvent(QWheelEvent* event) { + + int num_degrees = event->angleDelta().y() / 8; + int num_steps = (num_degrees / 15) * scroll_multiplier; + // Stated in QT docs: Most mouse types work in steps of 15 degrees, in which case the delta + // value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees. + + if (num_steps > 0) { + Settings::values.volume.SetValue( + std::min(200, Settings::values.volume.GetValue() + num_steps)); + } else { + Settings::values.volume.SetValue( + std::max(0, Settings::values.volume.GetValue() + num_steps)); + } + + scroll_multiplier = std::min(MaxMultiplier, scroll_multiplier * 2); + scroll_timer.start(100); // reset the multiplier if no scroll event occurs within 100 ms + + emit VolumeChanged(); + event->accept(); +} + +void VolumeButton::ResetMultiplier() { + scroll_multiplier = 1; +} + #ifdef main #undef main #endif diff --git a/src/yuzu/main.h b/src/yuzu/main.h index b7c6bd97e..acc2b1160 100755 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -137,6 +138,28 @@ namespace VkDeviceInfo { class Record; } +class VolumeButton : public QPushButton { + Q_OBJECT +public: + explicit VolumeButton(QWidget* parent = nullptr) : QPushButton(parent), scroll_multiplier(1) { + connect(&scroll_timer, &QTimer::timeout, this, &VolumeButton::ResetMultiplier); + } + +signals: + void VolumeChanged(); + +protected: + void wheelEvent(QWheelEvent* event) override; + +private slots: + void ResetMultiplier(); + +private: + int scroll_multiplier; + QTimer scroll_timer; + constexpr static int MaxMultiplier = 8; +}; + class GMainWindow : public QMainWindow { Q_OBJECT @@ -481,7 +504,7 @@ private: QPushButton* dock_status_button = nullptr; QPushButton* filter_status_button = nullptr; QPushButton* aa_status_button = nullptr; - QPushButton* volume_button = nullptr; + VolumeButton* volume_button = nullptr; QWidget* volume_popup = nullptr; QSlider* volume_slider = nullptr; QTimer status_bar_update_timer;