summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar wwylele2016-05-13 18:32:43 +0300
committerGravatar wwylele2016-05-15 13:24:22 +0300
commit416faa20d1156ac4e8646710e9c1f9565c0ed14b (patch)
tree8bc07be0343eea7f028c9a6ba52fee55d5ba0f1f /src
parentRefactor input subsystem (diff)
downloadyuzu-416faa20d1156ac4e8646710e9c1f9565c0ed14b.tar.gz
yuzu-416faa20d1156ac4e8646710e9c1f9565c0ed14b.tar.xz
yuzu-416faa20d1156ac4e8646710e9c1f9565c0ed14b.zip
implement circle pad modifier
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 = {
53 53
54 // indirectly mapped keys 54 // indirectly mapped keys
55 SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, 55 SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT,
56 SDL_SCANCODE_D,
56}; 57};
57 58
58void Config::ReadValues() { 59void Config::ReadValues() {
@@ -61,6 +62,7 @@ void Config::ReadValues() {
61 Settings::values.input_mappings[Settings::NativeInput::All[i]] = 62 Settings::values.input_mappings[Settings::NativeInput::All[i]] =
62 sdl2_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]); 63 sdl2_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]);
63 } 64 }
65 Settings::values.pad_circle_modifier_scale = (float)sdl2_config->GetReal("Controls", "pad_circle_modifier_scale", 0.5);
64 66
65 // Core 67 // Core
66 Settings::values.frame_skip = sdl2_config->GetInteger("Core", "frame_skip", 0); 68 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 =
31pad_circle_down = 31pad_circle_down =
32pad_circle_left = 32pad_circle_left =
33pad_circle_right = 33pad_circle_right =
34pad_circle_modifier =
35
36# The applied modifier scale to circle pad.
37# Must be in range of 0.0-1.0. Defaults to 0.5
38pad_circle_modifier_scale =
34 39
35[Core] 40[Core]
36# The applied frameskip amount. Must be a power of two. 41# 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 =
31 31
32 // indirectly mapped keys 32 // indirectly mapped keys
33 Qt::Key_Up, Qt::Key_Down, Qt::Key_Left, Qt::Key_Right, 33 Qt::Key_Up, Qt::Key_Down, Qt::Key_Left, Qt::Key_Right,
34 Qt::Key_D,
34}; 35};
35 36
36void Config::ReadValues() { 37void Config::ReadValues() {
@@ -39,6 +40,7 @@ void Config::ReadValues() {
39 Settings::values.input_mappings[Settings::NativeInput::All[i]] = 40 Settings::values.input_mappings[Settings::NativeInput::All[i]] =
40 qt_config->value(QString::fromStdString(Settings::NativeInput::Mapping[i]), defaults[i]).toInt(); 41 qt_config->value(QString::fromStdString(Settings::NativeInput::Mapping[i]), defaults[i]).toInt();
41 } 42 }
43 Settings::values.pad_circle_modifier_scale = qt_config->value("pad_circle_modifier_scale", 0.5).toFloat();
42 qt_config->endGroup(); 44 qt_config->endGroup();
43 45
44 qt_config->beginGroup("Core"); 46 qt_config->beginGroup("Core");
@@ -128,6 +130,7 @@ void Config::SaveValues() {
128 qt_config->setValue(QString::fromStdString(Settings::NativeInput::Mapping[i]), 130 qt_config->setValue(QString::fromStdString(Settings::NativeInput::Mapping[i]),
129 Settings::values.input_mappings[Settings::NativeInput::All[i]]); 131 Settings::values.input_mappings[Settings::NativeInput::All[i]]);
130 } 132 }
133 qt_config->setValue("pad_circle_modifier_scale", (double)Settings::values.pad_circle_modifier_scale);
131 qt_config->endGroup(); 134 qt_config->endGroup();
132 135
133 qt_config->beginGroup("Core"); 136 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 =
23 IndirectTarget::CIRCLE_PAD_DOWN, 23 IndirectTarget::CIRCLE_PAD_DOWN,
24 IndirectTarget::CIRCLE_PAD_LEFT, 24 IndirectTarget::CIRCLE_PAD_LEFT,
25 IndirectTarget::CIRCLE_PAD_RIGHT, 25 IndirectTarget::CIRCLE_PAD_RIGHT,
26 IndirectTarget::CIRCLE_PAD_MODIFIER,
26}}; 27}};
27 28
28static std::map<HostDeviceKey, KeyTarget> key_map; 29static std::map<HostDeviceKey, KeyTarget> key_map;
29static int next_device_id = 0; 30static int next_device_id = 0;
30 31
31static bool circle_pad_up = false, circle_pad_down = false, circle_pad_left = false, circle_pad_right = false; 32static bool circle_pad_up = false;
33static bool circle_pad_down = false;
34static bool circle_pad_left = false;
35static bool circle_pad_right = false;
36static bool circle_pad_modifier = false;
32 37
33static void UpdateCirclePad(EmuWindow& emu_window) { 38static void UpdateCirclePad(EmuWindow& emu_window) {
34 constexpr float SQRT_HALF = 0.707106781; 39 constexpr float SQRT_HALF = 0.707106781;
@@ -42,8 +47,9 @@ static void UpdateCirclePad(EmuWindow& emu_window) {
42 ++y; 47 ++y;
43 if (circle_pad_down) 48 if (circle_pad_down)
44 --y; 49 --y;
45 // TODO: apply modifier here 50
46 emu_window.CirclePadUpdated(x * (y == 0 ? 1.0 : SQRT_HALF), y * (x == 0 ? 1.0 : SQRT_HALF)); 51 float modifier = circle_pad_modifier ? Settings::values.pad_circle_modifier_scale : 1.0;
52 emu_window.CirclePadUpdated(x * modifier * (y == 0 ? 1.0 : SQRT_HALF), y * modifier * (x == 0 ? 1.0 : SQRT_HALF));
47} 53}
48 54
49int NewDeviceId() { 55int NewDeviceId() {
@@ -89,6 +95,10 @@ void PressKey(EmuWindow& emu_window, HostDeviceKey key) {
89 circle_pad_right = true; 95 circle_pad_right = true;
90 UpdateCirclePad(emu_window); 96 UpdateCirclePad(emu_window);
91 break; 97 break;
98 case IndirectTarget::CIRCLE_PAD_MODIFIER:
99 circle_pad_modifier = true;
100 UpdateCirclePad(emu_window);
101 break;
92 } 102 }
93 } 103 }
94} 104}
@@ -118,6 +128,10 @@ void ReleaseKey(EmuWindow& emu_window,HostDeviceKey key) {
118 circle_pad_right = false; 128 circle_pad_right = false;
119 UpdateCirclePad(emu_window); 129 UpdateCirclePad(emu_window);
120 break; 130 break;
131 case IndirectTarget::CIRCLE_PAD_MODIFIER:
132 circle_pad_modifier = false;
133 UpdateCirclePad(emu_window);
134 break;
121 } 135 }
122 } 136 }
123} 137}
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;
13namespace KeyMap { 13namespace KeyMap {
14 14
15enum class IndirectTarget { 15enum class IndirectTarget {
16 CIRCLE_PAD_UP, CIRCLE_PAD_DOWN, CIRCLE_PAD_LEFT, CIRCLE_PAD_RIGHT, 16 CIRCLE_PAD_UP,
17 CIRCLE_PAD_DOWN,
18 CIRCLE_PAD_LEFT,
19 CIRCLE_PAD_RIGHT,
20 CIRCLE_PAD_MODIFIER,
17}; 21};
18 22
19/** 23/**
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 {
22 22
23 // indirectly mapped keys 23 // indirectly mapped keys
24 CIRCLE_UP, CIRCLE_DOWN, CIRCLE_LEFT, CIRCLE_RIGHT, 24 CIRCLE_UP, CIRCLE_DOWN, CIRCLE_LEFT, CIRCLE_RIGHT,
25 CIRCLE_MODIFIER,
25 26
26 NUM_INPUTS 27 NUM_INPUTS
27}; 28};
@@ -35,7 +36,8 @@ static const std::array<const char*, NUM_INPUTS> Mapping = {{
35 "pad_cup", "pad_cdown", "pad_cleft", "pad_cright", 36 "pad_cup", "pad_cdown", "pad_cleft", "pad_cright",
36 37
37 // indirectly mapped keys 38 // indirectly mapped keys
38 "pad_circle_up", "pad_circle_down", "pad_circle_left", "pad_circle_right" 39 "pad_circle_up", "pad_circle_down", "pad_circle_left", "pad_circle_right",
40 "pad_circle_modifier",
39}}; 41}};
40static const std::array<Values, NUM_INPUTS> All = {{ 42static const std::array<Values, NUM_INPUTS> All = {{
41 A, B, X, Y, 43 A, B, X, Y,
@@ -44,6 +46,7 @@ static const std::array<Values, NUM_INPUTS> All = {{
44 DUP, DDOWN, DLEFT, DRIGHT, 46 DUP, DDOWN, DLEFT, DRIGHT,
45 CUP, CDOWN, CLEFT, CRIGHT, 47 CUP, CDOWN, CLEFT, CRIGHT,
46 CIRCLE_UP, CIRCLE_DOWN, CIRCLE_LEFT, CIRCLE_RIGHT, 48 CIRCLE_UP, CIRCLE_DOWN, CIRCLE_LEFT, CIRCLE_RIGHT,
49 CIRCLE_MODIFIER,
47}}; 50}};
48} 51}
49 52
@@ -51,6 +54,7 @@ static const std::array<Values, NUM_INPUTS> All = {{
51struct Values { 54struct Values {
52 // Controls 55 // Controls
53 std::array<int, NativeInput::NUM_INPUTS> input_mappings; 56 std::array<int, NativeInput::NUM_INPUTS> input_mappings;
57 float pad_circle_modifier_scale;
54 58
55 // Core 59 // Core
56 int frame_skip; 60 int frame_skip;