summaryrefslogtreecommitdiff
path: root/src/citra
diff options
context:
space:
mode:
authorGravatar bunnei2017-01-07 12:39:20 -0500
committerGravatar GitHub2017-01-07 12:39:20 -0500
commit7cfe3ef0463ace034b1e5786c9581cfa5f2e810c (patch)
tree6b06cb03d276b29070ca29599fc4c5fcf77edb39 /src/citra
parentMerge pull request #2410 from Subv/sleepthread (diff)
parentFrontend: make motion sensor interfaced thread-safe (diff)
downloadyuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.gz
yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.xz
yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.zip
Merge pull request #1951 from wwylele/motion-sensor
Emulate motion sensor in frontend
Diffstat (limited to 'src/citra')
-rw-r--r--src/citra/emu_window/emu_window_sdl2.cpp22
-rw-r--r--src/citra/emu_window/emu_window_sdl2.h5
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 @@
19 19
20void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { 20void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
21 TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); 21 TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0));
22 motion_emu->Tilt(x, y);
22} 23}
23 24
24void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { 25void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) {
25 if (button != SDL_BUTTON_LEFT) 26 if (button == SDL_BUTTON_LEFT) {
26 return; 27 if (state == SDL_PRESSED) {
27 28 TouchPressed((unsigned)std::max(x, 0), (unsigned)std::max(y, 0));
28 if (state == SDL_PRESSED) { 29 } else {
29 TouchPressed((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); 30 TouchReleased();
30 } else { 31 }
31 TouchReleased(); 32 } else if (button == SDL_BUTTON_RIGHT) {
33 if (state == SDL_PRESSED) {
34 motion_emu->BeginTilt(x, y);
35 } else {
36 motion_emu->EndTilt();
37 }
32 } 38 }
33} 39}
34 40
@@ -54,6 +60,7 @@ EmuWindow_SDL2::EmuWindow_SDL2() {
54 keyboard_id = KeyMap::NewDeviceId(); 60 keyboard_id = KeyMap::NewDeviceId();
55 61
56 ReloadSetKeymaps(); 62 ReloadSetKeymaps();
63 motion_emu = std::make_unique<Motion::MotionEmu>(*this);
57 64
58 SDL_SetMainReady(); 65 SDL_SetMainReady();
59 66
@@ -109,6 +116,7 @@ EmuWindow_SDL2::EmuWindow_SDL2() {
109EmuWindow_SDL2::~EmuWindow_SDL2() { 116EmuWindow_SDL2::~EmuWindow_SDL2() {
110 SDL_GL_DeleteContext(gl_context); 117 SDL_GL_DeleteContext(gl_context);
111 SDL_Quit(); 118 SDL_Quit();
119 motion_emu = nullptr;
112} 120}
113 121
114void EmuWindow_SDL2::SwapBuffers() { 122void 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 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
7#include <utility> 8#include <utility>
8#include "core/frontend/emu_window.h" 9#include "core/frontend/emu_window.h"
10#include "core/frontend/motion_emu.h"
9 11
10struct SDL_Window; 12struct SDL_Window;
11 13
@@ -61,4 +63,7 @@ private:
61 63
62 /// Device id of keyboard for use with KeyMap 64 /// Device id of keyboard for use with KeyMap
63 int keyboard_id; 65 int keyboard_id;
66
67 /// Motion sensors emulation
68 std::unique_ptr<Motion::MotionEmu> motion_emu;
64}; 69};