diff options
Diffstat (limited to '')
-rw-r--r-- | src/citra/config.cpp | 3 | ||||
-rw-r--r-- | src/citra/default_ini.h | 8 | ||||
-rw-r--r-- | src/citra/emu_window/emu_window_sdl2.cpp | 10 | ||||
-rw-r--r-- | src/citra/emu_window/emu_window_sdl2.h | 4 | ||||
-rw-r--r-- | src/citra_qt/bootmanager.cpp | 10 | ||||
-rw-r--r-- | src/citra_qt/bootmanager.h | 4 | ||||
-rw-r--r-- | src/citra_qt/configuration/config.cpp | 6 |
7 files changed, 24 insertions, 21 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() { 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); 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= 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) 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 @@ #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(); 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 @@ #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; }; diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 30554890f..7107bfc60 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -17,6 +17,7 @@ #include "core/settings.h" #include "input_common/keyboard.h" #include "input_common/main.h" +#include "input_common/motion_emu.h" #include "network/network.h" EmuThread::EmuThread(GRenderWindow* render_window) @@ -201,7 +202,6 @@ qreal GRenderWindow::windowPixelRatio() { } void GRenderWindow::closeEvent(QCloseEvent* event) { - motion_emu = nullptr; emit Closed(); QWidget::closeEvent(event); } @@ -221,7 +221,7 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) { this->TouchPressed(static_cast<unsigned>(pos.x() * pixelRatio), static_cast<unsigned>(pos.y() * pixelRatio)); } else if (event->button() == Qt::RightButton) { - motion_emu->BeginTilt(pos.x(), pos.y()); + InputCommon::GetMotionEmu()->BeginTilt(pos.x(), pos.y()); } } @@ -230,14 +230,14 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { qreal pixelRatio = windowPixelRatio(); this->TouchMoved(std::max(static_cast<unsigned>(pos.x() * pixelRatio), 0u), std::max(static_cast<unsigned>(pos.y() * pixelRatio), 0u)); - motion_emu->Tilt(pos.x(), pos.y()); + InputCommon::GetMotionEmu()->Tilt(pos.x(), pos.y()); } void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { if (event->button() == Qt::LeftButton) this->TouchReleased(); else if (event->button() == Qt::RightButton) - motion_emu->EndTilt(); + InputCommon::GetMotionEmu()->EndTilt(); } void GRenderWindow::focusOutEvent(QFocusEvent* event) { @@ -290,13 +290,11 @@ void GRenderWindow::OnMinimalClientAreaChangeRequest( } void GRenderWindow::OnEmulationStarting(EmuThread* emu_thread) { - motion_emu = std::make_unique<Motion::MotionEmu>(*this); this->emu_thread = emu_thread; child->DisablePainting(); } void GRenderWindow::OnEmulationStopping() { - motion_emu = nullptr; emu_thread = nullptr; child->EnablePainting(); } diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index 4b3a3b3cc..6974edcbb 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -12,7 +12,6 @@ #include "common/thread.h" #include "core/core.h" #include "core/frontend/emu_window.h" -#include "core/frontend/motion_emu.h" class QKeyEvent; class QScreen; @@ -158,9 +157,6 @@ private: EmuThread* emu_thread; - /// Motion sensors emulation - std::unique_ptr<Motion::MotionEmu> motion_emu; - protected: void showEvent(QShowEvent* event) override; }; diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 75abb4ce6..6e42db007 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -57,6 +57,11 @@ void Config::ReadValues() { Settings::values.analogs[i] = default_param; } + Settings::values.motion_device = + qt_config->value("motion_device", "engine:motion_emu,update_period:100,sensitivity:0.01") + .toString() + .toStdString(); + qt_config->endGroup(); qt_config->beginGroup("Core"); @@ -203,6 +208,7 @@ void Config::SaveValues() { qt_config->setValue(QString::fromStdString(Settings::NativeAnalog::mapping[i]), QString::fromStdString(Settings::values.analogs[i])); } + qt_config->setValue("motion_device", QString::fromStdString(Settings::values.motion_device)); qt_config->endGroup(); qt_config->beginGroup("Core"); |