diff options
| author | 2022-12-20 18:09:59 -0600 | |
|---|---|---|
| committer | 2023-01-19 18:05:21 -0600 | |
| commit | 5676c2e17fe895e450e185029991fc20bdf56ec5 (patch) | |
| tree | 2852ddbe053d4d20b86a955e2bccbe8f23852182 /src/input_common/helpers/joycon_protocol/calibration.h | |
| parent | input_common: Add support for joycon generic functions (diff) | |
| download | yuzu-5676c2e17fe895e450e185029991fc20bdf56ec5.tar.gz yuzu-5676c2e17fe895e450e185029991fc20bdf56ec5.tar.xz yuzu-5676c2e17fe895e450e185029991fc20bdf56ec5.zip | |
input_common: Use calibration from joycon
Diffstat (limited to 'src/input_common/helpers/joycon_protocol/calibration.h')
| -rw-r--r-- | src/input_common/helpers/joycon_protocol/calibration.h | 54 |
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 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | // Based on dkms-hid-nintendo implementation, CTCaer joycon toolkit and dekuNukem reverse | ||
| 5 | // engineering https://github.com/nicman23/dkms-hid-nintendo/blob/master/src/hid-nintendo.c | ||
| 6 | // https://github.com/CTCaer/jc_toolkit | ||
| 7 | // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include <vector> | ||
| 12 | |||
| 13 | #include "input_common/helpers/joycon_protocol/common_protocol.h" | ||
| 14 | |||
| 15 | namespace InputCommon::Joycon { | ||
| 16 | enum class DriverResult; | ||
| 17 | struct JoyStickCalibration; | ||
| 18 | struct IMUCalibration; | ||
| 19 | struct JoyconHandle; | ||
| 20 | } // namespace InputCommon::Joycon | ||
| 21 | |||
| 22 | namespace InputCommon::Joycon { | ||
| 23 | |||
| 24 | /// Driver functions related to retrieving calibration data from the device | ||
| 25 | class CalibrationProtocol final : private JoyconCommonProtocol { | ||
| 26 | public: | ||
| 27 | CalibrationProtocol(std::shared_ptr<JoyconHandle> handle); | ||
| 28 | |||
| 29 | /** | ||
| 30 | * Sends a request to obtain the left stick calibration from memory | ||
| 31 | * @param is_factory_calibration if true factory values will be returned | ||
| 32 | * @returns JoyStickCalibration of the left joystick | ||
| 33 | */ | ||
| 34 | DriverResult GetLeftJoyStickCalibration(JoyStickCalibration& calibration); | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Sends a request to obtain the right stick calibration from memory | ||
| 38 | * @param is_factory_calibration if true factory values will be returned | ||
| 39 | * @returns JoyStickCalibration of the right joystick | ||
| 40 | */ | ||
| 41 | DriverResult GetRightJoyStickCalibration(JoyStickCalibration& calibration); | ||
| 42 | |||
| 43 | /** | ||
| 44 | * Sends a request to obtain the motion calibration from memory | ||
| 45 | * @returns ImuCalibration of the motion sensor | ||
| 46 | */ | ||
| 47 | DriverResult GetImuCalibration(MotionCalibration& calibration); | ||
| 48 | |||
| 49 | private: | ||
| 50 | void ValidateCalibration(JoyStickCalibration& calibration); | ||
| 51 | void ValidateCalibration(MotionCalibration& calibration); | ||
| 52 | }; | ||
| 53 | |||
| 54 | } // namespace InputCommon::Joycon | ||