summaryrefslogtreecommitdiffstats
path: root/src/common/emu_window.cpp
diff options
context:
space:
mode:
authorwwylele <wwylele@gmail.com>2016-05-12 12:09:36 +0200
committerwwylele <wwylele@gmail.com>2016-05-15 12:24:22 +0200
commit03631f9b8fe75cf1c3a70a3094aeddcebffa4cf9 (patch)
tree95edc62b3b8520a533e534bf4991159875fef3e5 /src/common/emu_window.cpp
parentAudioCore: Implement time stretcher (#1737) (diff)
downloadyuzu-03631f9b8fe75cf1c3a70a3094aeddcebffa4cf9.tar
yuzu-03631f9b8fe75cf1c3a70a3094aeddcebffa4cf9.tar.gz
yuzu-03631f9b8fe75cf1c3a70a3094aeddcebffa4cf9.tar.bz2
yuzu-03631f9b8fe75cf1c3a70a3094aeddcebffa4cf9.tar.lz
yuzu-03631f9b8fe75cf1c3a70a3094aeddcebffa4cf9.tar.xz
yuzu-03631f9b8fe75cf1c3a70a3094aeddcebffa4cf9.tar.zst
yuzu-03631f9b8fe75cf1c3a70a3094aeddcebffa4cf9.zip
Diffstat (limited to 'src/common/emu_window.cpp')
-rw-r--r--src/common/emu_window.cpp24
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);
}
/**