summaryrefslogtreecommitdiffstats
path: root/src/input_common/helpers/joycon_protocol/generic_functions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/helpers/joycon_protocol/generic_functions.cpp')
-rw-r--r--src/input_common/helpers/joycon_protocol/generic_functions.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/input_common/helpers/joycon_protocol/generic_functions.cpp b/src/input_common/helpers/joycon_protocol/generic_functions.cpp
index 52bb8b61a..548a4b9e3 100644
--- a/src/input_common/helpers/joycon_protocol/generic_functions.cpp
+++ b/src/input_common/helpers/joycon_protocol/generic_functions.cpp
@@ -19,15 +19,26 @@ DriverResult GenericProtocol::EnableActiveMode() {
return SetReportMode(ReportMode::STANDARD_FULL_60HZ);
}
+DriverResult GenericProtocol::SetLowPowerMode(bool enable) {
+ ScopedSetBlocking sb(this);
+ const std::array<u8, 1> buffer{static_cast<u8>(enable ? 1 : 0)};
+ return SendSubCommand(SubCommand::LOW_POWER_MODE, buffer);
+}
+
+DriverResult GenericProtocol::TriggersElapsed() {
+ ScopedSetBlocking sb(this);
+ return SendSubCommand(SubCommand::TRIGGERS_ELAPSED, {});
+}
+
DriverResult GenericProtocol::GetDeviceInfo(DeviceInfo& device_info) {
ScopedSetBlocking sb(this);
- std::vector<u8> output;
+ SubCommandResponse output{};
const auto result = SendSubCommand(SubCommand::REQ_DEV_INFO, {}, output);
device_info = {};
if (result == DriverResult::Success) {
- memcpy(&device_info, output.data(), sizeof(DeviceInfo));
+ device_info = output.device_info;
}
return result;
@@ -60,8 +71,8 @@ DriverResult GenericProtocol::GetBattery(u32& battery_level) {
DriverResult GenericProtocol::GetColor(Color& color) {
ScopedSetBlocking sb(this);
- std::vector<u8> buffer;
- const auto result = ReadSPI(CalAddr::COLOR_DATA, 12, buffer);
+ std::array<u8, 12> buffer{};
+ const auto result = ReadRawSPI(SpiAddress::COLOR_DATA, buffer);
color = {};
if (result == DriverResult::Success) {
@@ -76,8 +87,8 @@ DriverResult GenericProtocol::GetColor(Color& color) {
DriverResult GenericProtocol::GetSerialNumber(SerialNumber& serial_number) {
ScopedSetBlocking sb(this);
- std::vector<u8> buffer;
- const auto result = ReadSPI(CalAddr::SERIAL_NUMBER, 16, buffer);
+ std::array<u8, 16> buffer{};
+ const auto result = ReadRawSPI(SpiAddress::SERIAL_NUMBER, buffer);
serial_number = {};
if (result == DriverResult::Success) {