2016-07-29 18:15:49 +05:30
|
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2016-09-20 20:51:23 +05:30
|
|
|
|
#include <memory>
|
2016-07-29 18:15:49 +05:30
|
|
|
|
#include <QKeyEvent>
|
2016-09-18 06:08:01 +05:30
|
|
|
|
#include <QWidget>
|
2016-07-29 18:15:49 +05:30
|
|
|
|
#include "citra_qt/config.h"
|
|
|
|
|
#include "core/settings.h"
|
|
|
|
|
#include "ui_configure_input.h"
|
|
|
|
|
|
|
|
|
|
class QPushButton;
|
|
|
|
|
class QString;
|
|
|
|
|
class QTimer;
|
|
|
|
|
|
|
|
|
|
namespace Ui {
|
2016-09-18 06:08:01 +05:30
|
|
|
|
class ConfigureInput;
|
2016-07-29 18:15:49 +05:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ConfigureInput : public QWidget {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit ConfigureInput(QWidget* parent = nullptr);
|
|
|
|
|
|
|
|
|
|
/// Save all button configurations to settings file
|
|
|
|
|
void applyConfiguration();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::unique_ptr<Ui::ConfigureInput> ui;
|
|
|
|
|
std::map<Settings::NativeInput::Values, QPushButton*> input_mapping;
|
|
|
|
|
int key_pressed;
|
|
|
|
|
QPushButton* changing_button = nullptr; ///< button currently waiting for key press.
|
|
|
|
|
QString previous_mapping;
|
|
|
|
|
QTimer* timer;
|
|
|
|
|
|
|
|
|
|
/// Load configuration settings into button text
|
|
|
|
|
void setConfiguration();
|
|
|
|
|
|
2016-09-18 06:08:01 +05:30
|
|
|
|
/// Check all inputs for duplicate keys. Clears out any other button with the same value as this
|
|
|
|
|
/// button's new value.
|
2016-07-29 18:15:49 +05:30
|
|
|
|
void removeDuplicates(const QString& newValue);
|
|
|
|
|
|
|
|
|
|
/// Handle key press event for input tab when a button is 'waiting'.
|
|
|
|
|
void keyPressEvent(QKeyEvent* event) override;
|
|
|
|
|
|
|
|
|
|
/// Convert key ASCII value to its' letter/name
|
|
|
|
|
QString getKeyName(int key_code) const;
|
|
|
|
|
|
|
|
|
|
/// Convert letter/name of key to its ASCII value.
|
|
|
|
|
Qt::Key getKeyValue(const QString& text) const;
|
|
|
|
|
|
|
|
|
|
/// Set button text to name of key pressed.
|
|
|
|
|
void setKey();
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
/// Event handler for all button released() event.
|
|
|
|
|
void handleClick();
|
|
|
|
|
|
|
|
|
|
/// Restore all buttons to their default values.
|
|
|
|
|
void restoreDefaults();
|
|
|
|
|
};
|