diff options
author | bunnei <bunneidev@gmail.com> | 2016-06-11 04:28:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-11 04:28:58 +0200 |
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 yuzu-f99961581ee129c44625dbd8890fab349253271a.tar.gz yuzu-f99961581ee129c44625dbd8890fab349253271a.tar.bz2 yuzu-f99961581ee129c44625dbd8890fab349253271a.tar.lz yuzu-f99961581ee129c44625dbd8890fab349253271a.tar.xz yuzu-f99961581ee129c44625dbd8890fab349253271a.tar.zst yuzu-f99961581ee129c44625dbd8890fab349253271a.zip |
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 @@ #include "emu_window.h" #include "video_core/video_core.h" -void EmuWindow::KeyPressed(KeyMap::HostDeviceKey key) { - pad_state.hex |= KeyMap::GetPadKey(key).hex; +void EmuWindow::ButtonPressed(Service::HID::PadState pad) { + pad_state.hex |= pad.hex; } -void EmuWindow::KeyReleased(KeyMap::HostDeviceKey key) { - pad_state.hex &= ~KeyMap::GetPadKey(key).hex; +void EmuWindow::ButtonReleased(Service::HID::PadState pad) { + pad_state.hex &= ~pad.hex; +} + +void EmuWindow::CirclePadUpdated(float x, float y) { + constexpr int MAX_CIRCLEPAD_POS = 0x9C; // Max value for a circle pad position + + // Make sure the coordinates are in the unit circle, + // otherwise normalize it. + float r = x * x + y * y; + if (r > 1) { + r = std::sqrt(r); + x /= r; + y /= r; + } + + circle_pad_x = static_cast<s16>(x * MAX_CIRCLEPAD_POS); + circle_pad_y = static_cast<s16>(y * MAX_CIRCLEPAD_POS); } /** |