summaryrefslogtreecommitdiffstats
path: root/src/input_common/helpers/joycon_protocol/calibration.h
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2022-12-21 01:09:59 +0100
committerNarr the Reg <juangerman-13@hotmail.com>2023-01-20 01:05:21 +0100
commit5676c2e17fe895e450e185029991fc20bdf56ec5 (patch)
tree2852ddbe053d4d20b86a955e2bccbe8f23852182 /src/input_common/helpers/joycon_protocol/calibration.h
parentinput_common: Add support for joycon generic functions (diff)
downloadyuzu-5676c2e17fe895e450e185029991fc20bdf56ec5.tar
yuzu-5676c2e17fe895e450e185029991fc20bdf56ec5.tar.gz
yuzu-5676c2e17fe895e450e185029991fc20bdf56ec5.tar.bz2
yuzu-5676c2e17fe895e450e185029991fc20bdf56ec5.tar.lz
yuzu-5676c2e17fe895e450e185029991fc20bdf56ec5.tar.xz
yuzu-5676c2e17fe895e450e185029991fc20bdf56ec5.tar.zst
yuzu-5676c2e17fe895e450e185029991fc20bdf56ec5.zip
Diffstat (limited to '')
-rw-r--r--src/input_common/helpers/joycon_protocol/calibration.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/input_common/helpers/joycon_protocol/calibration.h b/src/input_common/helpers/joycon_protocol/calibration.h
new file mode 100644
index 000000000..38214eed4
--- /dev/null
+++ b/src/input_common/helpers/joycon_protocol/calibration.h
@@ -0,0 +1,54 @@
+// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+// Based on dkms-hid-nintendo implementation, CTCaer joycon toolkit and dekuNukem reverse
+// engineering https://github.com/nicman23/dkms-hid-nintendo/blob/master/src/hid-nintendo.c
+// https://github.com/CTCaer/jc_toolkit
+// https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering
+
+#pragma once
+
+#include <vector>
+
+#include "input_common/helpers/joycon_protocol/common_protocol.h"
+
+namespace InputCommon::Joycon {
+enum class DriverResult;
+struct JoyStickCalibration;
+struct IMUCalibration;
+struct JoyconHandle;
+} // namespace InputCommon::Joycon
+
+namespace InputCommon::Joycon {
+
+/// Driver functions related to retrieving calibration data from the device
+class CalibrationProtocol final : private JoyconCommonProtocol {
+public:
+ CalibrationProtocol(std::shared_ptr<JoyconHandle> handle);
+
+ /**
+ * Sends a request to obtain the left stick calibration from memory
+ * @param is_factory_calibration if true factory values will be returned
+ * @returns JoyStickCalibration of the left joystick
+ */
+ DriverResult GetLeftJoyStickCalibration(JoyStickCalibration& calibration);
+
+ /**
+ * Sends a request to obtain the right stick calibration from memory
+ * @param is_factory_calibration if true factory values will be returned
+ * @returns JoyStickCalibration of the right joystick
+ */
+ DriverResult GetRightJoyStickCalibration(JoyStickCalibration& calibration);
+
+ /**
+ * Sends a request to obtain the motion calibration from memory
+ * @returns ImuCalibration of the motion sensor
+ */
+ DriverResult GetImuCalibration(MotionCalibration& calibration);
+
+private:
+ void ValidateCalibration(JoyStickCalibration& calibration);
+ void ValidateCalibration(MotionCalibration& calibration);
+};
+
+} // namespace InputCommon::Joycon