2020-04-01 20:07:16 +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>
|
2020-05-04 09:41:51 +02:00
|
|
|
#include <vector>
|
2020-04-01 20:07:16 +02:00
|
|
|
#include <QDialog>
|
|
|
|
#include "core/settings.h"
|
|
|
|
|
2020-05-04 09:41:51 +02:00
|
|
|
class QItemSelection;
|
2020-04-01 20:07:16 +02:00
|
|
|
class QModelIndex;
|
|
|
|
class QStandardItemModel;
|
2020-05-04 09:41:51 +02:00
|
|
|
class QStandardItem;
|
2020-04-01 20:07:16 +02:00
|
|
|
class QTimer;
|
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
class ParamPackage;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace InputCommon {
|
|
|
|
namespace Polling {
|
|
|
|
class DevicePoller;
|
|
|
|
}
|
|
|
|
} // namespace InputCommon
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class ConfigureTouchFromButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
class ConfigureTouchFromButton : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ConfigureTouchFromButton(QWidget* parent,
|
2020-05-04 09:41:51 +02:00
|
|
|
const std::vector<Settings::TouchFromButtonMap>& touch_maps,
|
|
|
|
const int default_index = 0);
|
2020-04-01 20:07:16 +02:00
|
|
|
~ConfigureTouchFromButton() override;
|
|
|
|
|
2020-05-04 09:41:51 +02:00
|
|
|
int GetSelectedIndex() const;
|
|
|
|
std::vector<Settings::TouchFromButtonMap> GetMaps() const;
|
2020-04-01 20:07:16 +02:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void ApplyConfiguration();
|
2020-05-04 09:41:51 +02:00
|
|
|
void NewBinding(const QPoint& pos);
|
|
|
|
void SetActiveBinding(const int dot_id);
|
|
|
|
void SetCoordinates(const int dot_id, const QPoint& pos);
|
2020-04-01 20:07:16 +02:00
|
|
|
|
|
|
|
protected:
|
2020-05-04 09:41:51 +02:00
|
|
|
virtual void showEvent(QShowEvent* ev) override;
|
|
|
|
virtual void keyPressEvent(QKeyEvent* event) override;
|
2020-04-01 20:07:16 +02:00
|
|
|
|
2020-05-04 09:41:51 +02:00
|
|
|
private slots:
|
2020-04-01 20:07:16 +02:00
|
|
|
void NewMapping();
|
|
|
|
void DeleteMapping();
|
|
|
|
void RenameMapping();
|
|
|
|
void EditBinding(const QModelIndex& qi);
|
|
|
|
void DeleteBinding();
|
2020-05-04 09:41:51 +02:00
|
|
|
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(const int row_index, const bool is_new);
|
|
|
|
void SetPollingResult(const Common::ParamPackage& params, const bool cancel);
|
2020-04-01 20:07:16 +02:00
|
|
|
void SaveCurrentMapping();
|
|
|
|
|
|
|
|
std::unique_ptr<Ui::ConfigureTouchFromButton> ui;
|
|
|
|
std::unique_ptr<QStandardItemModel> binding_list_model;
|
|
|
|
std::vector<Settings::TouchFromButtonMap> touch_maps;
|
|
|
|
int selected_index;
|
|
|
|
|
|
|
|
std::unique_ptr<QTimer> timeout_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&, const bool)>> input_setter;
|
2020-05-04 09:41:51 +02:00
|
|
|
|
|
|
|
static constexpr int data_role_dot = Qt::ItemDataRole::UserRole + 2;
|
2020-04-01 20:07:16 +02:00
|
|
|
};
|