diff options
Diffstat (limited to 'src/input_common/helpers/joycon_protocol/irs.h')
| -rw-r--r-- | src/input_common/helpers/joycon_protocol/irs.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/input_common/helpers/joycon_protocol/irs.h b/src/input_common/helpers/joycon_protocol/irs.h new file mode 100644 index 000000000..76dfa02ea --- /dev/null +++ b/src/input_common/helpers/joycon_protocol/irs.h | |||
| @@ -0,0 +1,63 @@ | |||
| 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 | #include "input_common/helpers/joycon_protocol/joycon_types.h" | ||
| 15 | |||
| 16 | namespace InputCommon::Joycon { | ||
| 17 | |||
| 18 | class IrsProtocol final : private JoyconCommonProtocol { | ||
| 19 | public: | ||
| 20 | explicit IrsProtocol(std::shared_ptr<JoyconHandle> handle); | ||
| 21 | |||
| 22 | DriverResult EnableIrs(); | ||
| 23 | |||
| 24 | DriverResult DisableIrs(); | ||
| 25 | |||
| 26 | DriverResult SetIrsConfig(IrsMode mode, IrsResolution format); | ||
| 27 | |||
| 28 | DriverResult RequestImage(std::span<u8> buffer); | ||
| 29 | |||
| 30 | std::vector<u8> GetImage() const; | ||
| 31 | |||
| 32 | IrsResolution GetIrsFormat() const; | ||
| 33 | |||
| 34 | bool IsEnabled() const; | ||
| 35 | |||
| 36 | private: | ||
| 37 | DriverResult ConfigureIrs(); | ||
| 38 | |||
| 39 | DriverResult WriteRegistersStep1(); | ||
| 40 | DriverResult WriteRegistersStep2(); | ||
| 41 | |||
| 42 | DriverResult RequestFrame(u8 frame); | ||
| 43 | DriverResult ResendFrame(u8 frame); | ||
| 44 | |||
| 45 | IrsMode irs_mode{IrsMode::ImageTransfer}; | ||
| 46 | IrsResolution resolution{IrsResolution::Size40x30}; | ||
| 47 | IrsResolutionCode resolution_code{IrsResolutionCode::Size40x30}; | ||
| 48 | IrsFragments fragments{IrsFragments::Size40x30}; | ||
| 49 | IrLeds leds{IrLeds::BrightAndDim}; | ||
| 50 | IrExLedFilter led_filter{IrExLedFilter::Enabled}; | ||
| 51 | IrImageFlip image_flip{IrImageFlip::Normal}; | ||
| 52 | u8 digital_gain{0x01}; | ||
| 53 | u16 exposure{0x2490}; | ||
| 54 | u16 led_intensity{0x0f10}; | ||
| 55 | u32 denoise{0x012344}; | ||
| 56 | |||
| 57 | u8 packet_fragment{}; | ||
| 58 | std::vector<u8> buf_image; // 8bpp greyscale image. | ||
| 59 | |||
| 60 | bool is_enabled{}; | ||
| 61 | }; | ||
| 62 | |||
| 63 | } // namespace InputCommon::Joycon | ||