early-access version 3262
This commit is contained in:
@@ -191,6 +191,10 @@ void Joycons::RegisterNewDevice(SDL_hid_device_info* device_info) {
|
||||
.on_amiibo_data = {[this, port](const std::vector<u8>& amiibo_data) {
|
||||
OnAmiiboUpdate(port, amiibo_data);
|
||||
}},
|
||||
.on_camera_data = {[this, port](const std::vector<u8>& camera_data,
|
||||
Joycon::IrsResolution format) {
|
||||
OnCameraUpdate(port, camera_data, format);
|
||||
}},
|
||||
};
|
||||
|
||||
handle->InitializeDevice();
|
||||
@@ -265,9 +269,14 @@ Common::Input::DriverResult Joycons::SetLeds(const PadIdentifier& identifier,
|
||||
handle->SetLedConfig(static_cast<u8>(led_config)));
|
||||
}
|
||||
|
||||
Common::Input::DriverResult Joycons::SetCameraFormat(const PadIdentifier& identifier_,
|
||||
Common::Input::DriverResult Joycons::SetCameraFormat(const PadIdentifier& identifier,
|
||||
Common::Input::CameraFormat camera_format) {
|
||||
return Common::Input::DriverResult::NotSupported;
|
||||
auto handle = GetHandle(identifier);
|
||||
if (handle == nullptr) {
|
||||
return Common::Input::DriverResult::InvalidHandle;
|
||||
}
|
||||
return static_cast<Common::Input::DriverResult>(handle->SetIrsConfig(
|
||||
Joycon::IrsMode::ImageTransfer, static_cast<Joycon::IrsResolution>(camera_format)));
|
||||
};
|
||||
|
||||
Common::Input::NfcState Joycons::SupportsNfc(const PadIdentifier& identifier_) const {
|
||||
@@ -288,18 +297,16 @@ Common::Input::DriverResult Joycons::SetPollingMode(const PadIdentifier& identif
|
||||
}
|
||||
|
||||
switch (polling_mode) {
|
||||
case Common::Input::PollingMode::NFC:
|
||||
return static_cast<Common::Input::DriverResult>(handle->SetNfcMode());
|
||||
break;
|
||||
case Common::Input::PollingMode::Active:
|
||||
return static_cast<Common::Input::DriverResult>(handle->SetActiveMode());
|
||||
break;
|
||||
case Common::Input::PollingMode::Pasive:
|
||||
return static_cast<Common::Input::DriverResult>(handle->SetPasiveMode());
|
||||
break;
|
||||
case Common::Input::PollingMode::IR:
|
||||
return static_cast<Common::Input::DriverResult>(handle->SetIrMode());
|
||||
case Common::Input::PollingMode::NFC:
|
||||
return static_cast<Common::Input::DriverResult>(handle->SetNfcMode());
|
||||
case Common::Input::PollingMode::Ring:
|
||||
return static_cast<Common::Input::DriverResult>(handle->SetRingConMode());
|
||||
break;
|
||||
default:
|
||||
return Common::Input::DriverResult::NotSupported;
|
||||
}
|
||||
@@ -390,6 +397,12 @@ void Joycons::OnAmiiboUpdate(std::size_t port, const std::vector<u8>& amiibo_dat
|
||||
SetNfc(identifier, {nfc_state, amiibo_data});
|
||||
}
|
||||
|
||||
void Joycons::OnCameraUpdate(std::size_t port, const std::vector<u8>& camera_data,
|
||||
Joycon::IrsResolution format) {
|
||||
const auto identifier = GetIdentifier(port, Joycon::ControllerType::Right);
|
||||
SetCamera(identifier, {static_cast<Common::Input::CameraFormat>(format), camera_data});
|
||||
}
|
||||
|
||||
std::shared_ptr<Joycon::JoyconDriver> Joycons::GetHandle(PadIdentifier identifier) const {
|
||||
auto is_handle_active = [&](std::shared_ptr<Joycon::JoyconDriver> device) {
|
||||
if (!device) {
|
||||
|
@@ -17,6 +17,7 @@ struct Color;
|
||||
struct MotionData;
|
||||
enum class ControllerType;
|
||||
enum class DriverResult;
|
||||
enum class IrsResolution;
|
||||
class JoyconDriver;
|
||||
} // namespace InputCommon::Joycon
|
||||
|
||||
@@ -35,7 +36,7 @@ public:
|
||||
Common::Input::DriverResult SetLeds(const PadIdentifier& identifier,
|
||||
const Common::Input::LedStatus& led_status) override;
|
||||
|
||||
Common::Input::DriverResult SetCameraFormat(const PadIdentifier& identifier_,
|
||||
Common::Input::DriverResult SetCameraFormat(const PadIdentifier& identifier,
|
||||
Common::Input::CameraFormat camera_format) override;
|
||||
|
||||
Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) const override;
|
||||
@@ -81,6 +82,8 @@ private:
|
||||
const Joycon::MotionData& value);
|
||||
void OnRingConUpdate(f32 ring_data);
|
||||
void OnAmiiboUpdate(std::size_t port, const std::vector<u8>& amiibo_data);
|
||||
void OnCameraUpdate(std::size_t port, const std::vector<u8>& camera_data,
|
||||
Joycon::IrsResolution format);
|
||||
|
||||
/// Returns a JoyconHandle corresponding to a PadIdentifier
|
||||
std::shared_ptr<Joycon::JoyconDriver> GetHandle(PadIdentifier identifier) const;
|
||||
|
@@ -202,10 +202,15 @@ void JoyconDriver::OnNewData(std::span<u8> buffer) {
|
||||
.min_value = ring_calibration.min_value,
|
||||
};
|
||||
|
||||
if (irs_protocol->IsEnabled()) {
|
||||
irs_protocol->RequestImage(buffer);
|
||||
joycon_poller->UpdateCamera(irs_protocol->GetImage(), irs_protocol->GetIrsFormat());
|
||||
}
|
||||
|
||||
if (nfc_protocol->IsEnabled()) {
|
||||
if (amiibo_detected) {
|
||||
if (!nfc_protocol->HasAmiibo()) {
|
||||
joycon_poller->updateAmiibo({});
|
||||
joycon_poller->UpdateAmiibo({});
|
||||
amiibo_detected = false;
|
||||
return;
|
||||
}
|
||||
@@ -215,7 +220,7 @@ void JoyconDriver::OnNewData(std::span<u8> buffer) {
|
||||
std::vector<u8> data(0x21C);
|
||||
const auto result = nfc_protocol->ScanAmiibo(data);
|
||||
if (result == DriverResult::Success) {
|
||||
joycon_poller->updateAmiibo(data);
|
||||
joycon_poller->UpdateAmiibo(data);
|
||||
amiibo_detected = true;
|
||||
}
|
||||
}
|
||||
@@ -391,12 +396,24 @@ DriverResult JoyconDriver::SetLedConfig(u8 led_pattern) {
|
||||
return generic_protocol->SetLedPattern(led_pattern);
|
||||
}
|
||||
|
||||
DriverResult JoyconDriver::SetIrsConfig(IrsMode mode_, IrsResolution format_) {
|
||||
std::scoped_lock lock{mutex};
|
||||
if (disable_input_thread) {
|
||||
return DriverResult::HandleInUse;
|
||||
}
|
||||
disable_input_thread = true;
|
||||
const auto result = irs_protocol->SetIrsConfig(mode_, format_);
|
||||
disable_input_thread = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
DriverResult JoyconDriver::SetPasiveMode() {
|
||||
std::scoped_lock lock{mutex};
|
||||
motion_enabled = false;
|
||||
hidbus_enabled = false;
|
||||
nfc_enabled = false;
|
||||
passive_enabled = true;
|
||||
irs_enabled = false;
|
||||
return SetPollingMode();
|
||||
}
|
||||
|
||||
@@ -406,6 +423,22 @@ DriverResult JoyconDriver::SetActiveMode() {
|
||||
hidbus_enabled = false;
|
||||
nfc_enabled = false;
|
||||
passive_enabled = false;
|
||||
irs_enabled = false;
|
||||
return SetPollingMode();
|
||||
}
|
||||
|
||||
DriverResult JoyconDriver::SetIrMode() {
|
||||
std::scoped_lock lock{mutex};
|
||||
|
||||
if (!supported_features.irs) {
|
||||
return DriverResult::NotSupported;
|
||||
}
|
||||
|
||||
motion_enabled = false;
|
||||
hidbus_enabled = false;
|
||||
nfc_enabled = false;
|
||||
passive_enabled = false;
|
||||
irs_enabled = true;
|
||||
return SetPollingMode();
|
||||
}
|
||||
|
||||
@@ -420,6 +453,7 @@ DriverResult JoyconDriver::SetNfcMode() {
|
||||
hidbus_enabled = false;
|
||||
nfc_enabled = true;
|
||||
passive_enabled = false;
|
||||
irs_enabled = false;
|
||||
return SetPollingMode();
|
||||
}
|
||||
|
||||
@@ -434,6 +468,7 @@ DriverResult JoyconDriver::SetRingConMode() {
|
||||
hidbus_enabled = true;
|
||||
nfc_enabled = false;
|
||||
passive_enabled = false;
|
||||
irs_enabled = false;
|
||||
|
||||
const auto result = SetPollingMode();
|
||||
|
||||
|
@@ -42,8 +42,10 @@ public:
|
||||
|
||||
DriverResult SetVibration(const VibrationValue& vibration);
|
||||
DriverResult SetLedConfig(u8 led_pattern);
|
||||
DriverResult SetIrsConfig(IrsMode mode_, IrsResolution format_);
|
||||
DriverResult SetPasiveMode();
|
||||
DriverResult SetActiveMode();
|
||||
DriverResult SetIrMode();
|
||||
DriverResult SetNfcMode();
|
||||
DriverResult SetRingConMode();
|
||||
|
||||
|
@@ -68,6 +68,69 @@ DriverResult IrsProtocol::DisableIrs() {
|
||||
return result;
|
||||
}
|
||||
|
||||
DriverResult IrsProtocol::SetIrsConfig(IrsMode mode, IrsResolution format) {
|
||||
irs_mode = mode;
|
||||
switch (format) {
|
||||
case IrsResolution::Size320x240:
|
||||
resolution_code = IrsResolutionCode::Size320x240;
|
||||
fragments = IrsFragments::Size320x240;
|
||||
resolution = IrsResolution::Size320x240;
|
||||
break;
|
||||
case IrsResolution::Size160x120:
|
||||
resolution_code = IrsResolutionCode::Size160x120;
|
||||
fragments = IrsFragments::Size160x120;
|
||||
resolution = IrsResolution::Size160x120;
|
||||
break;
|
||||
case IrsResolution::Size80x60:
|
||||
resolution_code = IrsResolutionCode::Size80x60;
|
||||
fragments = IrsFragments::Size80x60;
|
||||
resolution = IrsResolution::Size80x60;
|
||||
break;
|
||||
case IrsResolution::Size20x15:
|
||||
resolution_code = IrsResolutionCode::Size20x15;
|
||||
fragments = IrsFragments::Size20x15;
|
||||
resolution = IrsResolution::Size20x15;
|
||||
break;
|
||||
case IrsResolution::Size40x30:
|
||||
default:
|
||||
resolution_code = IrsResolutionCode::Size40x30;
|
||||
fragments = IrsFragments::Size40x30;
|
||||
resolution = IrsResolution::Size40x30;
|
||||
break;
|
||||
}
|
||||
|
||||
// Restart feature
|
||||
if (is_enabled) {
|
||||
DisableIrs();
|
||||
return EnableIrs();
|
||||
}
|
||||
|
||||
return DriverResult::Success;
|
||||
}
|
||||
|
||||
DriverResult IrsProtocol::RequestImage(std::span<u8> buffer) {
|
||||
const u8 next_packet_fragment =
|
||||
static_cast<u8>((packet_fragment + 1) % (static_cast<u8>(fragments) + 1));
|
||||
|
||||
if (buffer[0] == 0x31 && buffer[49] == 0x03) {
|
||||
u8 new_packet_fragment = buffer[52];
|
||||
if (new_packet_fragment == next_packet_fragment) {
|
||||
packet_fragment = next_packet_fragment;
|
||||
memcpy(buf_image.data() + (300 * packet_fragment), buffer.data() + 59, 300);
|
||||
|
||||
return RequestFrame(packet_fragment);
|
||||
}
|
||||
|
||||
if (new_packet_fragment == packet_fragment) {
|
||||
return RequestFrame(packet_fragment);
|
||||
}
|
||||
|
||||
return ResendFrame(next_packet_fragment);
|
||||
}
|
||||
|
||||
return RequestFrame(packet_fragment);
|
||||
}
|
||||
|
||||
DriverResult IrsProtocol::ConfigureIrs() {
|
||||
LOG_DEBUG(Input, "Configure IRS");
|
||||
constexpr std::size_t max_tries = 28;
|
||||
@@ -78,11 +141,12 @@ DriverResult IrsProtocol::ConfigureIrs() {
|
||||
.command = MCUCommand::ConfigureIR,
|
||||
.sub_command = MCUSubCommand::SetDeviceMode,
|
||||
.irs_mode = IrsMode::ImageTransfer,
|
||||
.number_of_fragments = 0x3,
|
||||
.number_of_fragments = fragments,
|
||||
.mcu_major_version = 0x0500,
|
||||
.mcu_minor_version = 0x1800,
|
||||
.crc = {},
|
||||
};
|
||||
buf_image.resize((static_cast<u8>(fragments) + 1) * 300);
|
||||
|
||||
std::vector<u8> request_data(sizeof(IrsConfigure));
|
||||
memcpy(request_data.data(), &irs_configuration, sizeof(IrsConfigure));
|
||||
@@ -102,7 +166,7 @@ DriverResult IrsProtocol::ConfigureIrs() {
|
||||
}
|
||||
|
||||
DriverResult IrsProtocol::WriteRegistersStep1() {
|
||||
LOG_DEBUG(Input, "Configure IRS");
|
||||
LOG_DEBUG(Input, "WriteRegistersStep1");
|
||||
DriverResult result{DriverResult::Success};
|
||||
constexpr std::size_t max_tries = 28;
|
||||
std::vector<u8> output;
|
||||
@@ -114,15 +178,15 @@ DriverResult IrsProtocol::WriteRegistersStep1() {
|
||||
.number_of_registers = 0x9,
|
||||
.registers =
|
||||
{
|
||||
IrsRegister{0x2e00, resolution},
|
||||
{0x3001, static_cast<u8>(exposure & 0xff)},
|
||||
{0x3101, static_cast<u8>(exposure >> 8)},
|
||||
{0x3201, 0x00},
|
||||
{0x1000, leds},
|
||||
{0x2e01, static_cast<u8>((digital_gain & 0x0f) << 4)},
|
||||
{0x2f01, static_cast<u8>((digital_gain & 0xf0) >> 4)},
|
||||
{0x0e00, ex_light_filter},
|
||||
{0x4301, 0xc8},
|
||||
IrsRegister{IrRegistersAddress::Resolution, static_cast<u8>(resolution_code)},
|
||||
{IrRegistersAddress::ExposureLSB, static_cast<u8>(exposure & 0xff)},
|
||||
{IrRegistersAddress::ExposureMSB, static_cast<u8>(exposure >> 8)},
|
||||
{IrRegistersAddress::ExposureTime, 0x00},
|
||||
{IrRegistersAddress::Leds, static_cast<u8>(leds)},
|
||||
{IrRegistersAddress::DigitalGainLSB, static_cast<u8>((digital_gain & 0x0f) << 4)},
|
||||
{IrRegistersAddress::DigitalGainMSB, static_cast<u8>((digital_gain & 0xf0) >> 4)},
|
||||
{IrRegistersAddress::LedFilter, static_cast<u8>(led_filter)},
|
||||
{IrRegistersAddress::WhitePixelThreshold, 0xc8},
|
||||
},
|
||||
.crc = {},
|
||||
};
|
||||
@@ -162,7 +226,7 @@ DriverResult IrsProtocol::WriteRegistersStep1() {
|
||||
}
|
||||
|
||||
DriverResult IrsProtocol::WriteRegistersStep2() {
|
||||
LOG_DEBUG(Input, "Configure IRS");
|
||||
LOG_DEBUG(Input, "WriteRegistersStep2");
|
||||
constexpr std::size_t max_tries = 28;
|
||||
std::vector<u8> output;
|
||||
std::size_t tries = 0;
|
||||
@@ -173,14 +237,15 @@ DriverResult IrsProtocol::WriteRegistersStep2() {
|
||||
.number_of_registers = 0x8,
|
||||
.registers =
|
||||
{
|
||||
IrsRegister{0x1100, static_cast<u8>(led_intensity >> 8)},
|
||||
{0x1200, static_cast<u8>(led_intensity & 0xff)},
|
||||
{0x2d00, image_flip},
|
||||
{0x6701, static_cast<u8>((denoise >> 16) & 0xff)},
|
||||
{0x6801, static_cast<u8>((denoise >> 8) & 0xff)},
|
||||
{0x6901, static_cast<u8>(denoise & 0xff)},
|
||||
{0x0400, 0x2d},
|
||||
{0x0700, 0x01},
|
||||
IrsRegister{IrRegistersAddress::LedIntensitiyMSB,
|
||||
static_cast<u8>(led_intensity >> 8)},
|
||||
{IrRegistersAddress::LedIntensitiyLSB, static_cast<u8>(led_intensity & 0xff)},
|
||||
{IrRegistersAddress::ImageFlip, static_cast<u8>(image_flip)},
|
||||
{IrRegistersAddress::DenoiseSmoothing, static_cast<u8>((denoise >> 16) & 0xff)},
|
||||
{IrRegistersAddress::DenoiseEdge, static_cast<u8>((denoise >> 8) & 0xff)},
|
||||
{IrRegistersAddress::DenoiseColor, static_cast<u8>(denoise & 0xff)},
|
||||
{IrRegistersAddress::UpdateTime, 0x2d},
|
||||
{IrRegistersAddress::FinalizeConfig, 0x01},
|
||||
},
|
||||
.crc = {},
|
||||
};
|
||||
@@ -202,6 +267,32 @@ DriverResult IrsProtocol::WriteRegistersStep2() {
|
||||
return DriverResult::Success;
|
||||
}
|
||||
|
||||
DriverResult IrsProtocol::RequestFrame(u8 frame) {
|
||||
std::array<u8, 38> mcu_request{};
|
||||
mcu_request[3] = frame;
|
||||
mcu_request[36] = CalculateMCU_CRC8(mcu_request.data(), 36);
|
||||
mcu_request[37] = 0xFF;
|
||||
return SendMcuCommand(SubCommand::SET_REPORT_MODE, mcu_request);
|
||||
}
|
||||
|
||||
DriverResult IrsProtocol::ResendFrame(u8 frame) {
|
||||
std::array<u8, 38> mcu_request{};
|
||||
mcu_request[1] = 0x1;
|
||||
mcu_request[2] = frame;
|
||||
mcu_request[3] = 0x0;
|
||||
mcu_request[36] = CalculateMCU_CRC8(mcu_request.data(), 36);
|
||||
mcu_request[37] = 0xFF;
|
||||
return SendMcuCommand(SubCommand::SET_REPORT_MODE, mcu_request);
|
||||
}
|
||||
|
||||
std::vector<u8> IrsProtocol::GetImage() const {
|
||||
return buf_image;
|
||||
}
|
||||
|
||||
IrsResolution IrsProtocol::GetIrsFormat() const {
|
||||
return resolution;
|
||||
}
|
||||
|
||||
bool IrsProtocol::IsEnabled() const {
|
||||
return is_enabled;
|
||||
}
|
||||
|
@@ -23,6 +23,14 @@ public:
|
||||
|
||||
DriverResult DisableIrs();
|
||||
|
||||
DriverResult SetIrsConfig(IrsMode mode, IrsResolution format);
|
||||
|
||||
DriverResult RequestImage(std::span<u8> buffer);
|
||||
|
||||
std::vector<u8> GetImage() const;
|
||||
|
||||
IrsResolution GetIrsFormat() const;
|
||||
|
||||
bool IsEnabled() const;
|
||||
|
||||
private:
|
||||
@@ -31,16 +39,25 @@ private:
|
||||
DriverResult WriteRegistersStep1();
|
||||
DriverResult WriteRegistersStep2();
|
||||
|
||||
bool is_enabled{};
|
||||
DriverResult RequestFrame(u8 frame);
|
||||
DriverResult ResendFrame(u8 frame);
|
||||
|
||||
u8 resolution = 0x69;
|
||||
u8 leds = 0x00;
|
||||
u8 ex_light_filter = 0x03;
|
||||
u8 image_flip = 0x00;
|
||||
u8 digital_gain = 0x01;
|
||||
u16 exposure = 0x2490;
|
||||
u16 led_intensity = 0x0f10;
|
||||
u32 denoise = 0x012344;
|
||||
IrsMode irs_mode{IrsMode::ImageTransfer};
|
||||
IrsResolution resolution{IrsResolution::Size40x30};
|
||||
IrsResolutionCode resolution_code{IrsResolutionCode::Size40x30};
|
||||
IrsFragments fragments{IrsFragments::Size40x30};
|
||||
IrLeds leds{IrLeds::BrightAndDim};
|
||||
IrExLedFilter led_filter{IrExLedFilter::Enabled};
|
||||
IrImageFlip image_flip{IrImageFlip::Normal};
|
||||
u8 digital_gain{0x01};
|
||||
u16 exposure{0x2490};
|
||||
u16 led_intensity{0x0f10};
|
||||
u32 denoise{0x012344};
|
||||
|
||||
u8 packet_fragment{};
|
||||
std::vector<u8> buf_image; // 8bpp greyscale image.
|
||||
|
||||
bool is_enabled{};
|
||||
};
|
||||
|
||||
} // namespace InputCommon::Joycon
|
||||
|
@@ -18,7 +18,7 @@
|
||||
|
||||
namespace InputCommon::Joycon {
|
||||
constexpr u32 MaxErrorCount = 50;
|
||||
constexpr u32 MaxBufferSize = 60;
|
||||
constexpr u32 MaxBufferSize = 368;
|
||||
constexpr u32 MaxResponseSize = 49;
|
||||
constexpr u32 MaxSubCommandResponseSize = 64;
|
||||
constexpr std::array<u8, 8> DefaultVibrationBuffer{0x0, 0x1, 0x40, 0x40, 0x0, 0x1, 0x40, 0x40};
|
||||
@@ -284,6 +284,69 @@ enum class IrsMode : u8 {
|
||||
SilhouetteTeraImage = 0x0A,
|
||||
};
|
||||
|
||||
enum class IrsResolution {
|
||||
Size320x240,
|
||||
Size160x120,
|
||||
Size80x60,
|
||||
Size40x30,
|
||||
Size20x15,
|
||||
None,
|
||||
};
|
||||
|
||||
enum class IrsResolutionCode : u8 {
|
||||
Size320x240 = 0x00, // Full pixel array
|
||||
Size160x120 = 0x50, // Sensor Binning [2 X 2]
|
||||
Size80x60 = 0x64, // Sensor Binning [4 x 2] and Skipping [1 x 2]
|
||||
Size40x30 = 0x69, // Sensor Binning [4 x 2] and Skipping [2 x 4]
|
||||
Size20x15 = 0x6A, // Sensor Binning [4 x 2] and Skipping [4 x 4]
|
||||
};
|
||||
|
||||
// Size of image divided by 300
|
||||
enum class IrsFragments : u8 {
|
||||
Size20x15 = 0x00,
|
||||
Size40x30 = 0x03,
|
||||
Size80x60 = 0x0f,
|
||||
Size160x120 = 0x3f,
|
||||
Size320x240 = 0xFF,
|
||||
};
|
||||
|
||||
enum class IrLeds : u8 {
|
||||
BrightAndDim = 0x00,
|
||||
Bright = 0x20,
|
||||
Dim = 0x10,
|
||||
None = 0x30,
|
||||
};
|
||||
|
||||
enum class IrExLedFilter : u8 {
|
||||
Disabled = 0x00,
|
||||
Enabled = 0x03,
|
||||
};
|
||||
|
||||
enum class IrImageFlip : u8 {
|
||||
Normal = 0x00,
|
||||
Inverted = 0x02,
|
||||
};
|
||||
|
||||
enum class IrRegistersAddress : u16 {
|
||||
UpdateTime = 0x0400,
|
||||
FinalizeConfig = 0x0700,
|
||||
LedFilter = 0x0e00,
|
||||
Leds = 0x1000,
|
||||
LedIntensitiyMSB = 0x1100,
|
||||
LedIntensitiyLSB = 0x1200,
|
||||
ImageFlip = 0x2d00,
|
||||
Resolution = 0x2e00,
|
||||
DigitalGainLSB = 0x2e01,
|
||||
DigitalGainMSB = 0x2f01,
|
||||
ExposureLSB = 0x3001,
|
||||
ExposureMSB = 0x3101,
|
||||
ExposureTime = 0x3201,
|
||||
WhitePixelThreshold = 0x4301,
|
||||
DenoiseSmoothing = 0x6701,
|
||||
DenoiseEdge = 0x6801,
|
||||
DenoiseColor = 0x6901,
|
||||
};
|
||||
|
||||
enum class DriverResult {
|
||||
Success,
|
||||
WrongReply,
|
||||
@@ -471,7 +534,7 @@ struct IrsConfigure {
|
||||
MCUCommand command;
|
||||
MCUSubCommand sub_command;
|
||||
IrsMode irs_mode;
|
||||
u8 number_of_fragments;
|
||||
IrsFragments number_of_fragments;
|
||||
u16 mcu_major_version;
|
||||
u16 mcu_minor_version;
|
||||
INSERT_PADDING_BYTES(0x1D);
|
||||
@@ -481,7 +544,7 @@ static_assert(sizeof(IrsConfigure) == 0x26, "IrsConfigure is an invalid size");
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct IrsRegister {
|
||||
u16 address;
|
||||
IrRegistersAddress address;
|
||||
u8 value;
|
||||
};
|
||||
static_assert(sizeof(IrsRegister) == 0x3, "IrsRegister is an invalid size");
|
||||
@@ -531,6 +594,7 @@ struct JoyconCallbacks {
|
||||
std::function<void(int, const MotionData&)> on_motion_data;
|
||||
std::function<void(f32)> on_ring_data;
|
||||
std::function<void(const std::vector<u8>&)> on_amiibo_data;
|
||||
std::function<void(const std::vector<u8>&, IrsResolution)> on_camera_data;
|
||||
};
|
||||
|
||||
} // namespace InputCommon::Joycon
|
||||
|
@@ -74,10 +74,14 @@ void JoyconPoller::UpdateColor(const Color& color) {
|
||||
callbacks.on_color_data(color);
|
||||
}
|
||||
|
||||
void JoyconPoller::updateAmiibo(const std::vector<u8>& amiibo_data) {
|
||||
void JoyconPoller::UpdateAmiibo(const std::vector<u8>& amiibo_data) {
|
||||
callbacks.on_amiibo_data(amiibo_data);
|
||||
}
|
||||
|
||||
void JoyconPoller::UpdateCamera(const std::vector<u8>& camera_data, IrsResolution format) {
|
||||
callbacks.on_camera_data(camera_data, format);
|
||||
}
|
||||
|
||||
void JoyconPoller::UpdateRing(s16 value, const RingStatus& ring_status) {
|
||||
float normalized_value = static_cast<float>(value - ring_status.default_value);
|
||||
if (normalized_value > 0) {
|
||||
|
@@ -36,7 +36,8 @@ public:
|
||||
|
||||
void UpdateColor(const Color& color);
|
||||
void UpdateRing(s16 value, const RingStatus& ring_status);
|
||||
void updateAmiibo(const std::vector<u8>& amiibo_data);
|
||||
void UpdateAmiibo(const std::vector<u8>& amiibo_data);
|
||||
void UpdateCamera(const std::vector<u8>& amiibo_data, IrsResolution format);
|
||||
|
||||
private:
|
||||
void UpdateActiveLeftPadInput(const InputReportActive& input,
|
||||
|
Reference in New Issue
Block a user