summaryrefslogtreecommitdiff
path: root/src/citra
diff options
context:
space:
mode:
authorGravatar James Rowe2017-08-19 23:43:01 -0600
committerGravatar GitHub2017-08-19 23:43:01 -0600
commitbbfa9d0635ce4b9226bed02ea1b6e8ddbb7e8a56 (patch)
tree5bfecf66096077d72346da902a9646314cb60631 /src/citra
parentMerge pull request #2871 from wwylele/sw-spotlight (diff)
parentHID: fix a comment and a warning (diff)
downloadyuzu-bbfa9d0635ce4b9226bed02ea1b6e8ddbb7e8a56.tar.gz
yuzu-bbfa9d0635ce4b9226bed02ea1b6e8ddbb7e8a56.tar.xz
yuzu-bbfa9d0635ce4b9226bed02ea1b6e8ddbb7e8a56.zip
Merge pull request #2861 from wwylele/motion-refactor
Refactor MotionEmu into a InputDevice
Diffstat (limited to 'src/citra')
-rw-r--r--src/citra/config.cpp3
-rw-r--r--src/citra/default_ini.h8
-rw-r--r--src/citra/emu_window/emu_window_sdl2.cpp10
-rw-r--r--src/citra/emu_window/emu_window_sdl2.h4
4 files changed, 14 insertions, 11 deletions
diff --git a/src/citra/config.cpp b/src/citra/config.cpp
index 69247b166..73846ed91 100644
--- a/src/citra/config.cpp
+++ b/src/citra/config.cpp
@@ -76,6 +76,9 @@ void Config::ReadValues() {
76 Settings::values.analogs[i] = default_param; 76 Settings::values.analogs[i] = default_param;
77 } 77 }
78 78
79 Settings::values.motion_device = sdl2_config->Get(
80 "Controls", "motion_device", "engine:motion_emu,update_period:100,sensitivity:0.01");
81
79 // Core 82 // Core
80 Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true); 83 Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true);
81 84
diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h
index b0a0ebd3b..9ea779dd8 100644
--- a/src/citra/default_ini.h
+++ b/src/citra/default_ini.h
@@ -43,7 +43,7 @@ button_zr=
43button_home= 43button_home=
44 44
45# for analog input, the following devices are available: 45# for analog input, the following devices are available:
46# - "analog_from_button" (default) for emulating analog input from direction buttons. Required parameters: 46# - "analog_from_button" (default) for emulating analog input from direction buttons. Required parameters:
47# - "up", "down", "left", "right": sub-devices for each direction. 47# - "up", "down", "left", "right": sub-devices for each direction.
48# Should be in the format as a button input devices using escape characters, for example, "engine$0keyboard$1code$00" 48# Should be in the format as a button input devices using escape characters, for example, "engine$0keyboard$1code$00"
49# - "modifier": sub-devices as a modifier. 49# - "modifier": sub-devices as a modifier.
@@ -56,6 +56,12 @@ button_home=
56circle_pad= 56circle_pad=
57c_stick= 57c_stick=
58 58
59# for motion input, the following devices are available:
60# - "motion_emu" (default) for emulating motion input from mouse input. Required parameters:
61# - "update_period": update period in milliseconds (default to 100)
62# - "sensitivity": the coefficient converting mouse movement to tilting angle (default to 0.01)
63motion_device=
64
59[Core] 65[Core]
60# Whether to use the Just-In-Time (JIT) compiler for CPU emulation 66# Whether to use the Just-In-Time (JIT) compiler for CPU emulation
61# 0: Interpreter (slow), 1 (default): JIT (fast) 67# 0: Interpreter (slow), 1 (default): JIT (fast)
diff --git a/src/citra/emu_window/emu_window_sdl2.cpp b/src/citra/emu_window/emu_window_sdl2.cpp
index b0f808399..25643715a 100644
--- a/src/citra/emu_window/emu_window_sdl2.cpp
+++ b/src/citra/emu_window/emu_window_sdl2.cpp
@@ -16,11 +16,12 @@
16#include "core/settings.h" 16#include "core/settings.h"
17#include "input_common/keyboard.h" 17#include "input_common/keyboard.h"
18#include "input_common/main.h" 18#include "input_common/main.h"
19#include "input_common/motion_emu.h"
19#include "network/network.h" 20#include "network/network.h"
20 21
21void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { 22void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
22 TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); 23 TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0));
23 motion_emu->Tilt(x, y); 24 InputCommon::GetMotionEmu()->Tilt(x, y);
24} 25}
25 26
26void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { 27void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) {
@@ -32,9 +33,9 @@ void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) {
32 } 33 }
33 } else if (button == SDL_BUTTON_RIGHT) { 34 } else if (button == SDL_BUTTON_RIGHT) {
34 if (state == SDL_PRESSED) { 35 if (state == SDL_PRESSED) {
35 motion_emu->BeginTilt(x, y); 36 InputCommon::GetMotionEmu()->BeginTilt(x, y);
36 } else { 37 } else {
37 motion_emu->EndTilt(); 38 InputCommon::GetMotionEmu()->EndTilt();
38 } 39 }
39 } 40 }
40} 41}
@@ -61,8 +62,6 @@ EmuWindow_SDL2::EmuWindow_SDL2() {
61 InputCommon::Init(); 62 InputCommon::Init();
62 Network::Init(); 63 Network::Init();
63 64
64 motion_emu = std::make_unique<Motion::MotionEmu>(*this);
65
66 SDL_SetMainReady(); 65 SDL_SetMainReady();
67 66
68 // Initialize the window 67 // Initialize the window
@@ -117,7 +116,6 @@ EmuWindow_SDL2::EmuWindow_SDL2() {
117EmuWindow_SDL2::~EmuWindow_SDL2() { 116EmuWindow_SDL2::~EmuWindow_SDL2() {
118 SDL_GL_DeleteContext(gl_context); 117 SDL_GL_DeleteContext(gl_context);
119 SDL_Quit(); 118 SDL_Quit();
120 motion_emu = nullptr;
121 119
122 Network::Shutdown(); 120 Network::Shutdown();
123 InputCommon::Shutdown(); 121 InputCommon::Shutdown();
diff --git a/src/citra/emu_window/emu_window_sdl2.h b/src/citra/emu_window/emu_window_sdl2.h
index 1ce2991f7..3664d2fbe 100644
--- a/src/citra/emu_window/emu_window_sdl2.h
+++ b/src/citra/emu_window/emu_window_sdl2.h
@@ -7,7 +7,6 @@
7#include <memory> 7#include <memory>
8#include <utility> 8#include <utility>
9#include "core/frontend/emu_window.h" 9#include "core/frontend/emu_window.h"
10#include "core/frontend/motion_emu.h"
11 10
12struct SDL_Window; 11struct SDL_Window;
13 12
@@ -57,7 +56,4 @@ private:
57 using SDL_GLContext = void*; 56 using SDL_GLContext = void*;
58 /// The OpenGL context associated with the window 57 /// The OpenGL context associated with the window
59 SDL_GLContext gl_context; 58 SDL_GLContext gl_context;
60
61 /// Motion sensors emulation
62 std::unique_ptr<Motion::MotionEmu> motion_emu;
63}; 59};