mirror of
https://github.com/yuzu-emu/yuzu-mainline.git
synced 2024-12-12 20:44:24 +01:00
yuzu: Update frontend
This commit is contained in:
parent
967cca10ff
commit
c405a19b73
@ -11,7 +11,6 @@
|
|||||||
#include "core/hle/service/acc/profile_manager.h"
|
#include "core/hle/service/acc/profile_manager.h"
|
||||||
#include "core/hle/service/hid/controllers/npad.h"
|
#include "core/hle/service/hid/controllers/npad.h"
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
#include "input_common/udp/client.h"
|
|
||||||
#include "yuzu/configuration/config.h"
|
#include "yuzu/configuration/config.h"
|
||||||
|
|
||||||
namespace FS = Common::FS;
|
namespace FS = Common::FS;
|
||||||
|
@ -73,7 +73,7 @@ ConfigureInput::ConfigureInput(Core::System& system_, QWidget* parent)
|
|||||||
|
|
||||||
ConfigureInput::~ConfigureInput() = default;
|
ConfigureInput::~ConfigureInput() = default;
|
||||||
|
|
||||||
void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem,
|
void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, Core::System& system,
|
||||||
std::size_t max_players) {
|
std::size_t max_players) {
|
||||||
player_controllers = {
|
player_controllers = {
|
||||||
new ConfigureInputPlayer(this, 0, ui->consoleInputSettings, input_subsystem, profiles.get(),
|
new ConfigureInputPlayer(this, 0, ui->consoleInputSettings, input_subsystem, profiles.get(),
|
||||||
@ -184,22 +184,8 @@ QList<QWidget*> ConfigureInput::GetSubTabs() const {
|
|||||||
void ConfigureInput::ApplyConfiguration() {
|
void ConfigureInput::ApplyConfiguration() {
|
||||||
for (auto* controller : player_controllers) {
|
for (auto* controller : player_controllers) {
|
||||||
controller->ApplyConfiguration();
|
controller->ApplyConfiguration();
|
||||||
controller->TryDisconnectSelectedController();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This emulates a delay between disconnecting and reconnecting controllers as some games
|
|
||||||
// do not respond to a change in controller type if it was instantaneous.
|
|
||||||
using namespace std::chrono_literals;
|
|
||||||
std::this_thread::sleep_for(150ms);
|
|
||||||
|
|
||||||
for (auto* controller : player_controllers) {
|
|
||||||
controller->TryConnectSelectedController();
|
|
||||||
}
|
|
||||||
|
|
||||||
// This emulates a delay between disconnecting and reconnecting controllers as some games
|
|
||||||
// do not respond to a change in controller type if it was instantaneous.
|
|
||||||
std::this_thread::sleep_for(150ms);
|
|
||||||
|
|
||||||
advanced->ApplyConfiguration();
|
advanced->ApplyConfiguration();
|
||||||
|
|
||||||
const bool pre_docked_mode = Settings::values.use_docked_mode.GetValue();
|
const bool pre_docked_mode = Settings::values.use_docked_mode.GetValue();
|
||||||
|
@ -42,7 +42,8 @@ public:
|
|||||||
~ConfigureInput() override;
|
~ConfigureInput() override;
|
||||||
|
|
||||||
/// Initializes the input dialog with the given input subsystem.
|
/// Initializes the input dialog with the given input subsystem.
|
||||||
void Initialize(InputCommon::InputSubsystem* input_subsystem_, std::size_t max_players = 8);
|
void Initialize(InputCommon::InputSubsystem* input_subsystem_, Core::System& system,
|
||||||
|
std::size_t max_players = 8);
|
||||||
|
|
||||||
/// Save all button configurations to settings file.
|
/// Save all button configurations to settings file.
|
||||||
void ApplyConfiguration();
|
void ApplyConfiguration();
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -38,14 +38,22 @@ class InputSubsystem;
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace InputCommon::Polling {
|
namespace InputCommon::Polling {
|
||||||
class DevicePoller;
|
enum class InputType;
|
||||||
enum class DeviceType;
|
|
||||||
} // namespace InputCommon::Polling
|
} // namespace InputCommon::Polling
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ConfigureInputPlayer;
|
class ConfigureInputPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Core::HID {
|
||||||
|
class EmulatedController;
|
||||||
|
enum class NpadType : u8;
|
||||||
|
} // namespace Core::HID
|
||||||
|
|
||||||
class ConfigureInputPlayer : public QWidget {
|
class ConfigureInputPlayer : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -59,18 +67,6 @@ public:
|
|||||||
/// Save all button configurations to settings file.
|
/// Save all button configurations to settings file.
|
||||||
void ApplyConfiguration();
|
void ApplyConfiguration();
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to connect the currently selected controller in the HID backend.
|
|
||||||
* This function will not do anything if it is not connected in the frontend.
|
|
||||||
*/
|
|
||||||
void TryConnectSelectedController();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to disconnect the currently selected controller in the HID backend.
|
|
||||||
* This function will not do anything if the configuration has not changed.
|
|
||||||
*/
|
|
||||||
void TryDisconnectSelectedController();
|
|
||||||
|
|
||||||
/// Set the connection state checkbox (used to sync state).
|
/// Set the connection state checkbox (used to sync state).
|
||||||
void ConnectPlayer(bool connected);
|
void ConnectPlayer(bool connected);
|
||||||
|
|
||||||
@ -104,6 +100,10 @@ protected:
|
|||||||
void showEvent(QShowEvent* event) override;
|
void showEvent(QShowEvent* event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString ButtonToText(const Common::ParamPackage& param);
|
||||||
|
|
||||||
|
QString AnalogToText(const Common::ParamPackage& param, const std::string& dir);
|
||||||
|
|
||||||
void changeEvent(QEvent* event) override;
|
void changeEvent(QEvent* event) override;
|
||||||
void RetranslateUI();
|
void RetranslateUI();
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ private:
|
|||||||
/// Called when the button was pressed.
|
/// Called when the button was pressed.
|
||||||
void HandleClick(QPushButton* button, std::size_t button_id,
|
void HandleClick(QPushButton* button, std::size_t button_id,
|
||||||
std::function<void(const Common::ParamPackage&)> new_input_setter,
|
std::function<void(const Common::ParamPackage&)> new_input_setter,
|
||||||
InputCommon::Polling::DeviceType type);
|
InputCommon::Polling::InputType type);
|
||||||
|
|
||||||
/// Finish polling and configure input using the input_setter.
|
/// Finish polling and configure input using the input_setter.
|
||||||
void SetPollingResult(const Common::ParamPackage& params, bool abort);
|
void SetPollingResult(const Common::ParamPackage& params, bool abort);
|
||||||
@ -134,17 +134,14 @@ private:
|
|||||||
void SetConnectableControllers();
|
void SetConnectableControllers();
|
||||||
|
|
||||||
/// Gets the Controller Type for a given controller combobox index.
|
/// Gets the Controller Type for a given controller combobox index.
|
||||||
Settings::ControllerType GetControllerTypeFromIndex(int index) const;
|
Core::HID::NpadType GetControllerTypeFromIndex(int index) const;
|
||||||
|
|
||||||
/// Gets the controller combobox index for a given Controller Type.
|
/// Gets the controller combobox index for a given Controller Type.
|
||||||
int GetIndexFromControllerType(Settings::ControllerType type) const;
|
int GetIndexFromControllerType(Core::HID::NpadType type) const;
|
||||||
|
|
||||||
/// Update the available input devices.
|
/// Update the available input devices.
|
||||||
void UpdateInputDevices();
|
void UpdateInputDevices();
|
||||||
|
|
||||||
/// Update the current controller icon.
|
|
||||||
void UpdateControllerIcon();
|
|
||||||
|
|
||||||
/// Hides and disables controller settings based on the current controller type.
|
/// Hides and disables controller settings based on the current controller type.
|
||||||
void UpdateControllerAvailableButtons();
|
void UpdateControllerAvailableButtons();
|
||||||
|
|
||||||
@ -185,7 +182,7 @@ private:
|
|||||||
std::unique_ptr<QTimer> poll_timer;
|
std::unique_ptr<QTimer> poll_timer;
|
||||||
|
|
||||||
/// Stores a pair of "Connected Controllers" combobox index and Controller Type enum.
|
/// Stores a pair of "Connected Controllers" combobox index and Controller Type enum.
|
||||||
std::vector<std::pair<int, Settings::ControllerType>> index_controller_type_pairs;
|
std::vector<std::pair<int, Core::HID::NpadType>> index_controller_type_pairs;
|
||||||
|
|
||||||
static constexpr int PLAYER_COUNT = 8;
|
static constexpr int PLAYER_COUNT = 8;
|
||||||
std::array<QCheckBox*, PLAYER_COUNT> player_connected_checkbox;
|
std::array<QCheckBox*, PLAYER_COUNT> player_connected_checkbox;
|
||||||
@ -193,9 +190,7 @@ private:
|
|||||||
/// This will be the the setting function when an input is awaiting configuration.
|
/// This will be the the setting function when an input is awaiting configuration.
|
||||||
std::optional<std::function<void(const Common::ParamPackage&)>> input_setter;
|
std::optional<std::function<void(const Common::ParamPackage&)>> input_setter;
|
||||||
|
|
||||||
std::array<Common::ParamPackage, Settings::NativeButton::NumButtons> buttons_param;
|
Core::HID::EmulatedController* emulated_controller;
|
||||||
std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs> analogs_param;
|
|
||||||
std::array<Common::ParamPackage, Settings::NativeMotion::NumMotions> motions_param;
|
|
||||||
|
|
||||||
static constexpr int ANALOG_SUB_BUTTONS_NUM = 4;
|
static constexpr int ANALOG_SUB_BUTTONS_NUM = 4;
|
||||||
|
|
||||||
@ -221,15 +216,9 @@ private:
|
|||||||
|
|
||||||
static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons;
|
static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> device_pollers;
|
|
||||||
|
|
||||||
/// A flag to indicate that the "Map Analog Stick" pop-up has been shown and accepted once.
|
/// A flag to indicate that the "Map Analog Stick" pop-up has been shown and accepted once.
|
||||||
bool map_analog_stick_accepted{};
|
bool map_analog_stick_accepted{};
|
||||||
|
|
||||||
/// A flag to indicate if keyboard keys are okay when configuring an input. If this is false,
|
|
||||||
/// keyboard events are ignored.
|
|
||||||
bool want_keyboard_mouse{};
|
|
||||||
|
|
||||||
/// List of physical devices users can map with. If a SDL backed device is selected, then you
|
/// List of physical devices users can map with. If a SDL backed device is selected, then you
|
||||||
/// can use this device to get a default mapping.
|
/// can use this device to get a default mapping.
|
||||||
std::vector<Common::ParamPackage> input_devices;
|
std::vector<Common::ParamPackage> input_devices;
|
||||||
|
@ -148,16 +148,6 @@
|
|||||||
<height>21</height>
|
<height>21</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Any</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Keyboard/Mouse</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -7,9 +7,10 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include "common/input.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "core/frontend/input.h"
|
#include "core/hid/hid_core.h"
|
||||||
#include "yuzu/debugger/controller.h"
|
#include "core/hid/hid_types.h"
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
|
||||||
@ -24,17 +25,12 @@ public:
|
|||||||
explicit PlayerControlPreview(QWidget* parent);
|
explicit PlayerControlPreview(QWidget* parent);
|
||||||
~PlayerControlPreview() override;
|
~PlayerControlPreview() override;
|
||||||
|
|
||||||
void SetPlayerInput(std::size_t index, const ButtonParam& buttons_param,
|
void SetController(Core::HID::EmulatedController* controller);
|
||||||
const AnalogParam& analogs_param);
|
|
||||||
void SetPlayerInputRaw(std::size_t index, const Settings::ButtonsRaw& buttons_,
|
|
||||||
Settings::AnalogsRaw analogs_);
|
|
||||||
void SetConnectedStatus(bool checked);
|
|
||||||
void SetControllerType(Settings::ControllerType type);
|
|
||||||
void BeginMappingButton(std::size_t button_id);
|
void BeginMappingButton(std::size_t button_id);
|
||||||
void BeginMappingAnalog(std::size_t button_id);
|
void BeginMappingAnalog(std::size_t button_id);
|
||||||
void EndMapping();
|
void EndMapping();
|
||||||
|
void ControllerUpdate(Core::HID::ControllerTriggerType type);
|
||||||
void UpdateInput();
|
void UpdateInput();
|
||||||
void SetCallBack(ControllerCallback callback_);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent* event) override;
|
void paintEvent(QPaintEvent* event) override;
|
||||||
@ -63,15 +59,6 @@ private:
|
|||||||
SR,
|
SR,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AxisValue {
|
|
||||||
QPointF value{};
|
|
||||||
QPointF raw_value{};
|
|
||||||
Input::AnalogProperties properties{};
|
|
||||||
int size{};
|
|
||||||
QPoint offset{};
|
|
||||||
bool active{};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LedPattern {
|
struct LedPattern {
|
||||||
bool position1;
|
bool position1;
|
||||||
bool position2;
|
bool position2;
|
||||||
@ -122,47 +109,66 @@ private:
|
|||||||
void DrawGCBody(QPainter& p, QPointF center);
|
void DrawGCBody(QPainter& p, QPointF center);
|
||||||
|
|
||||||
// Draw triggers functions
|
// Draw triggers functions
|
||||||
void DrawProTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed);
|
void DrawProTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed,
|
||||||
void DrawGCTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed);
|
const Input::ButtonStatus& right_pressed);
|
||||||
void DrawHandheldTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed);
|
void DrawGCTriggers(QPainter& p, QPointF center, Input::TriggerStatus left_trigger,
|
||||||
void DrawDualTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed);
|
Input::TriggerStatus right_trigger);
|
||||||
void DrawDualTriggersTopView(QPainter& p, QPointF center, bool left_pressed,
|
void DrawHandheldTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed,
|
||||||
bool right_pressed);
|
const Input::ButtonStatus& right_pressed);
|
||||||
void DrawDualZTriggersTopView(QPainter& p, QPointF center, bool left_pressed,
|
void DrawDualTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed,
|
||||||
bool right_pressed);
|
const Input::ButtonStatus& right_pressed);
|
||||||
void DrawLeftTriggers(QPainter& p, QPointF center, bool left_pressed);
|
void DrawDualTriggersTopView(QPainter& p, QPointF center,
|
||||||
void DrawLeftZTriggers(QPainter& p, QPointF center, bool left_pressed);
|
const Input::ButtonStatus& left_pressed,
|
||||||
void DrawLeftTriggersTopView(QPainter& p, QPointF center, bool left_pressed);
|
const Input::ButtonStatus& right_pressed);
|
||||||
void DrawLeftZTriggersTopView(QPainter& p, QPointF center, bool left_pressed);
|
void DrawDualZTriggersTopView(QPainter& p, QPointF center,
|
||||||
void DrawRightTriggers(QPainter& p, QPointF center, bool right_pressed);
|
const Input::ButtonStatus& left_pressed,
|
||||||
void DrawRightZTriggers(QPainter& p, QPointF center, bool right_pressed);
|
const Input::ButtonStatus& right_pressed);
|
||||||
void DrawRightTriggersTopView(QPainter& p, QPointF center, bool right_pressed);
|
void DrawLeftTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed);
|
||||||
void DrawRightZTriggersTopView(QPainter& p, QPointF center, bool right_pressed);
|
void DrawLeftZTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed);
|
||||||
|
void DrawLeftTriggersTopView(QPainter& p, QPointF center,
|
||||||
|
const Input::ButtonStatus& left_pressed);
|
||||||
|
void DrawLeftZTriggersTopView(QPainter& p, QPointF center,
|
||||||
|
const Input::ButtonStatus& left_pressed);
|
||||||
|
void DrawRightTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& right_pressed);
|
||||||
|
void DrawRightZTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& right_pressed);
|
||||||
|
void DrawRightTriggersTopView(QPainter& p, QPointF center,
|
||||||
|
const Input::ButtonStatus& right_pressed);
|
||||||
|
void DrawRightZTriggersTopView(QPainter& p, QPointF center,
|
||||||
|
const Input::ButtonStatus& right_pressed);
|
||||||
|
|
||||||
// Draw joystick functions
|
// Draw joystick functions
|
||||||
void DrawJoystick(QPainter& p, QPointF center, float size, bool pressed);
|
void DrawJoystick(QPainter& p, QPointF center, float size, const Input::ButtonStatus& pressed);
|
||||||
void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size, bool pressed);
|
void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size,
|
||||||
|
const Input::ButtonStatus& pressed);
|
||||||
void DrawRawJoystick(QPainter& p, QPointF center_left, QPointF center_right);
|
void DrawRawJoystick(QPainter& p, QPointF center_left, QPointF center_right);
|
||||||
void DrawJoystickProperties(QPainter& p, QPointF center,
|
void DrawJoystickProperties(QPainter& p, QPointF center,
|
||||||
const Input::AnalogProperties& properties);
|
const Input::AnalogProperties& properties);
|
||||||
void DrawJoystickDot(QPainter& p, QPointF center, QPointF value,
|
void DrawJoystickDot(QPainter& p, QPointF center, const Input::StickStatus& stick, bool raw);
|
||||||
const Input::AnalogProperties& properties);
|
void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar,
|
||||||
void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar, bool pressed);
|
const Input::ButtonStatus& pressed);
|
||||||
void DrawGCJoystick(QPainter& p, QPointF center, bool pressed);
|
void DrawGCJoystick(QPainter& p, QPointF center, const Input::ButtonStatus& pressed);
|
||||||
|
|
||||||
// Draw button functions
|
// Draw button functions
|
||||||
void DrawCircleButton(QPainter& p, QPointF center, bool pressed, float button_size);
|
void DrawCircleButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed,
|
||||||
void DrawRoundButton(QPainter& p, QPointF center, bool pressed, float width, float height,
|
float button_size);
|
||||||
Direction direction = Direction::None, float radius = 2);
|
void DrawRoundButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed,
|
||||||
void DrawMinusButton(QPainter& p, QPointF center, bool pressed, int button_size);
|
float width, float height, Direction direction = Direction::None,
|
||||||
void DrawPlusButton(QPainter& p, QPointF center, bool pressed, int button_size);
|
float radius = 2);
|
||||||
void DrawGCButtonX(QPainter& p, QPointF center, bool pressed);
|
void DrawMinusButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed,
|
||||||
void DrawGCButtonY(QPainter& p, QPointF center, bool pressed);
|
int button_size);
|
||||||
void DrawGCButtonZ(QPainter& p, QPointF center, bool pressed);
|
void DrawPlusButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed,
|
||||||
|
int button_size);
|
||||||
|
void DrawGCButtonX(QPainter& p, QPointF center, const Input::ButtonStatus& pressed);
|
||||||
|
void DrawGCButtonY(QPainter& p, QPointF center, const Input::ButtonStatus& pressed);
|
||||||
|
void DrawGCButtonZ(QPainter& p, QPointF center, const Input::ButtonStatus& pressed);
|
||||||
void DrawArrowButtonOutline(QPainter& p, const QPointF center, float size = 1.0f);
|
void DrawArrowButtonOutline(QPainter& p, const QPointF center, float size = 1.0f);
|
||||||
void DrawArrowButton(QPainter& p, QPointF center, Direction direction, bool pressed,
|
void DrawArrowButton(QPainter& p, QPointF center, Direction direction,
|
||||||
float size = 1.0f);
|
const Input::ButtonStatus& pressed, float size = 1.0f);
|
||||||
void DrawTriggerButton(QPainter& p, QPointF center, Direction direction, bool pressed);
|
void DrawTriggerButton(QPainter& p, QPointF center, Direction direction,
|
||||||
|
const Input::ButtonStatus& pressed);
|
||||||
|
|
||||||
|
// Draw battery functions
|
||||||
|
void DrawBattery(QPainter& p, QPointF center, Input::BatteryLevel battery);
|
||||||
|
|
||||||
// Draw icon functions
|
// Draw icon functions
|
||||||
void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size);
|
void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size);
|
||||||
@ -178,24 +184,23 @@ private:
|
|||||||
void SetTextFont(QPainter& p, float text_size,
|
void SetTextFont(QPainter& p, float text_size,
|
||||||
const QString& font_family = QStringLiteral("sans-serif"));
|
const QString& font_family = QStringLiteral("sans-serif"));
|
||||||
|
|
||||||
using ButtonArray =
|
bool is_controller_set{};
|
||||||
std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeButton::BUTTON_NS_END>;
|
bool is_connected{};
|
||||||
using StickArray =
|
bool needs_redraw{};
|
||||||
std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID>;
|
Core::HID::NpadType controller_type;
|
||||||
|
|
||||||
ControllerCallback controller_callback;
|
|
||||||
bool is_enabled{};
|
|
||||||
bool mapping_active{};
|
bool mapping_active{};
|
||||||
int blink_counter{};
|
int blink_counter{};
|
||||||
|
int callback_key;
|
||||||
QColor button_color{};
|
QColor button_color{};
|
||||||
ColorMapping colors{};
|
ColorMapping colors{};
|
||||||
std::array<QColor, 4> led_color{};
|
std::array<QColor, 4> led_color{};
|
||||||
ButtonArray buttons{};
|
|
||||||
StickArray sticks{};
|
|
||||||
std::size_t player_index{};
|
std::size_t player_index{};
|
||||||
std::size_t button_mapping_index{Settings::NativeButton::BUTTON_NS_END};
|
Core::HID::EmulatedController* controller;
|
||||||
std::size_t analog_mapping_index{Settings::NativeAnalog::NUM_STICKS_HID};
|
std::size_t button_mapping_index{Settings::NativeButton::NumButtons};
|
||||||
std::array<AxisValue, Settings::NativeAnalog::NUM_STICKS_HID> axis_values{};
|
std::size_t analog_mapping_index{Settings::NativeAnalog::NumAnalogs};
|
||||||
std::array<bool, Settings::NativeButton::NumButtons> button_values{};
|
Core::HID::ButtonValues button_values{};
|
||||||
Settings::ControllerType controller_type{Settings::ControllerType::ProController};
|
Core::HID::SticksValues stick_values{};
|
||||||
|
Core::HID::TriggerValues trigger_values{};
|
||||||
|
Core::HID::BatteryValues battery_values{};
|
||||||
};
|
};
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
|
#include "input_common/drivers/udp_client.h"
|
||||||
|
#include "input_common/helpers/udp_protocol.h"
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
#include "input_common/udp/client.h"
|
|
||||||
#include "input_common/udp/udp.h"
|
|
||||||
#include "ui_configure_motion_touch.h"
|
#include "ui_configure_motion_touch.h"
|
||||||
#include "yuzu/configuration/configure_motion_touch.h"
|
#include "yuzu/configuration/configure_motion_touch.h"
|
||||||
#include "yuzu/configuration/configure_touch_from_button.h"
|
#include "yuzu/configuration/configure_touch_from_button.h"
|
||||||
|
@ -11,8 +11,11 @@
|
|||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/param_package.h"
|
#include "common/param_package.h"
|
||||||
|
#include "input_common/drivers/keyboard.h"
|
||||||
|
#include "input_common/drivers/mouse.h"
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
#include "ui_configure_mouse_advanced.h"
|
#include "ui_configure_mouse_advanced.h"
|
||||||
|
#include "yuzu/bootmanager.h"
|
||||||
#include "yuzu/configuration/config.h"
|
#include "yuzu/configuration/config.h"
|
||||||
#include "yuzu/configuration/configure_mouse_advanced.h"
|
#include "yuzu/configuration/configure_mouse_advanced.h"
|
||||||
|
|
||||||
@ -101,7 +104,7 @@ ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent,
|
|||||||
[=, this](const Common::ParamPackage& params) {
|
[=, this](const Common::ParamPackage& params) {
|
||||||
buttons_param[button_id] = params;
|
buttons_param[button_id] = params;
|
||||||
},
|
},
|
||||||
InputCommon::Polling::DeviceType::Button);
|
InputCommon::Polling::InputType::Button);
|
||||||
});
|
});
|
||||||
connect(button, &QPushButton::customContextMenuRequested,
|
connect(button, &QPushButton::customContextMenuRequested,
|
||||||
[=, this](const QPoint& menu_location) {
|
[=, this](const QPoint& menu_location) {
|
||||||
@ -127,13 +130,10 @@ ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent,
|
|||||||
connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); });
|
connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); });
|
||||||
|
|
||||||
connect(poll_timer.get(), &QTimer::timeout, [this] {
|
connect(poll_timer.get(), &QTimer::timeout, [this] {
|
||||||
Common::ParamPackage params;
|
const auto& params = input_subsystem->GetNextInput();
|
||||||
for (auto& poller : device_pollers) {
|
if (params.Has("engine")) {
|
||||||
params = poller->GetNextInput();
|
SetPollingResult(params, false);
|
||||||
if (params.Has("engine")) {
|
return;
|
||||||
SetPollingResult(params, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -196,26 +196,13 @@ void ConfigureMouseAdvanced::UpdateButtonLabels() {
|
|||||||
|
|
||||||
void ConfigureMouseAdvanced::HandleClick(
|
void ConfigureMouseAdvanced::HandleClick(
|
||||||
QPushButton* button, std::function<void(const Common::ParamPackage&)> new_input_setter,
|
QPushButton* button, std::function<void(const Common::ParamPackage&)> new_input_setter,
|
||||||
InputCommon::Polling::DeviceType type) {
|
InputCommon::Polling::InputType type) {
|
||||||
button->setText(tr("[press key]"));
|
button->setText(tr("[press key]"));
|
||||||
button->setFocus();
|
button->setFocus();
|
||||||
|
|
||||||
// Keyboard keys or mouse buttons can only be used as button devices
|
|
||||||
want_keyboard_mouse = type == InputCommon::Polling::DeviceType::Button;
|
|
||||||
if (want_keyboard_mouse) {
|
|
||||||
const auto iter = std::find(button_map.begin(), button_map.end(), button);
|
|
||||||
ASSERT(iter != button_map.end());
|
|
||||||
const auto index = std::distance(button_map.begin(), iter);
|
|
||||||
ASSERT(index < Settings::NativeButton::NumButtons && index >= 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
input_setter = new_input_setter;
|
input_setter = new_input_setter;
|
||||||
|
|
||||||
device_pollers = input_subsystem->GetPollers(type);
|
input_subsystem->BeginMapping(type);
|
||||||
|
|
||||||
for (auto& poller : device_pollers) {
|
|
||||||
poller->Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget::grabMouse();
|
QWidget::grabMouse();
|
||||||
QWidget::grabKeyboard();
|
QWidget::grabKeyboard();
|
||||||
@ -227,9 +214,7 @@ void ConfigureMouseAdvanced::HandleClick(
|
|||||||
void ConfigureMouseAdvanced::SetPollingResult(const Common::ParamPackage& params, bool abort) {
|
void ConfigureMouseAdvanced::SetPollingResult(const Common::ParamPackage& params, bool abort) {
|
||||||
timeout_timer->stop();
|
timeout_timer->stop();
|
||||||
poll_timer->stop();
|
poll_timer->stop();
|
||||||
for (auto& poller : device_pollers) {
|
input_subsystem->StopMapping();
|
||||||
poller->Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget::releaseMouse();
|
QWidget::releaseMouse();
|
||||||
QWidget::releaseKeyboard();
|
QWidget::releaseKeyboard();
|
||||||
@ -247,15 +232,8 @@ void ConfigureMouseAdvanced::mousePressEvent(QMouseEvent* event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (want_keyboard_mouse) {
|
const auto button = GRenderWindow::QtButtonToMouseButton(event->button());
|
||||||
SetPollingResult(Common::ParamPackage{InputCommon::GenerateKeyboardParam(event->button())},
|
input_subsystem->GetMouse()->PressButton(0, 0, 0, 0, button);
|
||||||
false);
|
|
||||||
} else {
|
|
||||||
// We don't want any mouse buttons, so don't stop polling
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetPollingResult({}, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureMouseAdvanced::keyPressEvent(QKeyEvent* event) {
|
void ConfigureMouseAdvanced::keyPressEvent(QKeyEvent* event) {
|
||||||
@ -264,13 +242,6 @@ void ConfigureMouseAdvanced::keyPressEvent(QKeyEvent* event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event->key() != Qt::Key_Escape) {
|
if (event->key() != Qt::Key_Escape) {
|
||||||
if (want_keyboard_mouse) {
|
input_subsystem->GetKeyboard()->PressKey(event->key());
|
||||||
SetPollingResult(Common::ParamPackage{InputCommon::GenerateKeyboardParam(event->key())},
|
|
||||||
false);
|
|
||||||
} else {
|
|
||||||
// Escape key wasn't pressed and we don't want any keyboard keys, so don't stop polling
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
SetPollingResult({}, true);
|
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ private:
|
|||||||
/// Called when the button was pressed.
|
/// Called when the button was pressed.
|
||||||
void HandleClick(QPushButton* button,
|
void HandleClick(QPushButton* button,
|
||||||
std::function<void(const Common::ParamPackage&)> new_input_setter,
|
std::function<void(const Common::ParamPackage&)> new_input_setter,
|
||||||
InputCommon::Polling::DeviceType type);
|
InputCommon::Polling::InputType type);
|
||||||
|
|
||||||
/// Finish polling and configure input using the input_setter
|
/// Finish polling and configure input using the input_setter
|
||||||
void SetPollingResult(const Common::ParamPackage& params, bool abort);
|
void SetPollingResult(const Common::ParamPackage& params, bool abort);
|
||||||
@ -67,12 +67,6 @@ private:
|
|||||||
std::array<QPushButton*, Settings::NativeMouseButton::NumMouseButtons> button_map;
|
std::array<QPushButton*, Settings::NativeMouseButton::NumMouseButtons> button_map;
|
||||||
std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons> buttons_param;
|
std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons> buttons_param;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> device_pollers;
|
|
||||||
|
|
||||||
std::unique_ptr<QTimer> timeout_timer;
|
std::unique_ptr<QTimer> timeout_timer;
|
||||||
std::unique_ptr<QTimer> poll_timer;
|
std::unique_ptr<QTimer> poll_timer;
|
||||||
|
|
||||||
/// A flag to indicate if keyboard keys are okay when configuring an input. If this is false,
|
|
||||||
/// keyboard events are ignored.
|
|
||||||
bool want_keyboard_mouse = false;
|
|
||||||
};
|
};
|
||||||
|
@ -163,13 +163,10 @@ void ConfigureTouchFromButton::ConnectEvents() {
|
|||||||
connect(timeout_timer.get(), &QTimer::timeout, [this]() { SetPollingResult({}, true); });
|
connect(timeout_timer.get(), &QTimer::timeout, [this]() { SetPollingResult({}, true); });
|
||||||
|
|
||||||
connect(poll_timer.get(), &QTimer::timeout, [this]() {
|
connect(poll_timer.get(), &QTimer::timeout, [this]() {
|
||||||
Common::ParamPackage params;
|
const auto& params = input_subsystem->GetNextInput();
|
||||||
for (auto& poller : device_pollers) {
|
if (params.Has("engine")) {
|
||||||
params = poller->GetNextInput();
|
SetPollingResult(params, false);
|
||||||
if (params.Has("engine")) {
|
return;
|
||||||
SetPollingResult(params, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -248,11 +245,7 @@ void ConfigureTouchFromButton::GetButtonInput(const int row_index, const bool is
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
device_pollers = input_subsystem->GetPollers(InputCommon::Polling::DeviceType::Button);
|
input_subsystem->BeginMapping(InputCommon::Polling::InputType::Button);
|
||||||
|
|
||||||
for (auto& poller : device_pollers) {
|
|
||||||
poller->Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
grabKeyboard();
|
grabKeyboard();
|
||||||
grabMouse();
|
grabMouse();
|
||||||
@ -365,14 +358,14 @@ void ConfigureTouchFromButton::SetCoordinates(const int dot_id, const QPoint& po
|
|||||||
|
|
||||||
void ConfigureTouchFromButton::SetPollingResult(const Common::ParamPackage& params,
|
void ConfigureTouchFromButton::SetPollingResult(const Common::ParamPackage& params,
|
||||||
const bool cancel) {
|
const bool cancel) {
|
||||||
|
timeout_timer->stop();
|
||||||
|
poll_timer->stop();
|
||||||
|
input_subsystem->StopMapping();
|
||||||
|
|
||||||
releaseKeyboard();
|
releaseKeyboard();
|
||||||
releaseMouse();
|
releaseMouse();
|
||||||
qApp->restoreOverrideCursor();
|
qApp->restoreOverrideCursor();
|
||||||
timeout_timer->stop();
|
|
||||||
poll_timer->stop();
|
|
||||||
for (auto& poller : device_pollers) {
|
|
||||||
poller->Stop();
|
|
||||||
}
|
|
||||||
if (input_setter) {
|
if (input_setter) {
|
||||||
(*input_setter)(params, cancel);
|
(*input_setter)(params, cancel);
|
||||||
input_setter.reset();
|
input_setter.reset();
|
||||||
|
@ -24,10 +24,6 @@ namespace InputCommon {
|
|||||||
class InputSubsystem;
|
class InputSubsystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace InputCommon::Polling {
|
|
||||||
class DevicePoller;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
struct TouchFromButtonMap;
|
struct TouchFromButtonMap;
|
||||||
}
|
}
|
||||||
@ -85,7 +81,6 @@ private:
|
|||||||
|
|
||||||
std::unique_ptr<QTimer> timeout_timer;
|
std::unique_ptr<QTimer> timeout_timer;
|
||||||
std::unique_ptr<QTimer> poll_timer;
|
std::unique_ptr<QTimer> poll_timer;
|
||||||
std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> device_pollers;
|
|
||||||
std::optional<std::function<void(const Common::ParamPackage&, bool)>> input_setter;
|
std::optional<std::function<void(const Common::ParamPackage&, bool)>> input_setter;
|
||||||
|
|
||||||
static constexpr int DataRoleDot = Qt::ItemDataRole::UserRole + 2;
|
static constexpr int DataRoleDot = Qt::ItemDataRole::UserRole + 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user