mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	move MotionEmu from core/frontend to input_common as a InputDevice
This commit is contained in:
		
							parent
							
								
									867eabd6b7
								
							
						
					
					
						commit
						188194908c
					
				
					 17 changed files with 221 additions and 244 deletions
				
			
		|  | @ -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(); | ||||
| } | ||||
|  |  | |||
|  | @ -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; | ||||
| }; | ||||
|  |  | |||
|  | @ -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"); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue