diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 4f6d0a464402ae27925d11fbd3ba97c68ecb0aea..fb8dd9ba3dccb6163583244f0498bb446f518dd6 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -53,6 +53,7 @@ static const std::array<int, Settings::NativeInput::NUM_INPUTS> defaults = { // indirectly mapped keys SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, + SDL_SCANCODE_D, }; void Config::ReadValues() { @@ -61,6 +62,7 @@ void Config::ReadValues() { Settings::values.input_mappings[Settings::NativeInput::All[i]] = sdl2_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]); } + Settings::values.pad_circle_modifier_scale = (float)sdl2_config->GetReal("Controls", "pad_circle_modifier_scale", 0.5); // Core Settings::values.frame_skip = sdl2_config->GetInteger("Core", "frame_skip", 0); diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index d0b258cab7e84fca1795bd15146d82ac476e231d..a9017dcb3e161142445ae37d1e38a7f8e1aa00dd 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h @@ -31,6 +31,11 @@ pad_circle_up = pad_circle_down = pad_circle_left = pad_circle_right = +pad_circle_modifier = + +# The applied modifier scale to circle pad. +# Must be in range of 0.0-1.0. Defaults to 0.5 +pad_circle_modifier_scale = [Core] # The applied frameskip amount. Must be a power of two. diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp index ebee8c821d3dfd43b5daf43c6a17abe00fe44997..539fafb6f1e86c72e98f3fc5d1be31968eda40fe 100644 --- a/src/citra_qt/config.cpp +++ b/src/citra_qt/config.cpp @@ -31,6 +31,7 @@ static const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> defaults = // indirectly mapped keys Qt::Key_Up, Qt::Key_Down, Qt::Key_Left, Qt::Key_Right, + Qt::Key_D, }; void Config::ReadValues() { @@ -39,6 +40,7 @@ void Config::ReadValues() { Settings::values.input_mappings[Settings::NativeInput::All[i]] = qt_config->value(QString::fromStdString(Settings::NativeInput::Mapping[i]), defaults[i]).toInt(); } + Settings::values.pad_circle_modifier_scale = qt_config->value("pad_circle_modifier_scale", 0.5).toFloat(); qt_config->endGroup(); qt_config->beginGroup("Core"); @@ -128,6 +130,7 @@ void Config::SaveValues() { qt_config->setValue(QString::fromStdString(Settings::NativeInput::Mapping[i]), Settings::values.input_mappings[Settings::NativeInput::All[i]]); } + qt_config->setValue("pad_circle_modifier_scale", (double)Settings::values.pad_circle_modifier_scale); qt_config->endGroup(); qt_config->beginGroup("Core"); diff --git a/src/common/key_map.cpp b/src/common/key_map.cpp index c8f168aa114c65e94b0957830fce7123fbb10ea9..61572cde628095e1d238d7d14a4e3edde9ab4cbd 100644 --- a/src/common/key_map.cpp +++ b/src/common/key_map.cpp @@ -23,12 +23,17 @@ const std::array<KeyTarget, Settings::NativeInput::NUM_INPUTS> mapping_targets = IndirectTarget::CIRCLE_PAD_DOWN, IndirectTarget::CIRCLE_PAD_LEFT, IndirectTarget::CIRCLE_PAD_RIGHT, + IndirectTarget::CIRCLE_PAD_MODIFIER, }}; static std::map<HostDeviceKey, KeyTarget> key_map; static int next_device_id = 0; -static bool circle_pad_up = false, circle_pad_down = false, circle_pad_left = false, circle_pad_right = false; +static bool circle_pad_up = false; +static bool circle_pad_down = false; +static bool circle_pad_left = false; +static bool circle_pad_right = false; +static bool circle_pad_modifier = false; static void UpdateCirclePad(EmuWindow& emu_window) { constexpr float SQRT_HALF = 0.707106781; @@ -42,8 +47,9 @@ static void UpdateCirclePad(EmuWindow& emu_window) { ++y; if (circle_pad_down) --y; - // TODO: apply modifier here - emu_window.CirclePadUpdated(x * (y == 0 ? 1.0 : SQRT_HALF), y * (x == 0 ? 1.0 : SQRT_HALF)); + + float modifier = circle_pad_modifier ? Settings::values.pad_circle_modifier_scale : 1.0; + emu_window.CirclePadUpdated(x * modifier * (y == 0 ? 1.0 : SQRT_HALF), y * modifier * (x == 0 ? 1.0 : SQRT_HALF)); } int NewDeviceId() { @@ -89,6 +95,10 @@ void PressKey(EmuWindow& emu_window, HostDeviceKey key) { circle_pad_right = true; UpdateCirclePad(emu_window); break; + case IndirectTarget::CIRCLE_PAD_MODIFIER: + circle_pad_modifier = true; + UpdateCirclePad(emu_window); + break; } } } @@ -118,6 +128,10 @@ void ReleaseKey(EmuWindow& emu_window,HostDeviceKey key) { circle_pad_right = false; UpdateCirclePad(emu_window); break; + case IndirectTarget::CIRCLE_PAD_MODIFIER: + circle_pad_modifier = false; + UpdateCirclePad(emu_window); + break; } } } diff --git a/src/common/key_map.h b/src/common/key_map.h index 0438a14e0bf83e092d2e4a183f5d98ea8a381fca..ec371bdde559475e273b0ae2349e1d96021e9e63 100644 --- a/src/common/key_map.h +++ b/src/common/key_map.h @@ -13,7 +13,11 @@ class EmuWindow; namespace KeyMap { enum class IndirectTarget { - CIRCLE_PAD_UP, CIRCLE_PAD_DOWN, CIRCLE_PAD_LEFT, CIRCLE_PAD_RIGHT, + CIRCLE_PAD_UP, + CIRCLE_PAD_DOWN, + CIRCLE_PAD_LEFT, + CIRCLE_PAD_RIGHT, + CIRCLE_PAD_MODIFIER, }; /** diff --git a/src/core/settings.h b/src/core/settings.h index df591544221177b06fdc5a0041d8a34ddc01e33c..d6f8f2ff3e929dbb549faa849a8a808ed1bc25c4 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -22,6 +22,7 @@ enum Values { // indirectly mapped keys CIRCLE_UP, CIRCLE_DOWN, CIRCLE_LEFT, CIRCLE_RIGHT, + CIRCLE_MODIFIER, NUM_INPUTS }; @@ -35,7 +36,8 @@ static const std::array<const char*, NUM_INPUTS> Mapping = {{ "pad_cup", "pad_cdown", "pad_cleft", "pad_cright", // indirectly mapped keys - "pad_circle_up", "pad_circle_down", "pad_circle_left", "pad_circle_right" + "pad_circle_up", "pad_circle_down", "pad_circle_left", "pad_circle_right", + "pad_circle_modifier", }}; static const std::array<Values, NUM_INPUTS> All = {{ A, B, X, Y, @@ -44,6 +46,7 @@ static const std::array<Values, NUM_INPUTS> All = {{ DUP, DDOWN, DLEFT, DRIGHT, CUP, CDOWN, CLEFT, CRIGHT, CIRCLE_UP, CIRCLE_DOWN, CIRCLE_LEFT, CIRCLE_RIGHT, + CIRCLE_MODIFIER, }}; } @@ -51,6 +54,7 @@ static const std::array<Values, NUM_INPUTS> All = {{ struct Values { // Controls std::array<int, NativeInput::NUM_INPUTS> input_mappings; + float pad_circle_modifier_scale; // Core int frame_skip;