mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 16:23:05 +00:00
user: make the local profile configurable (#347)
user: make the local user ID configurable Co-authored-by: nmzik <Nmzik@mail.ru>
This commit is contained in:
1 parent
e559771a08
commit
ccddd6fb94
10 files changed
+108
-42
No files matched your search
@@ -22,6 +22,7 @@ void Shutdown() {
|
|||||||
void Load(const ConfigOptions& cfg) {
|
void Load(const ConfigOptions& cfg) {
|
||||||
EXIT_IF(g_config == nullptr);
|
EXIT_IF(g_config == nullptr);
|
||||||
EXIT_IF(cfg.user_name.empty() || cfg.user_name.size() > MAX_USER_NAME_LENGTH);
|
EXIT_IF(cfg.user_name.empty() || cfg.user_name.size() > MAX_USER_NAME_LENGTH);
|
||||||
|
EXIT_IF(!IsConfiguredUserIdValid(cfg.user_id));
|
||||||
|
|
||||||
*g_config = cfg;
|
*g_config = cfg;
|
||||||
}
|
}
|
||||||
@@ -38,6 +39,10 @@ const std::string& GetUserName() {
|
|||||||
return g_config->user_name;
|
return g_config->user_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t GetUserId() {
|
||||||
|
return g_config->user_id;
|
||||||
|
}
|
||||||
|
|
||||||
PresentMode GetPresentMode() {
|
PresentMode GetPresentMode() {
|
||||||
return g_config->present_mode;
|
return g_config->present_mode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,11 +34,19 @@ using Keymap = std::vector<std::string>;
|
|||||||
constexpr uint32_t DEFAULT_CONSOLE_LANGUAGE = 1;
|
constexpr uint32_t DEFAULT_CONSOLE_LANGUAGE = 1;
|
||||||
constexpr uint32_t MAX_CONSOLE_LANGUAGE = 29;
|
constexpr uint32_t MAX_CONSOLE_LANGUAGE = 29;
|
||||||
constexpr std::size_t MAX_USER_NAME_LENGTH = 16;
|
constexpr std::size_t MAX_USER_NAME_LENGTH = 16;
|
||||||
|
constexpr int32_t DEFAULT_USER_ID = 1000;
|
||||||
|
|
||||||
|
constexpr bool IsConfiguredUserIdValid(int32_t user_id) {
|
||||||
|
constexpr int32_t USER_ID_EVERYONE = 0xfe;
|
||||||
|
constexpr int32_t USER_ID_SYSTEM = 0xff;
|
||||||
|
return user_id >= 0 && user_id != USER_ID_EVERYONE && user_id != USER_ID_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
struct ConfigOptions {
|
struct ConfigOptions {
|
||||||
uint32_t screen_width = 1280;
|
uint32_t screen_width = 1280;
|
||||||
uint32_t screen_height = 720;
|
uint32_t screen_height = 720;
|
||||||
std::string user_name = "Kyty";
|
std::string user_name = "Kyty";
|
||||||
|
int32_t user_id = DEFAULT_USER_ID;
|
||||||
PresentMode present_mode = PresentMode::Fifo;
|
PresentMode present_mode = PresentMode::Fifo;
|
||||||
bool fullscreen_enabled = false;
|
bool fullscreen_enabled = false;
|
||||||
uint32_t vblank_frequency = 60;
|
uint32_t vblank_frequency = 60;
|
||||||
@@ -70,6 +78,7 @@ void Load(const ConfigOptions& cfg);
|
|||||||
uint32_t GetScreenWidth();
|
uint32_t GetScreenWidth();
|
||||||
uint32_t GetScreenHeight();
|
uint32_t GetScreenHeight();
|
||||||
const std::string& GetUserName();
|
const std::string& GetUserName();
|
||||||
|
int32_t GetUserId();
|
||||||
PresentMode GetPresentMode();
|
PresentMode GetPresentMode();
|
||||||
bool FullscreenEnabled();
|
bool FullscreenEnabled();
|
||||||
uint32_t GetVblankFrequency();
|
uint32_t GetVblankFrequency();
|
||||||
|
|||||||
@@ -119,41 +119,58 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_user_id">
|
||||||
|
<property name="text">
|
||||||
|
<string>User ID:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QSpinBox" name="spinBox_user_id">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Local user ID exposed to games</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>2147483647</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="label_16">
|
<widget class="QLabel" name="label_16">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Screen resolution:</string>
|
<string>Screen resolution:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QComboBox" name="comboBox_screen_resolution">
|
<widget class="QComboBox" name="comboBox_screen_resolution">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Window resolution</string>
|
<string>Window resolution</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="label_present_mode">
|
<widget class="QLabel" name="label_present_mode">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Present mode:</string>
|
<string>Present mode:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QComboBox" name="comboBox_present_mode">
|
<widget class="QComboBox" name="comboBox_present_mode">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Vulkan swapchain presentation mode</string>
|
<string>Vulkan swapchain presentation mode</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QLabel" name="label_vblank_frequency">
|
<widget class="QLabel" name="label_vblank_frequency">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Vblank frequency:</string>
|
<string>Vblank frequency:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="QSpinBox" name="spinBox_vblank_frequency">
|
<widget class="QSpinBox" name="spinBox_vblank_frequency">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Virtual display refresh rate used for frame pacing</string>
|
<string>Virtual display refresh rate used for frame pacing</string>
|
||||||
@@ -169,56 +186,56 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QLabel" name="label_console_language">
|
<widget class="QLabel" name="label_console_language">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Console language:</string>
|
<string>Console language:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="6" column="1">
|
||||||
<widget class="QComboBox" name="comboBox_console_language">
|
<widget class="QComboBox" name="comboBox_console_language">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Language</string>
|
<string>Language</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="7" column="0">
|
||||||
<widget class="QLabel" name="label_20">
|
<widget class="QLabel" name="label_20">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Shader optimization type:</string>
|
<string>Shader optimization type:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1">
|
<item row="7" column="1">
|
||||||
<widget class="QComboBox" name="comboBox_shader_optimization_type">
|
<widget class="QComboBox" name="comboBox_shader_optimization_type">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Optimize shaders for code size or performance</string>
|
<string>Optimize shaders for code size or performance</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0">
|
<item row="8" column="0">
|
||||||
<widget class="QLabel" name="label_21">
|
<widget class="QLabel" name="label_21">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Shader log direction:</string>
|
<string>Shader log direction:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1">
|
<item row="8" column="1">
|
||||||
<widget class="QComboBox" name="comboBox_shader_log_direction">
|
<widget class="QComboBox" name="comboBox_shader_log_direction">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Dump shaders to file or console window. If enabled may decrease emulator performance</string>
|
<string>Dump shaders to file or console window. If enabled may decrease emulator performance</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0">
|
<item row="9" column="0">
|
||||||
<widget class="QLabel" name="label_22">
|
<widget class="QLabel" name="label_22">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Shader log folder:</string>
|
<string>Shader log folder:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="1">
|
<item row="9" column="1">
|
||||||
<widget class="MandatoryLineEdit" name="lineEdit_shader_log_folder">
|
<widget class="MandatoryLineEdit" name="lineEdit_shader_log_folder">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Specify directory to dump shaders</string>
|
<string>Specify directory to dump shaders</string>
|
||||||
@@ -228,14 +245,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="0">
|
<item row="10" column="0">
|
||||||
<widget class="QLabel" name="label_24">
|
<widget class="QLabel" name="label_24">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Command buffer dump folder:</string>
|
<string>Command buffer dump folder:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="1">
|
<item row="10" column="1">
|
||||||
<widget class="MandatoryLineEdit" name="lineEdit_cmd_dump_folder">
|
<widget class="MandatoryLineEdit" name="lineEdit_cmd_dump_folder">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Specify directory to dump command buffers</string>
|
<string>Specify directory to dump command buffers</string>
|
||||||
@@ -245,28 +262,28 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="0">
|
<item row="11" column="0">
|
||||||
<widget class="QLabel" name="label_25">
|
<widget class="QLabel" name="label_25">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Printf direction:</string>
|
<string>Printf direction:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="1">
|
<item row="11" column="1">
|
||||||
<widget class="QComboBox" name="comboBox_printf_direction">
|
<widget class="QComboBox" name="comboBox_printf_direction">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Print logs to file or console window. If enabled may decrease emulator performance</string>
|
<string>Print logs to file or console window. If enabled may decrease emulator performance</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="11" column="0">
|
<item row="12" column="0">
|
||||||
<widget class="QLabel" name="label_26">
|
<widget class="QLabel" name="label_26">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Printf output file:</string>
|
<string>Printf output file:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="11" column="1">
|
<item row="12" column="1">
|
||||||
<widget class="MandatoryLineEdit" name="lineEdit_printf_file">
|
<widget class="MandatoryLineEdit" name="lineEdit_printf_file">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Specify file to dump logs</string>
|
<string>Specify file to dump logs</string>
|
||||||
@@ -276,14 +293,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="12" column="0">
|
<item row="13" column="0">
|
||||||
<widget class="QLabel" name="label_27">
|
<widget class="QLabel" name="label_27">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Profiler direction:</string>
|
<string>Profiler direction:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="12" column="1">
|
<item row="13" column="1">
|
||||||
<widget class="QComboBox" name="comboBox_profiler_direction">
|
<widget class="QComboBox" name="comboBox_profiler_direction">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Enable or disable profiler. If enabled may decrease emulator performance</string>
|
<string>Enable or disable profiler. If enabled may decrease emulator performance</string>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define LAUNCHER_INCLUDE_CONFIGURATION_H_
|
#define LAUNCHER_INCLUDE_CONFIGURATION_H_
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "common/emulatorConfig.h"
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QChar>
|
#include <QChar>
|
||||||
@@ -91,6 +92,7 @@ public:
|
|||||||
|
|
||||||
Resolution screen_resolution = Resolution::R1280X720;
|
Resolution screen_resolution = Resolution::R1280X720;
|
||||||
QString user_name = "Kyty";
|
QString user_name = "Kyty";
|
||||||
|
int user_id = Config::DEFAULT_USER_ID;
|
||||||
PresentMode present_mode = PresentMode::Fifo;
|
PresentMode present_mode = PresentMode::Fifo;
|
||||||
bool fullscreen_enabled = false;
|
bool fullscreen_enabled = false;
|
||||||
int vblank_frequency = 60;
|
int vblank_frequency = 60;
|
||||||
@@ -116,6 +118,7 @@ public:
|
|||||||
void CopyEmulatorSettingsFrom(const Configuration& other) {
|
void CopyEmulatorSettingsFrom(const Configuration& other) {
|
||||||
screen_resolution = other.screen_resolution;
|
screen_resolution = other.screen_resolution;
|
||||||
user_name = other.user_name;
|
user_name = other.user_name;
|
||||||
|
user_id = other.user_id;
|
||||||
present_mode = other.present_mode;
|
present_mode = other.present_mode;
|
||||||
fullscreen_enabled = other.fullscreen_enabled;
|
fullscreen_enabled = other.fullscreen_enabled;
|
||||||
vblank_frequency = other.vblank_frequency;
|
vblank_frequency = other.vblank_frequency;
|
||||||
@@ -158,6 +161,7 @@ public:
|
|||||||
KYTY_CFG_SET(custom_settings);
|
KYTY_CFG_SET(custom_settings);
|
||||||
KYTY_CFG_SET(screen_resolution);
|
KYTY_CFG_SET(screen_resolution);
|
||||||
KYTY_CFG_SET(user_name);
|
KYTY_CFG_SET(user_name);
|
||||||
|
KYTY_CFG_SET(user_id);
|
||||||
KYTY_CFG_SET(present_mode);
|
KYTY_CFG_SET(present_mode);
|
||||||
KYTY_CFG_SET(fullscreen_enabled);
|
KYTY_CFG_SET(fullscreen_enabled);
|
||||||
KYTY_CFG_SET(vblank_frequency);
|
KYTY_CFG_SET(vblank_frequency);
|
||||||
@@ -186,7 +190,12 @@ public:
|
|||||||
KYTY_CFG_GET(game_path);
|
KYTY_CFG_GET(game_path);
|
||||||
KYTY_CFG_GET(custom_settings);
|
KYTY_CFG_GET(custom_settings);
|
||||||
KYTY_CFG_GET(screen_resolution);
|
KYTY_CFG_GET(screen_resolution);
|
||||||
user_name = s->value("user_name", user_name).toString();
|
user_name = s->value("user_name", user_name).toString();
|
||||||
|
bool user_id_ok = false;
|
||||||
|
auto saved_user_id = s->value("user_id", user_id).toInt(&user_id_ok);
|
||||||
|
user_id = user_id_ok && Config::IsConfiguredUserIdValid(saved_user_id)
|
||||||
|
? saved_user_id
|
||||||
|
: Config::DEFAULT_USER_ID;
|
||||||
KYTY_CFG_GET(present_mode);
|
KYTY_CFG_GET(present_mode);
|
||||||
if (EnumToText(present_mode).isEmpty()) {
|
if (EnumToText(present_mode).isEmpty()) {
|
||||||
present_mode = PresentMode::Fifo;
|
present_mode = PresentMode::Fifo;
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ static void ListInit(QComboBox* combo, T value) {
|
|||||||
void ConfigurationEditDialog::Init(const Configuration& info) {
|
void ConfigurationEditDialog::Init(const Configuration& info) {
|
||||||
m_ui->lineEdit_user_name->setMaxLength(static_cast<int>(Config::MAX_USER_NAME_LENGTH));
|
m_ui->lineEdit_user_name->setMaxLength(static_cast<int>(Config::MAX_USER_NAME_LENGTH));
|
||||||
m_ui->lineEdit_user_name->setText(info.user_name);
|
m_ui->lineEdit_user_name->setText(info.user_name);
|
||||||
|
m_ui->spinBox_user_id->setValue(info.user_id);
|
||||||
ListInit(m_ui->comboBox_screen_resolution, info.screen_resolution);
|
ListInit(m_ui->comboBox_screen_resolution, info.screen_resolution);
|
||||||
ListInit(m_ui->comboBox_present_mode, info.present_mode);
|
ListInit(m_ui->comboBox_present_mode, info.present_mode);
|
||||||
m_ui->checkBox_fullscreen->setChecked(info.fullscreen_enabled);
|
m_ui->checkBox_fullscreen->setChecked(info.fullscreen_enabled);
|
||||||
@@ -289,6 +290,7 @@ void ConfigurationEditDialog::moveEvent(QMoveEvent* event) {
|
|||||||
|
|
||||||
static void UpdateInfo(Configuration& info, Ui::ConfigurationEditDialog& ui) {
|
static void UpdateInfo(Configuration& info, Ui::ConfigurationEditDialog& ui) {
|
||||||
info.user_name = ui.lineEdit_user_name->text().trimmed();
|
info.user_name = ui.lineEdit_user_name->text().trimmed();
|
||||||
|
info.user_id = ui.spinBox_user_id->value();
|
||||||
info.screen_resolution =
|
info.screen_resolution =
|
||||||
TextToEnum<Configuration::Resolution>(ui.comboBox_screen_resolution->currentText());
|
TextToEnum<Configuration::Resolution>(ui.comboBox_screen_resolution->currentText());
|
||||||
info.present_mode =
|
info.present_mode =
|
||||||
@@ -337,6 +339,11 @@ void ConfigurationEditDialog::save() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_ui->lineEdit_user_name->setText(user_name);
|
m_ui->lineEdit_user_name->setText(user_name);
|
||||||
|
if (!Config::IsConfiguredUserIdValid(m_ui->spinBox_user_id->value())) {
|
||||||
|
QMessageBox::critical(this, tr("Save failed"),
|
||||||
|
tr("User ID cannot be 254 (everyone) or 255 (system)"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
update_info();
|
update_info();
|
||||||
|
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ static QStringList CreateEmulatorArgs(const Configuration& info) {
|
|||||||
args << "--screen-width" << r.at(0);
|
args << "--screen-width" << r.at(0);
|
||||||
args << "--screen-height" << r.at(1);
|
args << "--screen-height" << r.at(1);
|
||||||
args << "--user-name" << info.user_name;
|
args << "--user-name" << info.user_name;
|
||||||
|
args << "--user-id" << QString::number(info.user_id);
|
||||||
args << "--present-mode" << EnumToText(info.present_mode);
|
args << "--present-mode" << EnumToText(info.present_mode);
|
||||||
if (info.fullscreen_enabled) {
|
if (info.fullscreen_enabled) {
|
||||||
args << "--fullscreen";
|
args << "--fullscreen";
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
|
#include "common/emulatorConfig.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/stringUtils.h"
|
#include "common/stringUtils.h"
|
||||||
#include "common/threads.h"
|
#include "common/threads.h"
|
||||||
@@ -358,13 +359,12 @@ int KYTY_SYSV_ABI PadInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool PadOpenArgsAreValid(int user_id, int type, int index) {
|
static bool PadOpenArgsAreValid(int user_id, int type, int index) {
|
||||||
constexpr int user_id_initial = 1000;
|
|
||||||
constexpr int user_id_system = 0xff;
|
constexpr int user_id_system = 0xff;
|
||||||
constexpr int port_type_standard = 0;
|
constexpr int port_type_standard = 0;
|
||||||
constexpr int port_type_special = 2;
|
constexpr int port_type_special = 2;
|
||||||
constexpr int port_type_remote = 16;
|
constexpr int port_type_remote = 16;
|
||||||
const bool personal_port =
|
const bool personal_port =
|
||||||
user_id == user_id_initial && (type == port_type_standard || type == port_type_special);
|
user_id == Config::GetUserId() && (type == port_type_standard || type == port_type_special);
|
||||||
const bool system_remote_control = user_id == user_id_system && type == port_type_remote;
|
const bool system_remote_control = user_id == user_id_system && type == port_type_remote;
|
||||||
return index == 0 && (personal_port || system_remote_control);
|
return index == 0 && (personal_port || system_remote_control);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -1,5 +1,6 @@
|
|||||||
#include "libs/dialog.h"
|
#include "libs/dialog.h"
|
||||||
|
|
||||||
|
#include "common/emulatorConfig.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/stringUtils.h"
|
#include "common/stringUtils.h"
|
||||||
#include "libs/errno.h"
|
#include "libs/errno.h"
|
||||||
@@ -41,7 +42,6 @@ constexpr int LOGIN_RESULT_OK = 0;
|
|||||||
constexpr int LOGIN_MODE_ALL_USERS = 0;
|
constexpr int LOGIN_MODE_ALL_USERS = 0;
|
||||||
constexpr int LOGIN_MODE_NOT_LOGGED_IN = 1;
|
constexpr int LOGIN_MODE_NOT_LOGGED_IN = 1;
|
||||||
constexpr int LOGIN_USER_INVALID = -1;
|
constexpr int LOGIN_USER_INVALID = -1;
|
||||||
constexpr int LOGIN_USER_ID = 1000;
|
|
||||||
|
|
||||||
constexpr int LOGIN_ERROR_NOT_INITIALIZED = static_cast<int>(0x81340001u);
|
constexpr int LOGIN_ERROR_NOT_INITIALIZED = static_cast<int>(0x81340001u);
|
||||||
constexpr int LOGIN_ERROR_ALREADY_INITIALIZED = static_cast<int>(0x81340002u);
|
constexpr int LOGIN_ERROR_ALREADY_INITIALIZED = static_cast<int>(0x81340002u);
|
||||||
@@ -67,7 +67,7 @@ static_assert(sizeof(LoginDialogResult) == 16);
|
|||||||
static_assert(sizeof(LoginDialogParam) == 64);
|
static_assert(sizeof(LoginDialogParam) == 64);
|
||||||
|
|
||||||
static int g_login_status = LOGIN_STATUS_NONE;
|
static int g_login_status = LOGIN_STATUS_NONE;
|
||||||
static int g_login_selected_user = LOGIN_USER_ID;
|
static int g_login_selected_user = LOGIN_USER_INVALID;
|
||||||
|
|
||||||
int KYTY_SYSV_ABI LoginDialogInitialize() {
|
int KYTY_SYSV_ABI LoginDialogInitialize() {
|
||||||
PRINT_NAME();
|
PRINT_NAME();
|
||||||
@@ -77,7 +77,7 @@ int KYTY_SYSV_ABI LoginDialogInitialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_login_status = LOGIN_STATUS_INITIALIZED;
|
g_login_status = LOGIN_STATUS_INITIALIZED;
|
||||||
g_login_selected_user = LOGIN_USER_ID;
|
g_login_selected_user = Config::GetUserId();
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ int KYTY_SYSV_ABI LoginDialogTerminate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_login_status = LOGIN_STATUS_NONE;
|
g_login_status = LOGIN_STATUS_NONE;
|
||||||
g_login_selected_user = LOGIN_USER_ID;
|
g_login_selected_user = LOGIN_USER_INVALID;
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ int KYTY_SYSV_ABI LoginDialogOpen(const void* param) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_login_selected_user =
|
g_login_selected_user =
|
||||||
p->initial_focus != LOGIN_USER_INVALID ? p->initial_focus : LOGIN_USER_ID;
|
p->initial_focus != LOGIN_USER_INVALID ? p->initial_focus : Config::GetUserId();
|
||||||
|
|
||||||
LOGF("\t size = %d\n"
|
LOGF("\t size = %d\n"
|
||||||
"\t mode = %d\n"
|
"\t mode = %d\n"
|
||||||
|
|||||||
+13
-13
@@ -56,7 +56,7 @@ static KYTY_SYSV_ABI int UserServiceGetInitialUser(int* user_id) {
|
|||||||
|
|
||||||
EXIT_NOT_IMPLEMENTED(user_id == nullptr);
|
EXIT_NOT_IMPLEMENTED(user_id == nullptr);
|
||||||
|
|
||||||
*user_id = 1000;
|
*user_id = Config::GetUserId();
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ static KYTY_SYSV_ABI int UserServiceGetEvent(SceUserServiceEvent* event) {
|
|||||||
if (!logged_in) {
|
if (!logged_in) {
|
||||||
logged_in = true;
|
logged_in = true;
|
||||||
event->event_type = UserServiceEventTypeLogin;
|
event->event_type = UserServiceEventTypeLogin;
|
||||||
event->user_id = 1000;
|
event->user_id = Config::GetUserId();
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ static KYTY_SYSV_ABI int UserServiceGetLoginUserIdList(UserServiceLoginUserIdLis
|
|||||||
|
|
||||||
EXIT_NOT_IMPLEMENTED(user_id_list == nullptr);
|
EXIT_NOT_IMPLEMENTED(user_id_list == nullptr);
|
||||||
|
|
||||||
user_id_list->user_id[0] = 1000;
|
user_id_list->user_id[0] = Config::GetUserId();
|
||||||
user_id_list->user_id[1] = -1;
|
user_id_list->user_id[1] = -1;
|
||||||
user_id_list->user_id[2] = -1;
|
user_id_list->user_id[2] = -1;
|
||||||
user_id_list->user_id[3] = -1;
|
user_id_list->user_id[3] = -1;
|
||||||
@@ -92,7 +92,7 @@ static KYTY_SYSV_ABI int UserServiceGetLoginUserIdList(UserServiceLoginUserIdLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
static KYTY_SYSV_ABI int UserServiceGetUserName(int user_id, char* name, size_t size) {
|
static KYTY_SYSV_ABI int UserServiceGetUserName(int user_id, char* name, size_t size) {
|
||||||
EXIT_NOT_IMPLEMENTED(user_id != 1000);
|
EXIT_NOT_IMPLEMENTED(user_id != Config::GetUserId());
|
||||||
EXIT_NOT_IMPLEMENTED(size < 5);
|
EXIT_NOT_IMPLEMENTED(size < 5);
|
||||||
|
|
||||||
const auto& user_name = Config::GetUserName();
|
const auto& user_name = Config::GetUserName();
|
||||||
@@ -109,7 +109,7 @@ static KYTY_SYSV_ABI int UserServiceGetUserNumber(int user_id, int32_t* number)
|
|||||||
if (number == nullptr) {
|
if (number == nullptr) {
|
||||||
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
if (user_id != 1000) {
|
if (user_id != Config::GetUserId()) {
|
||||||
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ static KYTY_SYSV_ABI int UserServiceGetGamePresets(int user_id, UserServiceGameP
|
|||||||
if (presets == nullptr) {
|
if (presets == nullptr) {
|
||||||
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
if (user_id != 1000) {
|
if (user_id != Config::GetUserId()) {
|
||||||
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ static KYTY_SYSV_ABI int UserServiceGetAccessibilityVibration(int user_id, int32
|
|||||||
if (vibration == nullptr) {
|
if (vibration == nullptr) {
|
||||||
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
if (user_id != 1000) {
|
if (user_id != Config::GetUserId()) {
|
||||||
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ static KYTY_SYSV_ABI int UserServiceGetAccessibilityTriggerEffect(int user_
|
|||||||
if (trigger_effect == nullptr) {
|
if (trigger_effect == nullptr) {
|
||||||
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
if (user_id != 1000) {
|
if (user_id != Config::GetUserId()) {
|
||||||
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ static KYTY_SYSV_ABI int UserServiceGetAgeLevel(int user_id, uint32_t* age_level
|
|||||||
if (age_level == nullptr) {
|
if (age_level == nullptr) {
|
||||||
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
if (user_id != 1000) {
|
if (user_id != Config::GetUserId()) {
|
||||||
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ static KYTY_SYSV_ABI int UserServiceGetAccessibilityChatTranscription(int u
|
|||||||
if (chat_transcription == nullptr) {
|
if (chat_transcription == nullptr) {
|
||||||
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
if (user_id != 1000) {
|
if (user_id != Config::GetUserId()) {
|
||||||
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ UserServiceGetAccessibilityPressAndHoldDelay(int user_id, int32_t* press_and_hol
|
|||||||
if (press_and_hold_delay == nullptr) {
|
if (press_and_hold_delay == nullptr) {
|
||||||
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
if (user_id != 1000) {
|
if (user_id != Config::GetUserId()) {
|
||||||
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ static KYTY_SYSV_ABI int UserServiceGetAccessibilityZoomEnabled(int user_id
|
|||||||
if (zoom_enabled == nullptr) {
|
if (zoom_enabled == nullptr) {
|
||||||
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
if (user_id != 1000) {
|
if (user_id != Config::GetUserId()) {
|
||||||
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ static KYTY_SYSV_ABI int UserServiceGetAccessibilityZoomFollowFocus(int use
|
|||||||
if (zoom_follow_focus == nullptr) {
|
if (zoom_follow_focus == nullptr) {
|
||||||
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
if (user_id != 1000) {
|
if (user_id != Config::GetUserId()) {
|
||||||
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
return USER_SERVICE_ERROR_NOT_LOGGED_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ static void PrintUsage() {
|
|||||||
::printf(" --screen-height <num> Window height. Default: 720.\n");
|
::printf(" --screen-height <num> Window height. Default: 720.\n");
|
||||||
::printf(
|
::printf(
|
||||||
" --user-name <name> Local user name (1-16 bytes). Default: Kyty.\n");
|
" --user-name <name> Local user name (1-16 bytes). Default: Kyty.\n");
|
||||||
|
::printf(" --user-id <num> Local user ID. Default: %d.\n",
|
||||||
|
Config::DEFAULT_USER_ID);
|
||||||
::printf(" --present-mode <value> Fifo, Mailbox, or Immediate. Default: Fifo.\n");
|
::printf(" --present-mode <value> Fifo, Mailbox, or Immediate. Default: Fifo.\n");
|
||||||
::printf(" --fullscreen Run in borderless desktop fullscreen.\n");
|
::printf(" --fullscreen Run in borderless desktop fullscreen.\n");
|
||||||
::printf(" --vblank-frequency <num> Virtual vblank frequency. Default: 60.\n");
|
::printf(" --vblank-frequency <num> Virtual vblank frequency. Default: 60.\n");
|
||||||
@@ -125,6 +127,17 @@ static bool ParseConsoleLanguage(const std::string& value, uint32_t& out) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool ParseUserId(const std::string& value, int32_t& out) {
|
||||||
|
int32_t user_id = 0;
|
||||||
|
auto [end, error] = std::from_chars(value.data(), value.data() + value.size(), user_id);
|
||||||
|
if (error != std::errc {} || end != value.data() + value.size() ||
|
||||||
|
!Config::IsConfiguredUserIdValid(user_id)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
out = user_id;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool ParseArgs(int argc, char* argv[], RunOptions& options, bool& show_help) {
|
static bool ParseArgs(int argc, char* argv[], RunOptions& options, bool& show_help) {
|
||||||
show_help = false;
|
show_help = false;
|
||||||
|
|
||||||
@@ -211,6 +224,11 @@ static bool ParseArgs(int argc, char* argv[], RunOptions& options, bool& show_he
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
options.config.user_name = value;
|
options.config.user_name = value;
|
||||||
|
} else if (arg == "--user-id") {
|
||||||
|
if (!ParseUserId(value, options.config.user_id)) {
|
||||||
|
::printf("invalid user ID: %s\n", value.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else if (arg == "--present-mode") {
|
} else if (arg == "--present-mode") {
|
||||||
if (!ParseEnum(value, options.config.present_mode)) {
|
if (!ParseEnum(value, options.config.present_mode)) {
|
||||||
::printf("invalid present mode: %s\n", value.c_str());
|
::printf("invalid present mode: %s\n", value.c_str());
|
||||||
|
|||||||
Reference in new issue
Block a user