summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwwylele <wwylele@gmail.com>2016-05-13 17:32:43 +0200
committerwwylele <wwylele@gmail.com>2016-05-15 12:24:22 +0200
commit416faa20d1156ac4e8646710e9c1f9565c0ed14b (patch)
tree8bc07be0343eea7f028c9a6ba52fee55d5ba0f1f /src
parentRefactor input subsystem (diff)
downloadyuzu-416faa20d1156ac4e8646710e9c1f9565c0ed14b.tar
yuzu-416faa20d1156ac4e8646710e9c1f9565c0ed14b.tar.gz
yuzu-416faa20d1156ac4e8646710e9c1f9565c0ed14b.tar.bz2
yuzu-416faa20d1156ac4e8646710e9c1f9565c0ed14b.tar.lz
yuzu-416faa20d1156ac4e8646710e9c1f9565c0ed14b.tar.xz
yuzu-416faa20d1156ac4e8646710e9c1f9565c0ed14b.tar.zst
yuzu-416faa20d1156ac4e8646710e9c1f9565c0ed14b.zip
Diffstat (limited to 'src')
-rw-r--r--src/citra/config.cpp2
-rw-r--r--src/citra/default_ini.h5
-rw-r--r--src/citra_qt/config.cpp3
-rw-r--r--src/common/key_map.cpp20
-rw-r--r--src/common/key_map.h6
-rw-r--r--src/core/settings.h6
6 files changed, 37 insertions, 5 deletions
diff --git a/src/citra/config.cpp b/src/citra/config.cpp
index 4f6d0a464..fb8dd9ba3 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 d0b258cab..a9017dcb3 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 ebee8c821..539fafb6f 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 c8f168aa1..61572cde6 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 0438a14e0..ec371bdde 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 df5915442..d6f8f2ff3 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;