citra_qt/applets/swkbd: QtKeyboard and misc fixes
* Addressed comments and removed the applet interface * swkbd: address @lioncash's comments * core: more fixes ** Moved registered_swkbd to System ** Removed an usused virtual ** Removed functionality of DrawScreenKeyboard ** Removed src/core/settings.h change * swkbd: address @lioncash's 2nd review * swkbd: update logging macro * QtKeyboard: Make dialog modal and hide help
This commit is contained in:
parent
f23443b921
commit
5407ed8b5e
@ -7,6 +7,8 @@ add_executable(citra-qt
|
|||||||
Info.plist
|
Info.plist
|
||||||
aboutdialog.cpp
|
aboutdialog.cpp
|
||||||
aboutdialog.h
|
aboutdialog.h
|
||||||
|
applets/swkbd.cpp
|
||||||
|
applets/swkbd.h
|
||||||
bootmanager.cpp
|
bootmanager.cpp
|
||||||
bootmanager.h
|
bootmanager.h
|
||||||
camera/camera_util.cpp
|
camera/camera_util.cpp
|
||||||
|
127
src/citra_qt/applets/swkbd.cpp
Normal file
127
src/citra_qt/applets/swkbd.cpp
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
// Copyright 2018 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QString>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include "citra_qt/applets/swkbd.h"
|
||||||
|
|
||||||
|
QtKeyboardValidator::QtKeyboardValidator(QtKeyboard* keyboard_) : keyboard(keyboard_) {}
|
||||||
|
|
||||||
|
QtKeyboardValidator::State QtKeyboardValidator::validate(QString& input, int& pos) const {
|
||||||
|
if (keyboard->ValidateFilters(input.toStdString()) == Frontend::ValidationError::None) {
|
||||||
|
return State::Acceptable;
|
||||||
|
} else {
|
||||||
|
return State::Invalid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QtKeyboardDialog::QtKeyboardDialog(QWidget* parent, QtKeyboard* keyboard_)
|
||||||
|
: QDialog(parent), keyboard(keyboard_) {
|
||||||
|
using namespace Frontend;
|
||||||
|
KeyboardConfig config = keyboard->config;
|
||||||
|
layout = new QVBoxLayout;
|
||||||
|
label = new QLabel(QString::fromStdString(config.hint_text));
|
||||||
|
line_edit = new QLineEdit;
|
||||||
|
line_edit->setValidator(new QtKeyboardValidator(keyboard));
|
||||||
|
buttons = new QDialogButtonBox;
|
||||||
|
// Initialize buttons
|
||||||
|
switch (config.button_config) {
|
||||||
|
case ButtonConfig::Triple:
|
||||||
|
buttons->addButton(config.has_custom_button_text
|
||||||
|
? QString::fromStdString(config.button_text[2])
|
||||||
|
: tr(BUTTON_OKAY),
|
||||||
|
QDialogButtonBox::ButtonRole::AcceptRole);
|
||||||
|
buttons->addButton(config.has_custom_button_text
|
||||||
|
? QString::fromStdString(config.button_text[1])
|
||||||
|
: tr(BUTTON_FORGOT),
|
||||||
|
QDialogButtonBox::ButtonRole::HelpRole);
|
||||||
|
buttons->addButton(config.has_custom_button_text
|
||||||
|
? QString::fromStdString(config.button_text[0])
|
||||||
|
: tr(BUTTON_CANCEL),
|
||||||
|
QDialogButtonBox::ButtonRole::RejectRole);
|
||||||
|
break;
|
||||||
|
case ButtonConfig::Dual:
|
||||||
|
buttons->addButton(config.has_custom_button_text
|
||||||
|
? QString::fromStdString(config.button_text[1])
|
||||||
|
: tr(BUTTON_OKAY),
|
||||||
|
QDialogButtonBox::ButtonRole::AcceptRole);
|
||||||
|
buttons->addButton(config.has_custom_button_text
|
||||||
|
? QString::fromStdString(config.button_text[0])
|
||||||
|
: tr(BUTTON_CANCEL),
|
||||||
|
QDialogButtonBox::ButtonRole::RejectRole);
|
||||||
|
break;
|
||||||
|
case ButtonConfig::Single:
|
||||||
|
buttons->addButton(config.has_custom_button_text
|
||||||
|
? QString::fromStdString(config.button_text[0])
|
||||||
|
: tr(BUTTON_OKAY),
|
||||||
|
QDialogButtonBox::ButtonRole::AcceptRole);
|
||||||
|
break;
|
||||||
|
case ButtonConfig::None:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
connect(buttons, &QDialogButtonBox::accepted, this, [=] { Submit(); });
|
||||||
|
connect(buttons, &QDialogButtonBox::rejected, this, [=] {
|
||||||
|
button = QtKeyboard::cancel_id;
|
||||||
|
accept();
|
||||||
|
});
|
||||||
|
connect(buttons, &QDialogButtonBox::helpRequested, this, [=] {
|
||||||
|
button = QtKeyboard::forgot_id;
|
||||||
|
accept();
|
||||||
|
});
|
||||||
|
layout->addWidget(label);
|
||||||
|
layout->addWidget(line_edit);
|
||||||
|
layout->addWidget(buttons);
|
||||||
|
setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtKeyboardDialog::Submit() {
|
||||||
|
auto error = keyboard->ValidateInput(line_edit->text().toStdString());
|
||||||
|
if (error != Frontend::ValidationError::None) {
|
||||||
|
HandleValidationError(error);
|
||||||
|
} else {
|
||||||
|
button = keyboard->ok_id;
|
||||||
|
text = line_edit->text();
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtKeyboardDialog::HandleValidationError(Frontend::ValidationError error) {
|
||||||
|
using namespace Frontend;
|
||||||
|
const std::unordered_map<ValidationError, QString> VALIDATION_ERROR_MESSAGES = {
|
||||||
|
{ValidationError::FixedLengthRequired,
|
||||||
|
tr("Text length is not correct (should be %1 characters)")
|
||||||
|
.arg(keyboard->config.max_text_length)},
|
||||||
|
{ValidationError::MaxLengthExceeded,
|
||||||
|
tr("Text is too long (should be no more than %1 characters)")
|
||||||
|
.arg(keyboard->config.max_text_length)},
|
||||||
|
{ValidationError::BlankInputNotAllowed, tr("Blank input is not allowed")},
|
||||||
|
{ValidationError::EmptyInputNotAllowed, tr("Empty input is not allowed")},
|
||||||
|
};
|
||||||
|
QMessageBox::critical(this, tr("Validation error"), VALIDATION_ERROR_MESSAGES.at(error));
|
||||||
|
}
|
||||||
|
|
||||||
|
QtKeyboard::QtKeyboard(QWidget& parent_) : parent(parent_) {}
|
||||||
|
|
||||||
|
void QtKeyboard::Setup(const Frontend::KeyboardConfig* config) {
|
||||||
|
SoftwareKeyboard::Setup(config);
|
||||||
|
if (this->config.button_config != Frontend::ButtonConfig::None) {
|
||||||
|
ok_id = static_cast<u8>(this->config.button_config);
|
||||||
|
}
|
||||||
|
QMetaObject::invokeMethod(this, "OpenInputDialog", Qt::BlockingQueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtKeyboard::OpenInputDialog() {
|
||||||
|
QtKeyboardDialog dialog(&parent, this);
|
||||||
|
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
|
||||||
|
Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
|
||||||
|
dialog.setWindowModality(Qt::WindowModal);
|
||||||
|
dialog.exec();
|
||||||
|
LOG_INFO(Frontend, "SWKBD input dialog finished, text={}, button={}", dialog.text.toStdString(),
|
||||||
|
dialog.button);
|
||||||
|
Finalize(dialog.text.toStdString(), dialog.button);
|
||||||
|
}
|
65
src/citra_qt/applets/swkbd.h
Normal file
65
src/citra_qt/applets/swkbd.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// Copyright 2018 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QValidator>
|
||||||
|
#include "core/frontend/applets/swkbd.h"
|
||||||
|
|
||||||
|
class QDialogButtonBox;
|
||||||
|
class QLabel;
|
||||||
|
class QLineEdit;
|
||||||
|
class QVBoxLayout;
|
||||||
|
class QtKeyboard;
|
||||||
|
|
||||||
|
class QtKeyboardValidator final : public QValidator {
|
||||||
|
public:
|
||||||
|
explicit QtKeyboardValidator(QtKeyboard* keyboard);
|
||||||
|
State validate(QString& input, int& pos) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QtKeyboard* keyboard;
|
||||||
|
};
|
||||||
|
|
||||||
|
class QtKeyboardDialog final : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QtKeyboardDialog(QWidget* parent, QtKeyboard* keyboard);
|
||||||
|
void Submit();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void HandleValidationError(Frontend::ValidationError error);
|
||||||
|
QDialogButtonBox* buttons;
|
||||||
|
QLabel* label;
|
||||||
|
QLineEdit* line_edit;
|
||||||
|
QVBoxLayout* layout;
|
||||||
|
QtKeyboard* keyboard;
|
||||||
|
QString text;
|
||||||
|
u8 button;
|
||||||
|
|
||||||
|
friend class QtKeyboard;
|
||||||
|
};
|
||||||
|
|
||||||
|
class QtKeyboard final : public QObject, public Frontend::SoftwareKeyboard {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit QtKeyboard(QWidget& parent);
|
||||||
|
void Setup(const Frontend::KeyboardConfig* config) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_INVOKABLE void OpenInputDialog();
|
||||||
|
|
||||||
|
/// Index of the buttons
|
||||||
|
u8 ok_id;
|
||||||
|
static constexpr u8 forgot_id = 1;
|
||||||
|
static constexpr u8 cancel_id = 0;
|
||||||
|
|
||||||
|
QWidget& parent;
|
||||||
|
|
||||||
|
friend class QtKeyboardDialog;
|
||||||
|
friend class QtKeyboardValidator;
|
||||||
|
};
|
@ -16,6 +16,7 @@
|
|||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
#include "citra_qt/aboutdialog.h"
|
#include "citra_qt/aboutdialog.h"
|
||||||
|
#include "citra_qt/applets/swkbd.h"
|
||||||
#include "citra_qt/bootmanager.h"
|
#include "citra_qt/bootmanager.h"
|
||||||
#include "citra_qt/camera/qt_multimedia_camera.h"
|
#include "citra_qt/camera/qt_multimedia_camera.h"
|
||||||
#include "citra_qt/camera/still_image_camera.h"
|
#include "citra_qt/camera/still_image_camera.h"
|
||||||
@ -1470,6 +1471,7 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
// Register frontend applets
|
// Register frontend applets
|
||||||
Frontend::RegisterDefaultApplets();
|
Frontend::RegisterDefaultApplets();
|
||||||
|
Frontend::RegisterSoftwareKeyboard(std::make_shared<QtKeyboard>(main_window));
|
||||||
|
|
||||||
main_window.show();
|
main_window.show();
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
@ -70,8 +70,6 @@ add_library(core STATIC
|
|||||||
file_sys/title_metadata.h
|
file_sys/title_metadata.h
|
||||||
frontend/applets/default_applets.cpp
|
frontend/applets/default_applets.cpp
|
||||||
frontend/applets/default_applets.h
|
frontend/applets/default_applets.h
|
||||||
frontend/applets/interface.cpp
|
|
||||||
frontend/applets/interface.h
|
|
||||||
frontend/applets/swkbd.cpp
|
frontend/applets/swkbd.cpp
|
||||||
frontend/applets/swkbd.h
|
frontend/applets/swkbd.h
|
||||||
frontend/camera/blank_camera.cpp
|
frontend/camera/blank_camera.cpp
|
||||||
|
@ -199,6 +199,10 @@ const Service::SM::ServiceManager& System::ServiceManager() const {
|
|||||||
return *service_manager;
|
return *service_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void System::RegisterSoftwareKeyboard(std::shared_ptr<Frontend::SoftwareKeyboard> swkbd) {
|
||||||
|
registered_swkbd = std::move(swkbd);
|
||||||
|
}
|
||||||
|
|
||||||
void System::Shutdown() {
|
void System::Shutdown() {
|
||||||
// Log last frame performance stats
|
// Log last frame performance stats
|
||||||
auto perf_results = GetAndResetPerfStats();
|
auto perf_results = GetAndResetPerfStats();
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "core/frontend/applets/swkbd.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
#include "core/perf_stats.h"
|
#include "core/perf_stats.h"
|
||||||
@ -150,6 +151,14 @@ public:
|
|||||||
return *app_loader;
|
return *app_loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Frontend Applets
|
||||||
|
|
||||||
|
void RegisterSoftwareKeyboard(std::shared_ptr<Frontend::SoftwareKeyboard> swkbd);
|
||||||
|
|
||||||
|
std::shared_ptr<Frontend::SoftwareKeyboard> GetSoftwareKeyboard() const {
|
||||||
|
return registered_swkbd;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Initialize the emulated system.
|
* Initialize the emulated system.
|
||||||
@ -180,6 +189,9 @@ private:
|
|||||||
/// Service manager
|
/// Service manager
|
||||||
std::shared_ptr<Service::SM::ServiceManager> service_manager;
|
std::shared_ptr<Service::SM::ServiceManager> service_manager;
|
||||||
|
|
||||||
|
/// Frontend applets
|
||||||
|
std::shared_ptr<Frontend::SoftwareKeyboard> registered_swkbd;
|
||||||
|
|
||||||
static System s_instance;
|
static System s_instance;
|
||||||
|
|
||||||
ResultStatus status = ResultStatus::Success;
|
ResultStatus status = ResultStatus::Success;
|
||||||
|
@ -3,11 +3,10 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "core/frontend/applets/default_applets.h"
|
#include "core/frontend/applets/default_applets.h"
|
||||||
#include "core/frontend/applets/interface.h"
|
|
||||||
#include "core/frontend/applets/swkbd.h"
|
#include "core/frontend/applets/swkbd.h"
|
||||||
|
|
||||||
namespace Frontend {
|
namespace Frontend {
|
||||||
void RegisterDefaultApplets() {
|
void RegisterDefaultApplets() {
|
||||||
RegisterFrontendApplet(std::make_shared<DefaultCitraKeyboard>(), AppletType::SoftwareKeyboard);
|
RegisterSoftwareKeyboard(std::make_shared<DefaultCitraKeyboard>());
|
||||||
}
|
}
|
||||||
} // namespace Frontend
|
} // namespace Frontend
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
// Copyright 2018 Citra Emulator Project
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
#include "core/frontend/applets/interface.h"
|
|
||||||
|
|
||||||
namespace Frontend {
|
|
||||||
|
|
||||||
std::unordered_map<AppletType, std::shared_ptr<AppletInterface>> registered_applets;
|
|
||||||
|
|
||||||
void RegisterFrontendApplet(std::shared_ptr<AppletInterface> applet, AppletType type) {
|
|
||||||
registered_applets[type] = applet;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UnregisterFrontendApplet(AppletType type) {
|
|
||||||
registered_applets.erase(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<AppletInterface> GetRegisteredApplet(AppletType type) {
|
|
||||||
return registered_applets.at(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Frontend
|
|
@ -1,67 +0,0 @@
|
|||||||
// Copyright 2018 Citra Emulator Project
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace Frontend {
|
|
||||||
|
|
||||||
enum class AppletType {
|
|
||||||
SoftwareKeyboard,
|
|
||||||
};
|
|
||||||
|
|
||||||
class AppletConfig {};
|
|
||||||
class AppletData {};
|
|
||||||
|
|
||||||
// TODO(jroweboy) add ability to draw to framebuffer
|
|
||||||
class AppletInterface {
|
|
||||||
public:
|
|
||||||
virtual ~AppletInterface() = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* On applet start, the applet specific configuration will be passed in along with the
|
|
||||||
* framebuffer.
|
|
||||||
*/
|
|
||||||
virtual void Setup(const AppletConfig*) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checked every update to see if the applet is still running. When the applet is done, the core
|
|
||||||
* will call ReceiveData
|
|
||||||
*/
|
|
||||||
virtual bool IsRunning() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by the core to receive the result data of this applet.
|
|
||||||
* Frontend implementation **should** block until the data is ready.
|
|
||||||
*/
|
|
||||||
virtual const AppletData* ReceiveData() = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::atomic<bool> running = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Frontends call this method to pass a frontend applet implementation to the core. If the core
|
|
||||||
* already has a applet registered, then this replaces the old applet
|
|
||||||
*
|
|
||||||
* @param applet - Frontend Applet implementation that the HLE applet code will launch
|
|
||||||
* @param type - Which type of applet
|
|
||||||
*/
|
|
||||||
void RegisterFrontendApplet(std::shared_ptr<AppletInterface> applet, AppletType type);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Frontends call this to prevent future requests
|
|
||||||
*/
|
|
||||||
void UnregisterFrontendApplet(AppletType type);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Frontend Applet for the provided type
|
|
||||||
*/
|
|
||||||
std::shared_ptr<AppletInterface> GetRegisteredApplet(AppletType type);
|
|
||||||
|
|
||||||
} // namespace Frontend
|
|
@ -2,13 +2,16 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cctype>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "core/core.h"
|
||||||
#include "core/frontend/applets/swkbd.h"
|
#include "core/frontend/applets/swkbd.h"
|
||||||
|
|
||||||
namespace Frontend {
|
namespace Frontend {
|
||||||
|
|
||||||
ValidationError SoftwareKeyboard::ValidateFilters(const std::string& input) {
|
ValidationError SoftwareKeyboard::ValidateFilters(const std::string& input) const {
|
||||||
if (config.filters.prevent_digit) {
|
if (config.filters.prevent_digit) {
|
||||||
if (std::any_of(input.begin(), input.end(),
|
if (std::any_of(input.begin(), input.end(),
|
||||||
[](unsigned char c) { return std::isdigit(c); })) {
|
[](unsigned char c) { return std::isdigit(c); })) {
|
||||||
@ -41,7 +44,7 @@ ValidationError SoftwareKeyboard::ValidateFilters(const std::string& input) {
|
|||||||
return ValidationError::None;
|
return ValidationError::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValidationError SoftwareKeyboard::ValidateInput(const std::string& input) {
|
ValidationError SoftwareKeyboard::ValidateInput(const std::string& input) const {
|
||||||
ValidationError error;
|
ValidationError error;
|
||||||
if ((error = ValidateFilters(input)) != ValidationError::None) {
|
if ((error = ValidateFilters(input)) != ValidationError::None) {
|
||||||
return error;
|
return error;
|
||||||
@ -52,11 +55,9 @@ ValidationError SoftwareKeyboard::ValidateInput(const std::string& input) {
|
|||||||
return ValidationError::MaxLengthExceeded;
|
return ValidationError::MaxLengthExceeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto is_blank = [&] {
|
bool is_blank =
|
||||||
return std::all_of(input.begin(), input.end(),
|
std::all_of(input.begin(), input.end(), [](unsigned char c) { return std::isspace(c); });
|
||||||
[](unsigned char c) { return std::isspace(c); });
|
bool is_empty = input.empty();
|
||||||
};
|
|
||||||
auto is_empty = [&] { return input.empty(); };
|
|
||||||
switch (config.accept_mode) {
|
switch (config.accept_mode) {
|
||||||
case AcceptedInput::FixedLength:
|
case AcceptedInput::FixedLength:
|
||||||
if (input.size() != config.max_text_length) {
|
if (input.size() != config.max_text_length) {
|
||||||
@ -64,20 +65,20 @@ ValidationError SoftwareKeyboard::ValidateInput(const std::string& input) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AcceptedInput::NotEmptyAndNotBlank:
|
case AcceptedInput::NotEmptyAndNotBlank:
|
||||||
if (is_blank()) {
|
if (is_blank) {
|
||||||
return ValidationError::BlankInputNotAllowed;
|
return ValidationError::BlankInputNotAllowed;
|
||||||
}
|
}
|
||||||
if (is_empty()) {
|
if (is_empty) {
|
||||||
return ValidationError::EmptyInputNotAllowed;
|
return ValidationError::EmptyInputNotAllowed;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AcceptedInput::NotBlank:
|
case AcceptedInput::NotBlank:
|
||||||
if (is_blank()) {
|
if (is_blank) {
|
||||||
return ValidationError::BlankInputNotAllowed;
|
return ValidationError::BlankInputNotAllowed;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AcceptedInput::NotEmpty:
|
case AcceptedInput::NotEmpty:
|
||||||
if (is_empty()) {
|
if (is_empty) {
|
||||||
return ValidationError::EmptyInputNotAllowed;
|
return ValidationError::EmptyInputNotAllowed;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -85,15 +86,15 @@ ValidationError SoftwareKeyboard::ValidateInput(const std::string& input) {
|
|||||||
return ValidationError::None;
|
return ValidationError::None;
|
||||||
default:
|
default:
|
||||||
// TODO(jroweboy): What does hardware do in this case?
|
// TODO(jroweboy): What does hardware do in this case?
|
||||||
NGLOG_CRITICAL(Frontend, "Application requested unknown validation method. Method: {}",
|
LOG_CRITICAL(Frontend, "Application requested unknown validation method. Method: {}",
|
||||||
static_cast<u32>(config.accept_mode));
|
static_cast<u32>(config.accept_mode));
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ValidationError::None;
|
return ValidationError::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValidationError SoftwareKeyboard::ValidateButton(u8 button) {
|
ValidationError SoftwareKeyboard::ValidateButton(u8 button) const {
|
||||||
switch (config.button_config) {
|
switch (config.button_config) {
|
||||||
case ButtonConfig::None:
|
case ButtonConfig::None:
|
||||||
return ValidationError::None;
|
return ValidationError::None;
|
||||||
@ -127,7 +128,32 @@ ValidationError SoftwareKeyboard::Finalize(const std::string& text, u8 button) {
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
data = {text, button};
|
data = {text, button};
|
||||||
running = false;
|
}
|
||||||
|
|
||||||
|
void DefaultCitraKeyboard::Setup(const Frontend::KeyboardConfig* config) {
|
||||||
|
SoftwareKeyboard::Setup(config);
|
||||||
|
switch (this->config.button_config) {
|
||||||
|
case ButtonConfig::None:
|
||||||
|
case ButtonConfig::Single:
|
||||||
|
Finalize("Citra", 0);
|
||||||
|
break;
|
||||||
|
case ButtonConfig::Dual:
|
||||||
|
Finalize("Citra", 1);
|
||||||
|
break;
|
||||||
|
case ButtonConfig::Triple:
|
||||||
|
Finalize("Citra", 2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisterSoftwareKeyboard(std::shared_ptr<SoftwareKeyboard> applet) {
|
||||||
|
Core::System::GetInstance().RegisterSoftwareKeyboard(applet);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<SoftwareKeyboard> GetRegisteredSoftwareKeyboard() {
|
||||||
|
return Core::System::GetInstance().GetSoftwareKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Frontend
|
} // namespace Frontend
|
||||||
|
@ -4,18 +4,15 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <codecvt>
|
|
||||||
#include <locale>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "core/frontend/applets/interface.h"
|
|
||||||
|
|
||||||
namespace Frontend {
|
namespace Frontend {
|
||||||
|
|
||||||
enum class AcceptedInput {
|
enum class AcceptedInput {
|
||||||
Anything = 0, /// All inputs are accepted.
|
Anything, /// All inputs are accepted.
|
||||||
NotEmpty, /// Empty inputs are not accepted.
|
NotEmpty, /// Empty inputs are not accepted.
|
||||||
NotEmptyAndNotBlank, /// Empty or blank inputs (consisting solely of whitespace) are not
|
NotEmptyAndNotBlank, /// Empty or blank inputs (consisting solely of whitespace) are not
|
||||||
/// accepted.
|
/// accepted.
|
||||||
@ -26,25 +23,20 @@ enum class AcceptedInput {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum class ButtonConfig {
|
enum class ButtonConfig {
|
||||||
Single = 0, /// Ok button
|
Single, /// Ok button
|
||||||
Dual, /// Cancel | Ok buttons
|
Dual, /// Cancel | Ok buttons
|
||||||
Triple, /// Cancel | I Forgot | Ok buttons
|
Triple, /// Cancel | I Forgot | Ok buttons
|
||||||
None, /// No button (returned by swkbdInputText in special cases)
|
None, /// No button (returned by swkbdInputText in special cases)
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Default English button text mappings. Frontends may need to copy this to internationalize it.
|
/// Default English button text mappings. Frontends may need to copy this to internationalize it.
|
||||||
static const char* BUTTON_OKAY = "Ok";
|
constexpr char BUTTON_OKAY[] = "Ok";
|
||||||
static const char* BUTTON_CANCEL = "Cancel";
|
constexpr char BUTTON_CANCEL[] = "Cancel";
|
||||||
static const char* BUTTON_FORGOT = "I Forgot";
|
constexpr char BUTTON_FORGOT[] = "I Forgot";
|
||||||
static const std::unordered_map<ButtonConfig, std::vector<std::string>> DEFAULT_BUTTON_MAPPING = {
|
|
||||||
{ButtonConfig::Single, {BUTTON_OKAY}},
|
|
||||||
{ButtonConfig::Dual, {BUTTON_CANCEL, BUTTON_OKAY}},
|
|
||||||
{ButtonConfig::Triple, {BUTTON_CANCEL, BUTTON_FORGOT, BUTTON_OKAY}},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Configuration thats relevent to frontend implementation of applets. Anything missing that we
|
/// Configuration thats relevent to frontend implementation of applets. Anything missing that we
|
||||||
/// later learn is needed can be added here and filled in by the backend HLE applet
|
/// later learn is needed can be added here and filled in by the backend HLE applet
|
||||||
struct KeyboardConfig : public AppletConfig {
|
struct KeyboardConfig {
|
||||||
ButtonConfig button_config;
|
ButtonConfig button_config;
|
||||||
AcceptedInput accept_mode; /// What kinds of input are accepted (blank/empty/fixed width)
|
AcceptedInput accept_mode; /// What kinds of input are accepted (blank/empty/fixed width)
|
||||||
bool multiline_mode; /// True if the keyboard accepts multiple lines of input
|
bool multiline_mode; /// True if the keyboard accepts multiple lines of input
|
||||||
@ -61,16 +53,13 @@ struct KeyboardConfig : public AppletConfig {
|
|||||||
bool prevent_backslash; /// Disallow the use of the \ sign.
|
bool prevent_backslash; /// Disallow the use of the \ sign.
|
||||||
bool prevent_profanity; /// Disallow profanity using Nintendo's profanity filter.
|
bool prevent_profanity; /// Disallow profanity using Nintendo's profanity filter.
|
||||||
bool enable_callback; /// Use a callback in order to check the input.
|
bool enable_callback; /// Use a callback in order to check the input.
|
||||||
} filters;
|
};
|
||||||
|
Filters filters;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KeyboardData : public AppletData {
|
struct KeyboardData {
|
||||||
public:
|
|
||||||
std::string text;
|
std::string text;
|
||||||
u8 button{};
|
u8 button{};
|
||||||
|
|
||||||
KeyboardData(std::string text, u8 button) : text(std::move(text)), button(button) {}
|
|
||||||
KeyboardData() = default;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ValidationError {
|
enum class ValidationError {
|
||||||
@ -91,35 +80,33 @@ enum class ValidationError {
|
|||||||
EmptyInputNotAllowed,
|
EmptyInputNotAllowed,
|
||||||
};
|
};
|
||||||
|
|
||||||
class SoftwareKeyboard : public AppletInterface {
|
class SoftwareKeyboard {
|
||||||
public:
|
public:
|
||||||
explicit SoftwareKeyboard() : AppletInterface() {}
|
virtual void Setup(const KeyboardConfig* config) {
|
||||||
void Setup(const AppletConfig* config) override {
|
this->config = KeyboardConfig(*config);
|
||||||
this->config = KeyboardConfig(*static_cast<const KeyboardConfig*>(config));
|
|
||||||
}
|
}
|
||||||
const AppletData* ReceiveData() override {
|
const KeyboardData* ReceiveData() {
|
||||||
return &data;
|
return &data;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
|
||||||
/**
|
/**
|
||||||
* Validates if the provided string breaks any of the filter rules. This is meant to be called
|
* Validates if the provided string breaks any of the filter rules. This is meant to be called
|
||||||
* whenever the user input changes to check to see if the new input is valid. Frontends can
|
* whenever the user input changes to check to see if the new input is valid. Frontends can
|
||||||
* decide if they want to check the input continuously or once before submission
|
* decide if they want to check the input continuously or once before submission
|
||||||
*/
|
*/
|
||||||
ValidationError ValidateFilters(const std::string& input);
|
ValidationError ValidateFilters(const std::string& input) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates the the provided string doesn't break any extra rules like "input must not be
|
* Validates the the provided string doesn't break any extra rules like "input must not be
|
||||||
* empty". This will be called by Finalize but can be called earlier if the frontend needs
|
* empty". This will be called by Finalize but can be called earlier if the frontend needs
|
||||||
*/
|
*/
|
||||||
ValidationError ValidateInput(const std::string& input);
|
ValidationError ValidateInput(const std::string& input) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies that the selected button is valid. This should be used as the last check before
|
* Verifies that the selected button is valid. This should be used as the last check before
|
||||||
* closing.
|
* closing.
|
||||||
*/
|
*/
|
||||||
ValidationError ValidateButton(u8 button);
|
ValidationError ValidateButton(u8 button) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs all validation phases. If successful, stores the data so that the HLE applet in core can
|
* Runs all validation phases. If successful, stores the data so that the HLE applet in core can
|
||||||
@ -127,29 +114,18 @@ protected:
|
|||||||
*/
|
*/
|
||||||
ValidationError Finalize(const std::string& text, u8 button);
|
ValidationError Finalize(const std::string& text, u8 button);
|
||||||
|
|
||||||
|
protected:
|
||||||
KeyboardConfig config;
|
KeyboardConfig config;
|
||||||
KeyboardData data;
|
KeyboardData data;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DefaultCitraKeyboard final : public SoftwareKeyboard {
|
class DefaultCitraKeyboard final : public SoftwareKeyboard {
|
||||||
public:
|
public:
|
||||||
void Setup(const AppletConfig* config) override {
|
void Setup(const KeyboardConfig* config) override;
|
||||||
SoftwareKeyboard::Setup(config);
|
|
||||||
switch (this->config.button_config) {
|
|
||||||
case ButtonConfig::None:
|
|
||||||
case ButtonConfig::Single:
|
|
||||||
Finalize("Citra", 0);
|
|
||||||
break;
|
|
||||||
case ButtonConfig::Dual:
|
|
||||||
Finalize("Citra", 1);
|
|
||||||
break;
|
|
||||||
case ButtonConfig::Triple:
|
|
||||||
Finalize("Citra", 2);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void RegisterSoftwareKeyboard(std::shared_ptr<SoftwareKeyboard> applet);
|
||||||
|
|
||||||
|
std::shared_ptr<SoftwareKeyboard> GetRegisteredSoftwareKeyboard();
|
||||||
|
|
||||||
} // namespace Frontend
|
} // namespace Frontend
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
@ -70,7 +71,7 @@ ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter cons
|
|||||||
DrawScreenKeyboard();
|
DrawScreenKeyboard();
|
||||||
|
|
||||||
using namespace Frontend;
|
using namespace Frontend;
|
||||||
frontend_applet = GetRegisteredApplet(AppletType::SoftwareKeyboard);
|
frontend_applet = GetRegisteredSoftwareKeyboard();
|
||||||
if (frontend_applet) {
|
if (frontend_applet) {
|
||||||
KeyboardConfig frontend_config = ToFrontendConfig(config);
|
KeyboardConfig frontend_config = ToFrontendConfig(config);
|
||||||
frontend_applet->Setup(&frontend_config);
|
frontend_applet->Setup(&frontend_config);
|
||||||
@ -82,38 +83,38 @@ ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter cons
|
|||||||
|
|
||||||
void SoftwareKeyboard::Update() {
|
void SoftwareKeyboard::Update() {
|
||||||
using namespace Frontend;
|
using namespace Frontend;
|
||||||
KeyboardData data(*static_cast<const KeyboardData*>(frontend_applet->ReceiveData()));
|
KeyboardData data(*frontend_applet->ReceiveData());
|
||||||
std::u16string text = Common::UTF8ToUTF16(data.text);
|
std::u16string text = Common::UTF8ToUTF16(data.text);
|
||||||
memcpy(text_memory->GetPointer(), text.c_str(), text.length() * sizeof(char16_t));
|
memcpy(text_memory->GetPointer(), text.c_str(), text.length() * sizeof(char16_t));
|
||||||
switch (config.num_buttons_m1) {
|
switch (config.num_buttons_m1) {
|
||||||
case SoftwareKeyboardButtonConfig::SINGLE_BUTTON:
|
case SoftwareKeyboardButtonConfig::SingleButton:
|
||||||
config.return_code = SoftwareKeyboardResult::D0_CLICK;
|
config.return_code = SoftwareKeyboardResult::D0Click;
|
||||||
break;
|
break;
|
||||||
case SoftwareKeyboardButtonConfig::DUAL_BUTTON:
|
case SoftwareKeyboardButtonConfig::DualButton:
|
||||||
if (data.button == 0)
|
if (data.button == 0)
|
||||||
config.return_code = SoftwareKeyboardResult::D1_CLICK0;
|
config.return_code = SoftwareKeyboardResult::D1Click0;
|
||||||
else
|
else
|
||||||
config.return_code = SoftwareKeyboardResult::D1_CLICK1;
|
config.return_code = SoftwareKeyboardResult::D1Click1;
|
||||||
break;
|
break;
|
||||||
case SoftwareKeyboardButtonConfig::TRIPLE_BUTTON:
|
case SoftwareKeyboardButtonConfig::TripleButton:
|
||||||
if (data.button == 0)
|
if (data.button == 0)
|
||||||
config.return_code = SoftwareKeyboardResult::D2_CLICK0;
|
config.return_code = SoftwareKeyboardResult::D2Click0;
|
||||||
else if (data.button == 1)
|
else if (data.button == 1)
|
||||||
config.return_code = SoftwareKeyboardResult::D2_CLICK1;
|
config.return_code = SoftwareKeyboardResult::D2Click1;
|
||||||
else
|
else
|
||||||
config.return_code = SoftwareKeyboardResult::D2_CLICK2;
|
config.return_code = SoftwareKeyboardResult::D2Click2;
|
||||||
break;
|
break;
|
||||||
case SoftwareKeyboardButtonConfig::NO_BUTTON:
|
case SoftwareKeyboardButtonConfig::NoButton:
|
||||||
// TODO: find out what is actually returned
|
// TODO: find out what is actually returned
|
||||||
config.return_code = SoftwareKeyboardResult::NONE;
|
config.return_code = SoftwareKeyboardResult::None;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
NGLOG_CRITICAL(Applet_SWKBD, "Unknown button config {}",
|
LOG_CRITICAL(Applet_SWKBD, "Unknown button config {}",
|
||||||
static_cast<int>(config.num_buttons_m1));
|
static_cast<int>(config.num_buttons_m1));
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
config.text_length = static_cast<u16>(text.size() + 1);
|
config.text_length = static_cast<u16>(text.size());
|
||||||
config.text_offset = 0;
|
config.text_offset = 0;
|
||||||
|
|
||||||
// TODO(Subv): We're finalizing the applet immediately after it's started,
|
// TODO(Subv): We're finalizing the applet immediately after it's started,
|
||||||
@ -122,13 +123,7 @@ void SoftwareKeyboard::Update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SoftwareKeyboard::DrawScreenKeyboard() {
|
void SoftwareKeyboard::DrawScreenKeyboard() {
|
||||||
auto bottom_screen = Service::GSP::GetFrameBufferInfo(0, 1);
|
// TODO(Subv): Draw the HLE keyboard, for now just do nothing
|
||||||
auto info = bottom_screen->framebuffer_info[bottom_screen->index];
|
|
||||||
|
|
||||||
// TODO(Subv): Draw the HLE keyboard, for now just zero-fill the framebuffer
|
|
||||||
Memory::ZeroBlock(info.address_left, info.stride * 320);
|
|
||||||
|
|
||||||
Service::GSP::SetBufferSwap(1, info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftwareKeyboard::Finalize() {
|
void SoftwareKeyboard::Finalize() {
|
||||||
@ -144,7 +139,8 @@ void SoftwareKeyboard::Finalize() {
|
|||||||
is_running = false;
|
is_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Frontend::KeyboardConfig SoftwareKeyboard::ToFrontendConfig(SoftwareKeyboardConfig config) {
|
Frontend::KeyboardConfig SoftwareKeyboard::ToFrontendConfig(
|
||||||
|
const SoftwareKeyboardConfig& config) const {
|
||||||
using namespace Frontend;
|
using namespace Frontend;
|
||||||
KeyboardConfig frontend_config;
|
KeyboardConfig frontend_config;
|
||||||
frontend_config.button_config = static_cast<ButtonConfig>(config.num_buttons_m1);
|
frontend_config.button_config = static_cast<ButtonConfig>(config.num_buttons_m1);
|
||||||
@ -152,32 +148,33 @@ Frontend::KeyboardConfig SoftwareKeyboard::ToFrontendConfig(SoftwareKeyboardConf
|
|||||||
frontend_config.multiline_mode = config.multiline;
|
frontend_config.multiline_mode = config.multiline;
|
||||||
frontend_config.max_text_length = config.max_text_length;
|
frontend_config.max_text_length = config.max_text_length;
|
||||||
frontend_config.max_digits = config.max_digits;
|
frontend_config.max_digits = config.max_digits;
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
|
std::u16string buffer(config.hint_text.size(), 0);
|
||||||
frontend_config.hint_text =
|
std::memcpy(buffer.data(), config.hint_text.data(), config.hint_text.size() * sizeof(u16));
|
||||||
convert.to_bytes(reinterpret_cast<const char16_t*>(config.hint_text.data()));
|
frontend_config.hint_text = Common::UTF16ToUTF8(buffer);
|
||||||
frontend_config.has_custom_button_text =
|
frontend_config.has_custom_button_text =
|
||||||
std::all_of(config.button_text.begin(), config.button_text.end(),
|
!std::all_of(config.button_text.begin(), config.button_text.end(),
|
||||||
[](std::array<u16, HLE::Applets::MAX_BUTTON_TEXT_LEN + 1> x) {
|
[](std::array<u16, HLE::Applets::MAX_BUTTON_TEXT_LEN + 1> x) {
|
||||||
return std::all_of(x.begin(), x.end(), [](u16 x) { return x == 0; });
|
return std::all_of(x.begin(), x.end(), [](u16 x) { return x == 0; });
|
||||||
});
|
});
|
||||||
if (frontend_config.has_custom_button_text) {
|
if (frontend_config.has_custom_button_text) {
|
||||||
for (const auto& text : config.button_text) {
|
for (const auto& text : config.button_text) {
|
||||||
frontend_config.button_text.push_back(
|
buffer.resize(text.size());
|
||||||
convert.to_bytes(reinterpret_cast<const char16_t*>(text.data())));
|
std::memcpy(buffer.data(), text.data(), text.size() * sizeof(u16));
|
||||||
|
frontend_config.button_text.push_back(Common::UTF16ToUTF8(buffer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
frontend_config.filters.prevent_digit =
|
frontend_config.filters.prevent_digit =
|
||||||
static_cast<bool>(config.filter_flags & SoftwareKeyboardFilter::DIGITS);
|
static_cast<bool>(config.filter_flags & SoftwareKeyboardFilter::Digits);
|
||||||
frontend_config.filters.prevent_at =
|
frontend_config.filters.prevent_at =
|
||||||
static_cast<bool>(config.filter_flags & SoftwareKeyboardFilter::AT);
|
static_cast<bool>(config.filter_flags & SoftwareKeyboardFilter::At);
|
||||||
frontend_config.filters.prevent_percent =
|
frontend_config.filters.prevent_percent =
|
||||||
static_cast<bool>(config.filter_flags & SoftwareKeyboardFilter::PERCENT);
|
static_cast<bool>(config.filter_flags & SoftwareKeyboardFilter::Percent);
|
||||||
frontend_config.filters.prevent_backslash =
|
frontend_config.filters.prevent_backslash =
|
||||||
static_cast<bool>(config.filter_flags & SoftwareKeyboardFilter::BACKSLASH);
|
static_cast<bool>(config.filter_flags & SoftwareKeyboardFilter::Backslash);
|
||||||
frontend_config.filters.prevent_profanity =
|
frontend_config.filters.prevent_profanity =
|
||||||
static_cast<bool>(config.filter_flags & SoftwareKeyboardFilter::PROFANITY);
|
static_cast<bool>(config.filter_flags & SoftwareKeyboardFilter::Profanity);
|
||||||
frontend_config.filters.enable_callback =
|
frontend_config.filters.enable_callback =
|
||||||
static_cast<bool>(config.filter_flags & SoftwareKeyboardFilter::CALLBACK);
|
static_cast<bool>(config.filter_flags & SoftwareKeyboardFilter::Callback);
|
||||||
return frontend_config;
|
return frontend_config;
|
||||||
}
|
}
|
||||||
} // namespace Applets
|
} // namespace Applets
|
||||||
|
@ -27,97 +27,97 @@ constexpr int MAX_CALLBACK_MSG_LEN = 256;
|
|||||||
|
|
||||||
/// Keyboard types
|
/// Keyboard types
|
||||||
enum class SoftwareKeyboardType : u32 {
|
enum class SoftwareKeyboardType : u32 {
|
||||||
NORMAL = 0, ///< Normal keyboard with several pages (QWERTY/accents/symbol/mobile)
|
Normal, ///< Normal keyboard with several pages (QWERTY/accents/symbol/mobile)
|
||||||
QWERTY, ///< QWERTY keyboard only.
|
QWERTY, ///< QWERTY keyboard only.
|
||||||
NUMPAD, ///< Number pad.
|
NumPad, ///< Number pad.
|
||||||
WESTERN, ///< On JPN systems, a text keyboard without Japanese input capabilities,
|
Western, ///< On JPN systems, a text keyboard without Japanese input capabilities,
|
||||||
/// otherwise same as SWKBD_TYPE_NORMAL.
|
/// otherwise same as SWKBD_TYPE_NORMAL.
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Keyboard dialog buttons.
|
/// Keyboard dialog buttons.
|
||||||
enum class SoftwareKeyboardButtonConfig : u32 {
|
enum class SoftwareKeyboardButtonConfig : u32 {
|
||||||
SINGLE_BUTTON = 0, ///< Ok button
|
SingleButton, ///< Ok button
|
||||||
DUAL_BUTTON, ///< Cancel | Ok buttons
|
DualButton, ///< Cancel | Ok buttons
|
||||||
TRIPLE_BUTTON, ///< Cancel | I Forgot | Ok buttons
|
TripleButton, ///< Cancel | I Forgot | Ok buttons
|
||||||
NO_BUTTON, ///< No button (returned by swkbdInputText in special cases)
|
NoButton, ///< No button (returned by swkbdInputText in special cases)
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Accepted input types.
|
/// Accepted input types.
|
||||||
enum class SoftwareKeyboardValidInput : u32 {
|
enum class SoftwareKeyboardValidInput : u32 {
|
||||||
ANYTHING = 0, ///< All inputs are accepted.
|
Anything, ///< All inputs are accepted.
|
||||||
NOTEMPTY, ///< Empty inputs are not accepted.
|
NotEmpty, ///< Empty inputs are not accepted.
|
||||||
NOTEMPTY_NOTBLANK, ///< Empty or blank inputs (consisting solely of whitespace) are not
|
NotEmptyNotBlank, ///< Empty or blank inputs (consisting solely of whitespace) are not
|
||||||
/// accepted.
|
/// accepted.
|
||||||
NOTBLANK, ///< Blank inputs (consisting solely of whitespace) are not accepted, but empty
|
NotBlank, ///< Blank inputs (consisting solely of whitespace) are not accepted, but empty
|
||||||
/// inputs are.
|
/// inputs are.
|
||||||
FIXEDLEN, ///< The input must have a fixed length (specified by maxTextLength in
|
FixedLen, ///< The input must have a fixed length (specified by maxTextLength in
|
||||||
/// swkbdInit).
|
/// swkbdInit).
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Keyboard password modes.
|
/// Keyboard password modes.
|
||||||
enum class SoftwareKeyboardPasswordMode : u32 {
|
enum class SoftwareKeyboardPasswordMode : u32 {
|
||||||
NONE = 0, ///< Characters are not concealed.
|
None, ///< Characters are not concealed.
|
||||||
HIDE, ///< Characters are concealed immediately.
|
Hide, ///< Characters are concealed immediately.
|
||||||
HIDE_DELAY, ///< Characters are concealed a second after they've been typed.
|
HideDelay, ///< Characters are concealed a second after they've been typed.
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Keyboard input filtering flags. Allows the caller to specify what input is explicitly not
|
/// Keyboard input filtering flags. Allows the caller to specify what input is explicitly not
|
||||||
/// allowed
|
/// allowed
|
||||||
namespace SoftwareKeyboardFilter {
|
namespace SoftwareKeyboardFilter {
|
||||||
enum Filter {
|
enum Filter {
|
||||||
DIGITS = 1, ///< Disallow the use of more than a certain number of digits (0 or more)
|
Digits = 1, ///< Disallow the use of more than a certain number of digits (0 or more)
|
||||||
AT = 1 << 1, ///< Disallow the use of the @ sign.
|
At = 1 << 1, ///< Disallow the use of the @ sign.
|
||||||
PERCENT = 1 << 2, ///< Disallow the use of the % sign.
|
Percent = 1 << 2, ///< Disallow the use of the % sign.
|
||||||
BACKSLASH = 1 << 3, ///< Disallow the use of the \ sign.
|
Backslash = 1 << 3, ///< Disallow the use of the \ sign.
|
||||||
PROFANITY = 1 << 4, ///< Disallow profanity using Nintendo's profanity filter.
|
Profanity = 1 << 4, ///< Disallow profanity using Nintendo's profanity filter.
|
||||||
CALLBACK = 1 << 5, ///< Use a callback in order to check the input.
|
Callback = 1 << 5, ///< Use a callback in order to check the input.
|
||||||
};
|
};
|
||||||
} // namespace SoftwareKeyboardFilter
|
} // namespace SoftwareKeyboardFilter
|
||||||
|
|
||||||
/// Keyboard features.
|
/// Keyboard features.
|
||||||
namespace SoftwareKeyboardFeature {
|
namespace SoftwareKeyboardFeature {
|
||||||
enum Feature {
|
enum Feature {
|
||||||
PARENTAL = 1, ///< Parental PIN mode.
|
Parental = 1, ///< Parental PIN mode.
|
||||||
DARKEN_TOP_SCREEN = 1 << 1, ///< Darken the top screen when the keyboard is shown.
|
DarkenTopScreen = 1 << 1, ///< Darken the top screen when the keyboard is shown.
|
||||||
PREDICTIVE_INPUT =
|
PredictiveInput =
|
||||||
1 << 2, ///< Enable predictive input (necessary for Kanji input in JPN systems).
|
1 << 2, ///< Enable predictive input (necessary for Kanji input in JPN systems).
|
||||||
MULTILINE = 1 << 3, ///< Enable multiline input.
|
Multiline = 1 << 3, ///< Enable multiline input.
|
||||||
FIXED_WIDTH = 1 << 4, ///< Enable fixed-width mode.
|
FixedWidth = 1 << 4, ///< Enable fixed-width mode.
|
||||||
ALLOW_HOME = 1 << 5, ///< Allow the usage of the HOME button.
|
AllowHome = 1 << 5, ///< Allow the usage of the HOME button.
|
||||||
ALLOW_RESET = 1 << 6, ///< Allow the usage of a software-reset combination.
|
AllowReset = 1 << 6, ///< Allow the usage of a software-reset combination.
|
||||||
ALLOW_POWER = 1 << 7, ///< Allow the usage of the POWER button.
|
AllowPower = 1 << 7, ///< Allow the usage of the POWER button.
|
||||||
DEFAULT_QWERTY = 1 << 9, ///< Default to the QWERTY page when the keyboard is shown.
|
DefaultQWERTY = 1 << 9, ///< Default to the QWERTY page when the keyboard is shown.
|
||||||
};
|
};
|
||||||
} // namespace SoftwareKeyboardFeature
|
} // namespace SoftwareKeyboardFeature
|
||||||
|
|
||||||
/// Keyboard filter callback return values.
|
/// Keyboard filter callback return values.
|
||||||
enum class SoftwareKeyboardCallbackResult : u32 {
|
enum class SoftwareKeyboardCallbackResult : u32 {
|
||||||
OK = 0, ///< Specifies that the input is valid.
|
OK, ///< Specifies that the input is valid.
|
||||||
CLOSE, ///< Displays an error message, then closes the keyboard.
|
Close, ///< Displays an error message, then closes the keyboard.
|
||||||
CONTINUE, ///< Displays an error message and continues displaying the keyboard.
|
Continue, ///< Displays an error message and continues displaying the keyboard.
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Keyboard return values.
|
/// Keyboard return values.
|
||||||
enum class SoftwareKeyboardResult : s32 {
|
enum class SoftwareKeyboardResult : s32 {
|
||||||
NONE = -1, ///< Dummy/unused.
|
None = -1, ///< Dummy/unused.
|
||||||
INVALID_INPUT = -2, ///< Invalid parameters to swkbd.
|
InvalidInput = -2, ///< Invalid parameters to swkbd.
|
||||||
OUTOFMEM = -3, ///< Out of memory.
|
OutOfMem = -3, ///< Out of memory.
|
||||||
|
|
||||||
D0_CLICK = 0, ///< The button was clicked in 1-button dialogs.
|
D0Click = 0, ///< The button was clicked in 1-button dialogs.
|
||||||
D1_CLICK0, ///< The left button was clicked in 2-button dialogs.
|
D1Click0, ///< The left button was clicked in 2-button dialogs.
|
||||||
D1_CLICK1, ///< The right button was clicked in 2-button dialogs.
|
D1Click1, ///< The right button was clicked in 2-button dialogs.
|
||||||
D2_CLICK0, ///< The left button was clicked in 3-button dialogs.
|
D2Click0, ///< The left button was clicked in 3-button dialogs.
|
||||||
D2_CLICK1, ///< The middle button was clicked in 3-button dialogs.
|
D2Click1, ///< The middle button was clicked in 3-button dialogs.
|
||||||
D2_CLICK2, ///< The right button was clicked in 3-button dialogs.
|
D2Click2, ///< The right button was clicked in 3-button dialogs.
|
||||||
|
|
||||||
HOMEPRESSED = 10, ///< The HOME button was pressed.
|
HomePressed = 10, ///< The HOME button was pressed.
|
||||||
RESETPRESSED, ///< The soft-reset key combination was pressed.
|
ResetPressed, ///< The soft-reset key combination was pressed.
|
||||||
POWERPRESSED, ///< The POWER button was pressed.
|
PowerPressed, ///< The POWER button was pressed.
|
||||||
|
|
||||||
PARENTAL_OK = 20, ///< The parental PIN was verified successfully.
|
ParentalOK = 20, ///< The parental PIN was verified successfully.
|
||||||
PARENTAL_FAIL, ///< The parental PIN was incorrect.
|
ParentalFail, ///< The parental PIN was incorrect.
|
||||||
|
|
||||||
BANNED_INPUT = 30, ///< The filter callback returned SoftwareKeyboardCallback::CLOSE.
|
BannedInput = 30, ///< The filter callback returned SoftwareKeyboardCallback::CLOSE.
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SoftwareKeyboardConfig {
|
struct SoftwareKeyboardConfig {
|
||||||
@ -195,7 +195,7 @@ public:
|
|||||||
void Finalize();
|
void Finalize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Frontend::KeyboardConfig ToFrontendConfig(SoftwareKeyboardConfig config);
|
Frontend::KeyboardConfig ToFrontendConfig(const SoftwareKeyboardConfig& config) const;
|
||||||
|
|
||||||
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
|
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
|
||||||
/// It holds the framebuffer info retrieved by the application with
|
/// It holds the framebuffer info retrieved by the application with
|
||||||
@ -208,7 +208,7 @@ private:
|
|||||||
/// Configuration of this instance of the SoftwareKeyboard, as received from the application
|
/// Configuration of this instance of the SoftwareKeyboard, as received from the application
|
||||||
SoftwareKeyboardConfig config;
|
SoftwareKeyboardConfig config;
|
||||||
|
|
||||||
std::shared_ptr<Frontend::AppletInterface> frontend_applet;
|
std::shared_ptr<Frontend::SoftwareKeyboard> frontend_applet;
|
||||||
};
|
};
|
||||||
} // namespace Applets
|
} // namespace Applets
|
||||||
} // namespace HLE
|
} // namespace HLE
|
||||||
|
@ -96,9 +96,6 @@ struct Values {
|
|||||||
std::string motion_device;
|
std::string motion_device;
|
||||||
std::string touch_device;
|
std::string touch_device;
|
||||||
|
|
||||||
// Frontend Devices
|
|
||||||
std::string applet_swkbd;
|
|
||||||
|
|
||||||
// Core
|
// Core
|
||||||
bool use_cpu_jit;
|
bool use_cpu_jit;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user