diff options
author | bunnei <bunneidev@gmail.com> | 2017-01-07 18:39:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-07 18:39:20 +0100 |
commit | 7cfe3ef0463ace034b1e5786c9581cfa5f2e810c (patch) | |
tree | 6b06cb03d276b29070ca29599fc4c5fcf77edb39 /src/citra/emu_window | |
parent | Merge pull request #2410 from Subv/sleepthread (diff) | |
parent | Frontend: make motion sensor interfaced thread-safe (diff) | |
download | yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.gz yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.bz2 yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.lz yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.xz yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.zst yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/citra/emu_window/emu_window_sdl2.cpp | 22 | ||||
-rw-r--r-- | src/citra/emu_window/emu_window_sdl2.h | 5 |
2 files changed, 20 insertions, 7 deletions
diff --git a/src/citra/emu_window/emu_window_sdl2.cpp b/src/citra/emu_window/emu_window_sdl2.cpp index b0d82b670..81a3abe3f 100644 --- a/src/citra/emu_window/emu_window_sdl2.cpp +++ b/src/citra/emu_window/emu_window_sdl2.cpp @@ -19,16 +19,22 @@ void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); + motion_emu->Tilt(x, y); } void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { - if (button != SDL_BUTTON_LEFT) - return; - - if (state == SDL_PRESSED) { - TouchPressed((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); - } else { - TouchReleased(); + if (button == SDL_BUTTON_LEFT) { + if (state == SDL_PRESSED) { + TouchPressed((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); + } else { + TouchReleased(); + } + } else if (button == SDL_BUTTON_RIGHT) { + if (state == SDL_PRESSED) { + motion_emu->BeginTilt(x, y); + } else { + motion_emu->EndTilt(); + } } } @@ -54,6 +60,7 @@ EmuWindow_SDL2::EmuWindow_SDL2() { keyboard_id = KeyMap::NewDeviceId(); ReloadSetKeymaps(); + motion_emu = std::make_unique<Motion::MotionEmu>(*this); SDL_SetMainReady(); @@ -109,6 +116,7 @@ EmuWindow_SDL2::EmuWindow_SDL2() { EmuWindow_SDL2::~EmuWindow_SDL2() { SDL_GL_DeleteContext(gl_context); SDL_Quit(); + motion_emu = nullptr; } void EmuWindow_SDL2::SwapBuffers() { diff --git a/src/citra/emu_window/emu_window_sdl2.h b/src/citra/emu_window/emu_window_sdl2.h index c8cd919c6..b1cbf16d7 100644 --- a/src/citra/emu_window/emu_window_sdl2.h +++ b/src/citra/emu_window/emu_window_sdl2.h @@ -4,8 +4,10 @@ #pragma once +#include <memory> #include <utility> #include "core/frontend/emu_window.h" +#include "core/frontend/motion_emu.h" struct SDL_Window; @@ -61,4 +63,7 @@ private: /// Device id of keyboard for use with KeyMap int keyboard_id; + + /// Motion sensors emulation + std::unique_ptr<Motion::MotionEmu> motion_emu; }; |