diff options
| author | 2016-05-13 18:32:43 +0300 | |
|---|---|---|
| committer | 2016-05-15 13:24:22 +0300 | |
| commit | 416faa20d1156ac4e8646710e9c1f9565c0ed14b (patch) | |
| tree | 8bc07be0343eea7f028c9a6ba52fee55d5ba0f1f /src/common/key_map.cpp | |
| parent | Refactor input subsystem (diff) | |
| download | yuzu-416faa20d1156ac4e8646710e9c1f9565c0ed14b.tar.gz yuzu-416faa20d1156ac4e8646710e9c1f9565c0ed14b.tar.xz yuzu-416faa20d1156ac4e8646710e9c1f9565c0ed14b.zip | |
implement circle pad modifier
Diffstat (limited to 'src/common/key_map.cpp')
| -rw-r--r-- | src/common/key_map.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
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 | ||
| 28 | static std::map<HostDeviceKey, KeyTarget> key_map; | 29 | static std::map<HostDeviceKey, KeyTarget> key_map; |
| 29 | static int next_device_id = 0; | 30 | static int next_device_id = 0; |
| 30 | 31 | ||
| 31 | static bool circle_pad_up = false, circle_pad_down = false, circle_pad_left = false, circle_pad_right = false; | 32 | static bool circle_pad_up = false; |
| 33 | static bool circle_pad_down = false; | ||
| 34 | static bool circle_pad_left = false; | ||
| 35 | static bool circle_pad_right = false; | ||
| 36 | static bool circle_pad_modifier = false; | ||
| 32 | 37 | ||
| 33 | static void UpdateCirclePad(EmuWindow& emu_window) { | 38 | static 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 | ||
| 49 | int NewDeviceId() { | 55 | int 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 | } |