diff options
| author | 2016-06-10 22:28:58 -0400 | |
|---|---|---|
| committer | 2016-06-10 22:28:58 -0400 | |
| commit | f99961581ee129c44625dbd8890fab349253271a (patch) | |
| tree | 9a2610d391d795b533054a91c22763e869bdd62b /src/common/emu_window.cpp | |
| parent | Merge pull request #1896 from citra-emu/revert-1893-interpreter-split (diff) | |
| parent | fixup! fixup! Refactor input system (diff) | |
| download | yuzu-f99961581ee129c44625dbd8890fab349253271a.tar.gz yuzu-f99961581ee129c44625dbd8890fab349253271a.tar.xz yuzu-f99961581ee129c44625dbd8890fab349253271a.zip | |
Merge pull request #1789 from wwylele/input-refactor
Refactor input mapping & implement circle pad modifier
Diffstat (limited to 'src/common/emu_window.cpp')
| -rw-r--r-- | src/common/emu_window.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/common/emu_window.cpp b/src/common/emu_window.cpp index b2807354a..08270dd88 100644 --- a/src/common/emu_window.cpp +++ b/src/common/emu_window.cpp | |||
| @@ -11,12 +11,28 @@ | |||
| 11 | #include "emu_window.h" | 11 | #include "emu_window.h" |
| 12 | #include "video_core/video_core.h" | 12 | #include "video_core/video_core.h" |
| 13 | 13 | ||
| 14 | void EmuWindow::KeyPressed(KeyMap::HostDeviceKey key) { | 14 | void EmuWindow::ButtonPressed(Service::HID::PadState pad) { |
| 15 | pad_state.hex |= KeyMap::GetPadKey(key).hex; | 15 | pad_state.hex |= pad.hex; |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | void EmuWindow::KeyReleased(KeyMap::HostDeviceKey key) { | 18 | void EmuWindow::ButtonReleased(Service::HID::PadState pad) { |
| 19 | pad_state.hex &= ~KeyMap::GetPadKey(key).hex; | 19 | pad_state.hex &= ~pad.hex; |
| 20 | } | ||
| 21 | |||
| 22 | void EmuWindow::CirclePadUpdated(float x, float y) { | ||
| 23 | constexpr int MAX_CIRCLEPAD_POS = 0x9C; // Max value for a circle pad position | ||
| 24 | |||
| 25 | // Make sure the coordinates are in the unit circle, | ||
| 26 | // otherwise normalize it. | ||
| 27 | float r = x * x + y * y; | ||
| 28 | if (r > 1) { | ||
| 29 | r = std::sqrt(r); | ||
| 30 | x /= r; | ||
| 31 | y /= r; | ||
| 32 | } | ||
| 33 | |||
| 34 | circle_pad_x = static_cast<s16>(x * MAX_CIRCLEPAD_POS); | ||
| 35 | circle_pad_y = static_cast<s16>(y * MAX_CIRCLEPAD_POS); | ||
| 20 | } | 36 | } |
| 21 | 37 | ||
| 22 | /** | 38 | /** |