diff options
author | german77 <[email protected]> | 2022-01-08 23:23:40 -0600 |
---|---|---|
committer | Narr the Reg <[email protected]> | 2022-04-16 00:49:26 -0500 |
commit | d2f9412cf1717f884855af22793f3a1e5815c967 (patch) | |
tree | a1beab6c5d35dbfb8a58ef45f919e9d4a7d1d58d /src/yuzu/configuration/configure_ringcon.h | |
parent | b2359f1527df30e151a44221f4276e6b14ec0bca (diff) | |
download | yuzu-android-d2f9412cf1717f884855af22793f3a1e5815c967.tar.gz yuzu-android-d2f9412cf1717f884855af22793f3a1e5815c967.zip |
yuzu: Add custom ringcon configuration
Diffstat (limited to 'src/yuzu/configuration/configure_ringcon.h')
-rw-r--r-- | src/yuzu/configuration/configure_ringcon.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/yuzu/configuration/configure_ringcon.h b/src/yuzu/configuration/configure_ringcon.h new file mode 100644 index 000000000..cf9e54f09 --- /dev/null +++ b/src/yuzu/configuration/configure_ringcon.h @@ -0,0 +1,85 @@ +// Copyright 2022 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <functional> +#include <memory> +#include <QDialog> + +namespace InputCommon { +class InputSubsystem; +} // namespace InputCommon + +namespace Core::HID { +class HIDCore; +class EmulatedDevices; +} // namespace Core::HID + +namespace Ui { +class ConfigureRingController; +} // namespace Ui + +class ConfigureRingController : public QDialog { + Q_OBJECT + +public: + explicit ConfigureRingController(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_, + Core::HID::HIDCore& hid_core_); + ~ConfigureRingController() override; + + void ApplyConfiguration(); + +private: + void changeEvent(QEvent* event) override; + void RetranslateUI(); + + void UpdateUI(); + + /// Load configuration settings. + void LoadConfiguration(); + + /// Restore all buttons to their default values. + void RestoreDefaults(); + + /// Called when the button was pressed. + void HandleClick(QPushButton* button, + std::function<void(const Common::ParamPackage&)> new_input_setter, + InputCommon::Polling::InputType type); + + /// Finish polling and configure input using the input_setter. + void SetPollingResult(const Common::ParamPackage& params, bool abort); + + /// Checks whether a given input can be accepted. + bool IsInputAcceptable(const Common::ParamPackage& params) const; + + /// Handle mouse button press events. + void mousePressEvent(QMouseEvent* event) override; + + /// Handle key press events. + void keyPressEvent(QKeyEvent* event) override; + + QString ButtonToText(const Common::ParamPackage& param); + + QString AnalogToText(const Common::ParamPackage& param, const std::string& dir); + + static constexpr int ANALOG_SUB_BUTTONS_NUM = 2; + + // A group of four QPushButtons represent one analog input. The buttons each represent left, + // right, respectively. + std::array<QPushButton*, ANALOG_SUB_BUTTONS_NUM> analog_map_buttons; + + static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons; + + std::unique_ptr<QTimer> timeout_timer; + std::unique_ptr<QTimer> poll_timer; + + /// This will be the the setting function when an input is awaiting configuration. + std::optional<std::function<void(const Common::ParamPackage&)>> input_setter; + + InputCommon::InputSubsystem* input_subsystem; + Core::HID::EmulatedDevices* emulated_device; + + std::unique_ptr<Ui::ConfigureRingController> ui; +}; |