diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2023-01-24 15:29:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-24 15:29:37 +0100 |
commit | a68af583ea378b48e2ed5a19f519a815ba89e40f (patch) | |
tree | 2983c14a7d4bc2797259c7d97462a439bec629f3 /src/input_common/helpers/joycon_protocol/calibration.h | |
parent | Merge pull request #9555 from abouvier/catch2-update (diff) | |
parent | core: hid: Make use of SCOPE_EXIT and SCOPE_GUARD where applicable (diff) | |
download | yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar.gz yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar.bz2 yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar.lz yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar.xz yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar.zst yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.zip |
Diffstat (limited to 'src/input_common/helpers/joycon_protocol/calibration.h')
-rw-r--r-- | src/input_common/helpers/joycon_protocol/calibration.h | 64 |
1 files changed, 64 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..afb52a36a --- /dev/null +++ b/src/input_common/helpers/joycon_protocol/calibration.h @@ -0,0 +1,64 @@ +// 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: + explicit 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); + + /** + * Calculates on run time the proper calibration of the ring controller + * @returns RingCalibration of the ring sensor + */ + DriverResult GetRingCalibration(RingCalibration& calibration, s16 current_value); + +private: + void ValidateCalibration(JoyStickCalibration& calibration); + void ValidateCalibration(MotionCalibration& calibration); + + s16 ring_data_max = 0; + s16 ring_data_default = 0; + s16 ring_data_min = 0; +}; + +} // namespace InputCommon::Joycon |