2020-07-14 19:01:36 +02:00
|
|
|
// Copyright 2020 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <memory>
|
|
|
|
#include <optional>
|
|
|
|
#include <vector>
|
|
|
|
#include <QDialog>
|
|
|
|
|
|
|
|
class QItemSelection;
|
|
|
|
class QModelIndex;
|
|
|
|
class QStandardItemModel;
|
|
|
|
class QStandardItem;
|
|
|
|
class QTimer;
|
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
class ParamPackage;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace InputCommon {
|
2020-08-30 00:07:38 +02:00
|
|
|
class InputSubsystem;
|
2020-07-14 19:01:36 +02:00
|
|
|
}
|
|
|
|
|
2020-08-29 20:56:51 +02:00
|
|
|
namespace Settings {
|
|
|
|
struct TouchFromButtonMap;
|
|
|
|
}
|
|
|
|
|
2020-08-30 00:07:38 +02:00
|
|
|
namespace Ui {
|
|
|
|
class ConfigureTouchFromButton;
|
|
|
|
}
|
|
|
|
|
2020-07-14 19:01:36 +02:00
|
|
|
class ConfigureTouchFromButton : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ConfigureTouchFromButton(QWidget* parent,
|
2022-06-14 02:06:00 +02:00
|
|
|
const std::vector<Settings::TouchFromButtonMap>& touch_maps_,
|
2020-08-29 20:56:51 +02:00
|
|
|
InputCommon::InputSubsystem* input_subsystem_,
|
2020-07-14 19:01:36 +02:00
|
|
|
int default_index = 0);
|
|
|
|
~ConfigureTouchFromButton() override;
|
|
|
|
|
|
|
|
int GetSelectedIndex() const;
|
|
|
|
std::vector<Settings::TouchFromButtonMap> GetMaps() const;
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void ApplyConfiguration();
|
|
|
|
void NewBinding(const QPoint& pos);
|
|
|
|
void SetActiveBinding(int dot_id);
|
|
|
|
void SetCoordinates(int dot_id, const QPoint& pos);
|
|
|
|
|
|
|
|
protected:
|
2020-08-29 20:56:51 +02:00
|
|
|
void showEvent(QShowEvent* ev) override;
|
|
|
|
void keyPressEvent(QKeyEvent* event) override;
|
2020-07-14 19:01:36 +02:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void NewMapping();
|
|
|
|
void DeleteMapping();
|
|
|
|
void RenameMapping();
|
|
|
|
void EditBinding(const QModelIndex& qi);
|
|
|
|
void DeleteBinding();
|
|
|
|
void OnBindingSelection(const QItemSelection& selected, const QItemSelection& deselected);
|
|
|
|
void OnBindingChanged(QStandardItem* item);
|
|
|
|
void OnBindingDeleted(const QModelIndex& parent, int first, int last);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void SetConfiguration();
|
|
|
|
void UpdateUiDisplay();
|
|
|
|
void ConnectEvents();
|
|
|
|
void GetButtonInput(int row_index, bool is_new);
|
|
|
|
void SetPollingResult(const Common::ParamPackage& params, bool cancel);
|
|
|
|
void SaveCurrentMapping();
|
|
|
|
|
|
|
|
std::unique_ptr<Ui::ConfigureTouchFromButton> ui;
|
|
|
|
std::vector<Settings::TouchFromButtonMap> touch_maps;
|
2020-08-29 20:56:51 +02:00
|
|
|
QStandardItemModel* binding_list_model;
|
|
|
|
InputCommon::InputSubsystem* input_subsystem;
|
2020-08-30 00:07:38 +02:00
|
|
|
int selected_index;
|
2020-08-29 20:56:51 +02:00
|
|
|
|
2020-07-14 19:01:36 +02:00
|
|
|
std::unique_ptr<QTimer> timeout_timer;
|
|
|
|
std::unique_ptr<QTimer> poll_timer;
|
|
|
|
std::optional<std::function<void(const Common::ParamPackage&, bool)>> input_setter;
|
|
|
|
|
|
|
|
static constexpr int DataRoleDot = Qt::ItemDataRole::UserRole + 2;
|
|
|
|
};
|