From 4cb3baba5cf360a02dff9d6af1a839a570c40999 Mon Sep 17 00:00:00 2001
From: rlnilsen <47765059+rlnilsen@users.noreply.github.com>
Date: Fri, 6 Sep 2019 17:09:30 +0200
Subject: Add support for motion controllers via the CemuHook controller input
protocol. This is done by: 1) Implementing said protocol in a new controller
input class CemuHookUDPServer. 2) Adding functionality in the WiimoteEmu
class for pushing that motion input to the emulated Wiimote and MotionPlus.
3) Suitably modifying the UI for configuring an Emulated Wii Remote.
---
.../ControlGroup/IMUAccelerometer.cpp | 44 ++++++++++++++++++++++
1 file changed, 44 insertions(+)
create mode 100644 Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.cpp
(limited to 'Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.cpp')
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.cpp
new file mode 100644
index 0000000000..e994ceba5d
--- /dev/null
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.cpp
@@ -0,0 +1,44 @@
+// Copyright 2019 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#include "InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.h"
+
+#include "Common/Common.h"
+#include "Common/MathUtil.h"
+
+#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
+
+#include "InputCommon/ControlReference/ControlReference.h"
+#include "InputCommon/ControllerEmu/Control/Control.h"
+#include "InputCommon/ControllerEmu/Control/Input.h"
+#include "InputCommon/ControllerEmu/ControllerEmu.h"
+#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
+
+namespace ControllerEmu
+{
+IMUAccelerometer::IMUAccelerometer(std::string name, std::string ui_name)
+ : ControlGroup(std::move(name), std::move(ui_name), GroupType::IMUAccelerometer)
+{
+ controls.emplace_back(std::make_unique(Translate, _trans("Left")));
+ controls.emplace_back(std::make_unique(Translate, _trans("Right")));
+ controls.emplace_back(std::make_unique(Translate, _trans("Forward")));
+ controls.emplace_back(std::make_unique(Translate, _trans("Backward")));
+ controls.emplace_back(std::make_unique(Translate, _trans("Up")));
+ controls.emplace_back(std::make_unique(Translate, _trans("Down")));
+}
+
+std::optional IMUAccelerometer::GetState() const
+{
+ StateData state;
+ state.x = (controls[0]->control_ref->State() - controls[1]->control_ref->State());
+ state.y = (controls[3]->control_ref->State() - controls[2]->control_ref->State());
+ state.z = (controls[4]->control_ref->State() - controls[5]->control_ref->State());
+
+ if (controls[0]->control_ref->BoundCount() != 0)
+ return state;
+ else
+ return std::nullopt;
+}
+
+} // namespace ControllerEmu
--
cgit v1.2.3