Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
Artic Base: Add Artic Controller support (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloMK7 authored Jul 16, 2024
1 parent 9de19ff commit 55748d7
Show file tree
Hide file tree
Showing 24 changed files with 752 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ enum class IntSetting(
DEBUG_RENDERER("renderer_debug", Settings.SECTION_DEBUG, 0),
TEXTURE_FILTER("texture_filter", Settings.SECTION_RENDERER, 0),
USE_FRAME_LIMIT("use_frame_limit", Settings.SECTION_RENDERER, 1),
DELAY_RENDER_THREAD_US("delay_game_render_thread_us", Settings.SECTION_RENDERER, 0);
DELAY_RENDER_THREAD_US("delay_game_render_thread_us", Settings.SECTION_RENDERER, 0),
USE_ARTIC_BASE_CONTROLLER("use_artic_base_controller", Settings.SECTION_CONTROLS, 0);

override var int: Int = defaultValue

Expand Down Expand Up @@ -69,7 +70,8 @@ enum class IntSetting(
DEBUG_RENDERER,
CPU_JIT,
ASYNC_CUSTOM_LOADING,
AUDIO_INPUT_TYPE
AUDIO_INPUT_TYPE,
USE_ARTIC_BASE_CONTROLLER
)

fun from(key: String): IntSetting? = IntSetting.values().firstOrNull { it.key == key }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,16 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
val button = getInputObject(key)
add(InputBindingSetting(button, Settings.hotkeyTitles[i]))
}
add(HeaderSetting(R.string.miscellaneous))
add(
SwitchSetting(
IntSetting.USE_ARTIC_BASE_CONTROLLER,
R.string.use_artic_base_controller,
R.string.use_artic_base_controller_desc,
IntSetting.USE_ARTIC_BASE_CONTROLLER.key,
IntSetting.USE_ARTIC_BASE_CONTROLLER.defaultValue
)
)
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/android/app/src/main/jni/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ void Config::ReadValues() {
static_cast<u16>(sdl2_config->GetInteger("Controls", "udp_input_port",
InputCommon::CemuhookUDP::DEFAULT_PORT));

ReadSetting("Controls", Settings::values.use_artic_base_controller);

// Core
ReadSetting("Core", Settings::values.use_cpu_jit);
ReadSetting("Core", Settings::values.cpu_clock_percentage);
Expand Down
3 changes: 3 additions & 0 deletions src/android/app/src/main/jni/default_ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ udp_input_port=
# The pad to request data on. Should be between 0 (Pad 1) and 3 (Pad 4). (Default 0)
udp_pad_index=
# Use Artic Controller when connected to Artic Base Server. (Default 0)
use_artic_base_controller=
[Core]
# Whether to use the Just-In-Time (JIT) compiler for CPU emulation
# 0: Interpreter (slow), 1 (default): JIT (fast)
Expand Down
3 changes: 3 additions & 0 deletions src/android/app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -665,5 +665,8 @@ Se esperan fallos gráficos temporales cuando ésta esté activado.</string>
<string name="artic_base_enter_address">Introduce la dirección del servidor Artic Base</string>
<string name="delay_render_thread">Retrasa el hilo de dibujado del juego</string>
<string name="delay_render_thread_description">Retrasa el hilo de dibujado del juego cuando envía datos a la GPU. Ayuda con problemas de rendimiento en los (muy pocos) juegos de fps dinámicos.</string>
<string name="miscellaneous">Misceláneo</string>
<string name="use_artic_base_controller">Usar Artic Controller cuando se está conectado a Artic Base Server</string>
<string name="use_artic_base_controller_desc">Usa los controles proporcionados por Artic Base Server cuando esté conectado a él en lugar del dispositivo de entrada configurado.</string>

</resources>
3 changes: 3 additions & 0 deletions src/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,8 @@
<string name="quicksave_saving">Saving…</string>
<string name="quickload_loading">Loading…</string>
<string name="quickload_not_found">No Quicksave available.</string>
<string name="miscellaneous">Miscellaneous</string>
<string name="use_artic_base_controller">Use Artic Controller when connected to Artic Base Server</string>
<string name="use_artic_base_controller_desc">Use the controls provided by Artic Base Server when connected to it instead of the configured input device.</string>

</resources>
4 changes: 4 additions & 0 deletions src/citra_qt/configuration/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ void Config::ReadCameraValues() {
void Config::ReadControlValues() {
qt_config->beginGroup(QStringLiteral("Controls"));

ReadBasicSetting(Settings::values.use_artic_base_controller);

int num_touch_from_button_maps =
qt_config->beginReadArray(QStringLiteral("touch_from_button_maps"));

Expand Down Expand Up @@ -924,6 +926,8 @@ void Config::SaveCameraValues() {
void Config::SaveControlValues() {
qt_config->beginGroup(QStringLiteral("Controls"));

WriteBasicSetting(Settings::values.use_artic_base_controller);

WriteSetting(QStringLiteral("profile"), Settings::values.current_input_profile_index, 0);
qt_config->beginWriteArray(QStringLiteral("profiles"));
for (std::size_t p = 0; p < Settings::values.input_profiles.size(); ++p) {
Expand Down
2 changes: 1 addition & 1 deletion src/citra_qt/configuration/configure_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, Cor
system{system_}, is_powered_on{system.IsPoweredOn()},
general_tab{std::make_unique<ConfigureGeneral>(this)},
system_tab{std::make_unique<ConfigureSystem>(system, this)},
input_tab{std::make_unique<ConfigureInput>(this)},
input_tab{std::make_unique<ConfigureInput>(system, this)},
hotkeys_tab{std::make_unique<ConfigureHotkeys>(this)},
graphics_tab{
std::make_unique<ConfigureGraphics>(gl_renderer, physical_devices, is_powered_on, this)},
Expand Down
12 changes: 10 additions & 2 deletions src/citra_qt/configuration/configure_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "citra_qt/configuration/configure_input.h"
#include "citra_qt/configuration/configure_motion_touch.h"
#include "common/param_package.h"
#include "core/core.h"
#include "ui_configure_input.h"

const std::array<std::string, ConfigureInput::ANALOG_SUB_BUTTONS_NUM>
Expand Down Expand Up @@ -145,8 +146,8 @@ static QString AnalogToText(const Common::ParamPackage& param, const std::string
return QObject::tr("[unknown]");
}

ConfigureInput::ConfigureInput(QWidget* parent)
: QWidget(parent), ui(std::make_unique<Ui::ConfigureInput>()),
ConfigureInput::ConfigureInput(Core::System& _system, QWidget* parent)
: QWidget(parent), system(_system), ui(std::make_unique<Ui::ConfigureInput>()),
timeout_timer(std::make_unique<QTimer>()), poll_timer(std::make_unique<QTimer>()) {
ui->setupUi(this);
setFocusPolicy(Qt::ClickFocus);
Expand Down Expand Up @@ -400,6 +401,9 @@ ConfigureInput::ConfigureInput(QWidget* parent)
ConfigureInput::~ConfigureInput() = default;

void ConfigureInput::ApplyConfiguration() {

Settings::values.use_artic_base_controller = ui->use_artic_controller->isChecked();

std::transform(buttons_param.begin(), buttons_param.end(),
Settings::values.current_input_profile.buttons.begin(),
[](const Common::ParamPackage& param) { return param.Serialize(); });
Expand Down Expand Up @@ -444,6 +448,10 @@ QList<QKeySequence> ConfigureInput::GetUsedKeyboardKeys() {
}

void ConfigureInput::LoadConfiguration() {

ui->use_artic_controller->setChecked(Settings::values.use_artic_base_controller.GetValue());
ui->use_artic_controller->setEnabled(!system.IsPoweredOn());

std::transform(Settings::values.current_input_profile.buttons.begin(),
Settings::values.current_input_profile.buttons.end(), buttons_param.begin(),
[](const std::string& str) { return Common::ParamPackage(str); });
Expand Down
3 changes: 2 additions & 1 deletion src/citra_qt/configuration/configure_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ConfigureInput : public QWidget {
Q_OBJECT

public:
explicit ConfigureInput(QWidget* parent = nullptr);
explicit ConfigureInput(Core::System& system, QWidget* parent = nullptr);
~ConfigureInput() override;

/// Save all button configurations to settings file
Expand All @@ -50,6 +50,7 @@ public slots:
void InputKeysChanged(QList<QKeySequence> new_key_list);

private:
Core::System& system;
std::unique_ptr<Ui::ConfigureInput> ui;

std::unique_ptr<QTimer> timeout_timer;
Expand Down
7 changes: 7 additions & 0 deletions src/citra_qt/configuration/configure_input.ui
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,13 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="use_artic_controller">
<property name="text">
<string>Use Artic Controller when connected to Artic Base Server</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down
1 change: 1 addition & 0 deletions src/common/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void LogSettings() {
LOG_INFO(Config, "Citra Configuration:");
log_setting("Core_UseCpuJit", values.use_cpu_jit.GetValue());
log_setting("Core_CPUClockPercentage", values.cpu_clock_percentage.GetValue());
log_setting("Controller_UseArticController", values.use_artic_base_controller.GetValue());
log_setting("Renderer_UseGLES", values.use_gles.GetValue());
log_setting("Renderer_GraphicsAPI", GetGraphicsAPIName(values.graphics_api.GetValue()));
log_setting("Renderer_AsyncShaders", values.async_shader_compilation.GetValue());
Expand Down
1 change: 1 addition & 0 deletions src/common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ struct Values {
int current_input_profile_index; ///< The current input profile index
std::vector<InputProfile> input_profiles; ///< The list of input profiles
std::vector<TouchFromButtonMap> touch_from_button_maps;
Setting<bool> use_artic_base_controller{false, "use_artic_base_controller"};

SwitchableSetting<bool> enable_gamemode{true, "enable_gamemode"};

Expand Down
Loading

0 comments on commit 55748d7

Please sign in to comment.