From 9427e27e24a7135880ee2881c3c44988e174b41a Mon Sep 17 00:00:00 2001 From: Zephyron Date: Tue, 31 Dec 2024 16:19:25 +1000 Subject: chore: update project branding to citron --- src/citron/configuration/configure_ringcon.h | 94 ++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/citron/configuration/configure_ringcon.h (limited to 'src/citron/configuration/configure_ringcon.h') diff --git a/src/citron/configuration/configure_ringcon.h b/src/citron/configuration/configure_ringcon.h new file mode 100644 index 000000000..6fd95e2b8 --- /dev/null +++ b/src/citron/configuration/configure_ringcon.h @@ -0,0 +1,94 @@ +// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include +#include + +namespace InputCommon { +class InputSubsystem; +} // namespace InputCommon + +namespace Core::HID { +class HIDCore; +class EmulatedController; +} // 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(); + + /// Sets current polling mode to ring input + void EnableRingController(); + + // Handles emulated controller events + void ControllerUpdate(Core::HID::ControllerTriggerType type); + + /// Called when the button was pressed. + void HandleClick(QPushButton* button, + std::function 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 analog_map_buttons; + + static const std::array analog_sub_buttons; + + std::unique_ptr timeout_timer; + std::unique_ptr poll_timer; + + /// This will be the the setting function when an input is awaiting configuration. + std::optional> input_setter; + + InputCommon::InputSubsystem* input_subsystem; + Core::HID::EmulatedController* emulated_controller; + + bool is_ring_enabled{}; + bool is_controller_set{}; + int callback_key; + + std::unique_ptr ui; +}; -- cgit v1.2.3