move MotionEmu from core/frontend to input_common as a InputDevice
This commit is contained in:
		| @@ -76,6 +76,9 @@ void Config::ReadValues() { | ||||
|             Settings::values.analogs[i] = default_param; | ||||
|     } | ||||
|  | ||||
|     Settings::values.motion_device = sdl2_config->Get( | ||||
|         "Controls", "motion_device", "engine:motion_emu,update_period:100,sensitivity:0.01"); | ||||
|  | ||||
|     // Core | ||||
|     Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true); | ||||
|  | ||||
|   | ||||
| @@ -43,7 +43,7 @@ button_zr= | ||||
| button_home= | ||||
|  | ||||
| # for analog input, the following devices are available: | ||||
| #  - "analog_from_button" (default) for emulating analog input from direction buttons.  Required parameters: | ||||
| #  - "analog_from_button" (default) for emulating analog input from direction buttons. Required parameters: | ||||
| #      - "up", "down", "left", "right": sub-devices for each direction. | ||||
| #          Should be in the format as a button input devices using escape characters, for example, "engine$0keyboard$1code$00" | ||||
| #      - "modifier": sub-devices as a modifier. | ||||
| @@ -56,6 +56,12 @@ button_home= | ||||
| circle_pad= | ||||
| c_stick= | ||||
|  | ||||
| # for motion input, the following devices are available: | ||||
| #  - "motion_emu" (default) for emulating motion input from mouse input. Required parameters: | ||||
| #      - "update_period": update period in milliseconds (default to 100) | ||||
| #      - "sensitivity": the coefficient converting mouse movement to tilting angle (default to 0.01) | ||||
| motion_device= | ||||
|  | ||||
| [Core] | ||||
| # Whether to use the Just-In-Time (JIT) compiler for CPU emulation | ||||
| # 0: Interpreter (slow), 1 (default): JIT (fast) | ||||
|   | ||||
| @@ -16,11 +16,12 @@ | ||||
| #include "core/settings.h" | ||||
| #include "input_common/keyboard.h" | ||||
| #include "input_common/main.h" | ||||
| #include "input_common/motion_emu.h" | ||||
| #include "network/network.h" | ||||
|  | ||||
| void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { | ||||
|     TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); | ||||
|     motion_emu->Tilt(x, y); | ||||
|     InputCommon::GetMotionEmu()->Tilt(x, y); | ||||
| } | ||||
|  | ||||
| void 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) { | ||||
|         } | ||||
|     } else if (button == SDL_BUTTON_RIGHT) { | ||||
|         if (state == SDL_PRESSED) { | ||||
|             motion_emu->BeginTilt(x, y); | ||||
|             InputCommon::GetMotionEmu()->BeginTilt(x, y); | ||||
|         } else { | ||||
|             motion_emu->EndTilt(); | ||||
|             InputCommon::GetMotionEmu()->EndTilt(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -61,8 +62,6 @@ EmuWindow_SDL2::EmuWindow_SDL2() { | ||||
|     InputCommon::Init(); | ||||
|     Network::Init(); | ||||
|  | ||||
|     motion_emu = std::make_unique<Motion::MotionEmu>(*this); | ||||
|  | ||||
|     SDL_SetMainReady(); | ||||
|  | ||||
|     // Initialize the window | ||||
| @@ -117,7 +116,6 @@ EmuWindow_SDL2::EmuWindow_SDL2() { | ||||
| EmuWindow_SDL2::~EmuWindow_SDL2() { | ||||
|     SDL_GL_DeleteContext(gl_context); | ||||
|     SDL_Quit(); | ||||
|     motion_emu = nullptr; | ||||
|  | ||||
|     Network::Shutdown(); | ||||
|     InputCommon::Shutdown(); | ||||
|   | ||||
| @@ -7,7 +7,6 @@ | ||||
| #include <memory> | ||||
| #include <utility> | ||||
| #include "core/frontend/emu_window.h" | ||||
| #include "core/frontend/motion_emu.h" | ||||
|  | ||||
| struct SDL_Window; | ||||
|  | ||||
| @@ -57,7 +56,4 @@ private: | ||||
|     using SDL_GLContext = void*; | ||||
|     /// The OpenGL context associated with the window | ||||
|     SDL_GLContext gl_context; | ||||
|  | ||||
|     /// Motion sensors emulation | ||||
|     std::unique_ptr<Motion::MotionEmu> motion_emu; | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 wwylele
					wwylele