early-access version 3309
This commit is contained in:
@@ -120,7 +120,7 @@ DriverResult JoyconCommonProtocol::SendSubCommand(SubCommand sc, std::span<const
|
||||
return DriverResult::Success;
|
||||
}
|
||||
|
||||
DriverResult JoyconCommonProtocol::SendMcuCommand(SubCommand sc, std::span<const u8> buffer) {
|
||||
DriverResult JoyconCommonProtocol::SendMCUCommand(SubCommand sc, std::span<const u8> buffer) {
|
||||
std::vector<u8> local_buffer(MaxResponseSize);
|
||||
|
||||
local_buffer[0] = static_cast<u8>(OutputReport::MCU_DATA);
|
||||
|
@@ -79,7 +79,7 @@ public:
|
||||
* @param sc sub command to be send
|
||||
* @param buffer data to be send
|
||||
*/
|
||||
DriverResult SendMcuCommand(SubCommand sc, std::span<const u8> buffer);
|
||||
DriverResult SendMCUCommand(SubCommand sc, std::span<const u8> buffer);
|
||||
|
||||
/**
|
||||
* Sends vibration data to the joycon
|
||||
@@ -150,4 +150,17 @@ private:
|
||||
std::shared_ptr<JoyconHandle> hidapi_handle;
|
||||
};
|
||||
|
||||
class ScopedSetBlocking {
|
||||
public:
|
||||
explicit ScopedSetBlocking(JoyconCommonProtocol* self) : m_self{self} {
|
||||
m_self->SetBlocking();
|
||||
}
|
||||
|
||||
~ScopedSetBlocking() {
|
||||
m_self->SetNonBlocking();
|
||||
}
|
||||
|
||||
private:
|
||||
JoyconCommonProtocol* m_self{};
|
||||
};
|
||||
} // namespace InputCommon::Joycon
|
||||
|
@@ -208,7 +208,7 @@ DriverResult IrsProtocol::WriteRegistersStep1() {
|
||||
|
||||
// First time we need to set the report mode
|
||||
if (result == DriverResult::Success && tries == 0) {
|
||||
result = SendMcuCommand(SubCommand::SET_REPORT_MODE, mcu_request);
|
||||
result = SendMCUCommand(SubCommand::SET_REPORT_MODE, mcu_request);
|
||||
}
|
||||
if (result == DriverResult::Success && tries == 0) {
|
||||
GetSubCommandResponse(SubCommand::SET_MCU_CONFIG, output);
|
||||
@@ -272,7 +272,7 @@ DriverResult IrsProtocol::RequestFrame(u8 frame) {
|
||||
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);
|
||||
return SendMCUCommand(SubCommand::SET_REPORT_MODE, mcu_request);
|
||||
}
|
||||
|
||||
DriverResult IrsProtocol::ResendFrame(u8 frame) {
|
||||
@@ -282,7 +282,7 @@ DriverResult IrsProtocol::ResendFrame(u8 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);
|
||||
return SendMCUCommand(SubCommand::SET_REPORT_MODE, mcu_request);
|
||||
}
|
||||
|
||||
std::vector<u8> IrsProtocol::GetImage() const {
|
||||
|
@@ -176,7 +176,7 @@ loop1:
|
||||
auto result = SendReadAmiiboRequest(output, ntag_pages);
|
||||
|
||||
int attempt = 0;
|
||||
while (1) {
|
||||
while (true) {
|
||||
if (attempt != 0) {
|
||||
result = GetMCUDataResponse(ReportMode::NFC_IR_MODE_60HZ, output);
|
||||
}
|
||||
@@ -364,45 +364,50 @@ DriverResult NfcProtocol::SendReadAmiiboRequest(std::vector<u8>& output, std::si
|
||||
}
|
||||
|
||||
NFCReadBlockCommand NfcProtocol::GetReadBlockCommand(std::size_t pages) const {
|
||||
constexpr NFCReadBlockCommand block0{
|
||||
.block_count = 1,
|
||||
};
|
||||
constexpr NFCReadBlockCommand block45{
|
||||
.block_count = 1,
|
||||
.blocks =
|
||||
{
|
||||
NFCReadBlock{0x00, 0x2C},
|
||||
},
|
||||
};
|
||||
constexpr NFCReadBlockCommand block135{
|
||||
.block_count = 3,
|
||||
.blocks =
|
||||
{
|
||||
NFCReadBlock{0x00, 0x3b},
|
||||
{0x3c, 0x77},
|
||||
{0x78, 0x86},
|
||||
},
|
||||
};
|
||||
constexpr NFCReadBlockCommand block231{
|
||||
.block_count = 4,
|
||||
.blocks =
|
||||
{
|
||||
NFCReadBlock{0x00, 0x3b},
|
||||
{0x3c, 0x77},
|
||||
{0x78, 0x83},
|
||||
{0xb4, 0xe6},
|
||||
},
|
||||
};
|
||||
|
||||
if (pages == 0) {
|
||||
return {
|
||||
.block_count = 1,
|
||||
};
|
||||
return block0;
|
||||
}
|
||||
|
||||
if (pages == 45) {
|
||||
return {
|
||||
.block_count = 1,
|
||||
.blocks =
|
||||
{
|
||||
NFCReadBlock{0x00, 0x2C},
|
||||
},
|
||||
};
|
||||
return block45;
|
||||
}
|
||||
|
||||
if (pages == 135) {
|
||||
return {
|
||||
.block_count = 3,
|
||||
.blocks =
|
||||
{
|
||||
NFCReadBlock{0x00, 0x3b},
|
||||
{0x3c, 0x77},
|
||||
{0x78, 0x86},
|
||||
},
|
||||
};
|
||||
return block135;
|
||||
}
|
||||
|
||||
if (pages == 231) {
|
||||
return {
|
||||
.block_count = 4,
|
||||
.blocks =
|
||||
{
|
||||
NFCReadBlock{0x00, 0x3b},
|
||||
{0x3c, 0x77},
|
||||
{0x78, 0x83},
|
||||
{0xb4, 0xe6},
|
||||
},
|
||||
};
|
||||
return block231;
|
||||
}
|
||||
|
||||
return {};
|
||||
|
@@ -224,9 +224,9 @@ void JoyconPoller::UpdatePasiveLeftPadInput(const InputReportPassive& input) {
|
||||
Joycon::PasivePadButton::StickL,
|
||||
};
|
||||
|
||||
for (std::size_t i = 0; i < left_buttons.size(); ++i) {
|
||||
const bool button_status = (input.button_input & static_cast<u32>(left_buttons[i])) != 0;
|
||||
const int button = static_cast<int>(left_buttons[i]);
|
||||
for (auto left_button : left_buttons) {
|
||||
const bool button_status = (input.button_input & static_cast<u32>(left_button)) != 0;
|
||||
const int button = static_cast<int>(left_button);
|
||||
callbacks.on_button_data(button, button_status);
|
||||
}
|
||||
}
|
||||
@@ -241,9 +241,9 @@ void JoyconPoller::UpdatePasiveRightPadInput(const InputReportPassive& input) {
|
||||
Joycon::PasivePadButton::StickR,
|
||||
};
|
||||
|
||||
for (std::size_t i = 0; i < right_buttons.size(); ++i) {
|
||||
const bool button_status = (input.button_input & static_cast<u32>(right_buttons[i])) != 0;
|
||||
const int button = static_cast<int>(right_buttons[i]);
|
||||
for (auto right_button : right_buttons) {
|
||||
const bool button_status = (input.button_input & static_cast<u32>(right_button)) != 0;
|
||||
const int button = static_cast<int>(right_button);
|
||||
callbacks.on_button_data(button, button_status);
|
||||
}
|
||||
}
|
||||
@@ -259,9 +259,9 @@ void JoyconPoller::UpdatePasiveProPadInput(const InputReportPassive& input) {
|
||||
Joycon::PasivePadButton::StickL, Joycon::PasivePadButton::StickR,
|
||||
};
|
||||
|
||||
for (std::size_t i = 0; i < pro_buttons.size(); ++i) {
|
||||
const bool button_status = (input.button_input & static_cast<u32>(pro_buttons[i])) != 0;
|
||||
const int button = static_cast<int>(pro_buttons[i]);
|
||||
for (auto pro_button : pro_buttons) {
|
||||
const bool button_status = (input.button_input & static_cast<u32>(pro_button)) != 0;
|
||||
const int button = static_cast<int>(pro_button);
|
||||
callbacks.on_button_data(button, button_status);
|
||||
}
|
||||
}
|
||||
|
@@ -66,9 +66,9 @@ u8 RumbleProtocol::EncodeLowFrequency(f32 frequency) const {
|
||||
}
|
||||
|
||||
u8 RumbleProtocol::EncodeHighAmplitude(f32 amplitude) const {
|
||||
/* More information about these values can be found here:
|
||||
* https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md
|
||||
*/
|
||||
// More information about these values can be found here:
|
||||
// https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md
|
||||
|
||||
static constexpr std::array<std::pair<f32, int>, 101> high_fequency_amplitude{
|
||||
std::pair<f32, int>{0.0f, 0x0},
|
||||
{0.01f, 0x2},
|
||||
@@ -183,9 +183,9 @@ u8 RumbleProtocol::EncodeHighAmplitude(f32 amplitude) const {
|
||||
}
|
||||
|
||||
u16 RumbleProtocol::EncodeLowAmplitude(f32 amplitude) const {
|
||||
/* More information about these values can be found here:
|
||||
* https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md
|
||||
*/
|
||||
// More information about these values can be found here:
|
||||
// https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md
|
||||
|
||||
static constexpr std::array<std::pair<f32, int>, 101> high_fequency_amplitude{
|
||||
std::pair<f32, int>{0.0f, 0x0040},
|
||||
{0.01f, 0x8040},
|
||||
|
Reference in New Issue
Block a user