summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/input_common/drivers/joycon.cpp4
-rw-r--r--src/input_common/drivers/joycon.h2
-rw-r--r--src/input_common/helpers/joycon_protocol/generic_functions.cpp2
-rw-r--r--src/input_common/helpers/joycon_protocol/joycon_types.h68
-rw-r--r--src/input_common/helpers/joycon_protocol/poller.cpp8
-rw-r--r--src/input_common/helpers/joycon_protocol/ringcon.cpp10
6 files changed, 53 insertions, 41 deletions
diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp
index cedc94e63..4fcfb4510 100644
--- a/src/input_common/drivers/joycon.cpp
+++ b/src/input_common/drivers/joycon.cpp
@@ -668,12 +668,10 @@ std::string Joycons::JoyconName(Joycon::ControllerType type) const {
668 return "Right Joycon"; 668 return "Right Joycon";
669 case Joycon::ControllerType::Pro: 669 case Joycon::ControllerType::Pro:
670 return "Pro Controller"; 670 return "Pro Controller";
671 case Joycon::ControllerType::Grip:
672 return "Grip Controller";
673 case Joycon::ControllerType::Dual: 671 case Joycon::ControllerType::Dual:
674 return "Dual Joycon"; 672 return "Dual Joycon";
675 default: 673 default:
676 return "Unknown Joycon"; 674 return "Unknown Switch Controller";
677 } 675 }
678} 676}
679} // namespace InputCommon 677} // namespace InputCommon
diff --git a/src/input_common/drivers/joycon.h b/src/input_common/drivers/joycon.h
index 316d383d8..2149ab7fd 100644
--- a/src/input_common/drivers/joycon.h
+++ b/src/input_common/drivers/joycon.h
@@ -15,7 +15,7 @@ using SerialNumber = std::array<u8, 15>;
15struct Battery; 15struct Battery;
16struct Color; 16struct Color;
17struct MotionData; 17struct MotionData;
18enum class ControllerType; 18enum class ControllerType : u8;
19enum class DriverResult; 19enum class DriverResult;
20enum class IrsResolution; 20enum class IrsResolution;
21class JoyconDriver; 21class JoyconDriver;
diff --git a/src/input_common/helpers/joycon_protocol/generic_functions.cpp b/src/input_common/helpers/joycon_protocol/generic_functions.cpp
index 484c208e6..f3fefd5b6 100644
--- a/src/input_common/helpers/joycon_protocol/generic_functions.cpp
+++ b/src/input_common/helpers/joycon_protocol/generic_functions.cpp
@@ -38,7 +38,7 @@ DriverResult GenericProtocol::GetDeviceInfo(DeviceInfo& device_info) {
38 38
39 device_info = {}; 39 device_info = {};
40 if (result == DriverResult::Success) { 40 if (result == DriverResult::Success) {
41 memcpy(&device_info, output.data(), sizeof(DeviceInfo)); 41 memcpy(&device_info, output.data() + 15, sizeof(DeviceInfo));
42 } 42 }
43 43
44 return result; 44 return result;
diff --git a/src/input_common/helpers/joycon_protocol/joycon_types.h b/src/input_common/helpers/joycon_protocol/joycon_types.h
index 14b07bfb5..ddb48a553 100644
--- a/src/input_common/helpers/joycon_protocol/joycon_types.h
+++ b/src/input_common/helpers/joycon_protocol/joycon_types.h
@@ -26,13 +26,19 @@ constexpr std::array<u8, 8> DefaultVibrationBuffer{0x0, 0x1, 0x40, 0x40, 0x0, 0x
26using MacAddress = std::array<u8, 6>; 26using MacAddress = std::array<u8, 6>;
27using SerialNumber = std::array<u8, 15>; 27using SerialNumber = std::array<u8, 15>;
28 28
29enum class ControllerType { 29enum class ControllerType : u8 {
30 None, 30 None = 0x00,
31 Left, 31 Left = 0x01,
32 Right, 32 Right = 0x02,
33 Pro, 33 Pro = 0x03,
34 Grip, 34 Dual = 0x05, // TODO: Verify this id
35 Dual, 35 LarkHvc1 = 0x07,
36 LarkHvc2 = 0x08,
37 LarkNesLeft = 0x09,
38 LarkNesRight = 0x0A,
39 Lucia = 0x0B,
40 Lagon = 0x0C,
41 Lager = 0x0D,
36}; 42};
37 43
38enum class PadAxes { 44enum class PadAxes {
@@ -143,9 +149,10 @@ enum class SubCommand : u8 {
143 ENABLE_VIBRATION = 0x48, 149 ENABLE_VIBRATION = 0x48,
144 GET_REGULATED_VOLTAGE = 0x50, 150 GET_REGULATED_VOLTAGE = 0x50,
145 SET_EXTERNAL_CONFIG = 0x58, 151 SET_EXTERNAL_CONFIG = 0x58,
146 UNKNOWN_RINGCON = 0x59, 152 GET_EXTERNAL_DEVICE_INFO = 0x59,
147 UNKNOWN_RINGCON2 = 0x5A, 153 ENABLE_EXTERNAL_POLLING = 0x5A,
148 UNKNOWN_RINGCON3 = 0x5C, 154 DISABLE_EXTERNAL_POLLING = 0x5B,
155 SET_EXTERNAL_FORMAT_CONFIG = 0x5C,
149}; 156};
150 157
151enum class UsbSubCommand : u8 { 158enum class UsbSubCommand : u8 {
@@ -165,19 +172,25 @@ enum class CalibrationMagic : u8 {
165}; 172};
166 173
167enum class SpiAddress { 174enum class SpiAddress {
168 SERIAL_NUMBER = 0X6000, 175 MAGIC = 0x0000,
169 DEVICE_TYPE = 0X6012, 176 MAC_ADDRESS = 0x0015,
170 COLOR_EXIST = 0X601B, 177 PAIRING_INFO = 0x2000,
171 FACT_LEFT_DATA = 0X603d, 178 SHIPMENT = 0x5000,
172 FACT_RIGHT_DATA = 0X6046, 179 SERIAL_NUMBER = 0x6000,
173 COLOR_DATA = 0X6050, 180 DEVICE_TYPE = 0x6012,
174 FACT_IMU_DATA = 0X6020, 181 FORMAT_VERSION = 0x601B,
175 USER_LEFT_MAGIC = 0X8010, 182 FACT_IMU_DATA = 0x6020,
176 USER_LEFT_DATA = 0X8012, 183 FACT_LEFT_DATA = 0x603d,
177 USER_RIGHT_MAGIC = 0X801B, 184 FACT_RIGHT_DATA = 0x6046,
178 USER_RIGHT_DATA = 0X801D, 185 COLOR_DATA = 0x6050,
179 USER_IMU_MAGIC = 0X8026, 186 DESIGN_VARIATION = 0x605C,
180 USER_IMU_DATA = 0X8028, 187 SENSOR_DATA = 0x6080,
188 USER_LEFT_MAGIC = 0x8010,
189 USER_LEFT_DATA = 0x8012,
190 USER_RIGHT_MAGIC = 0x801B,
191 USER_RIGHT_DATA = 0x801D,
192 USER_IMU_MAGIC = 0x8026,
193 USER_IMU_DATA = 0x8028,
181}; 194};
182 195
183enum class ReportMode : u8 { 196enum class ReportMode : u8 {
@@ -359,6 +372,11 @@ enum class IrRegistersAddress : u16 {
359 DenoiseColor = 0x6901, 372 DenoiseColor = 0x6901,
360}; 373};
361 374
375enum class ExternalDeviceId : u8 {
376 RingController = 0x20,
377 Starlink = 0x28,
378};
379
362enum class DriverResult { 380enum class DriverResult {
363 Success, 381 Success,
364 WrongReply, 382 WrongReply,
@@ -605,9 +623,11 @@ static_assert(sizeof(FirmwareVersion) == 0x2, "FirmwareVersion is an invalid siz
605 623
606struct DeviceInfo { 624struct DeviceInfo {
607 FirmwareVersion firmware; 625 FirmwareVersion firmware;
626 std::array<u8, 2> unknown_1;
608 MacAddress mac_address; 627 MacAddress mac_address;
628 std::array<u8, 2> unknown_2;
609}; 629};
610static_assert(sizeof(DeviceInfo) == 0x8, "DeviceInfo is an invalid size"); 630static_assert(sizeof(DeviceInfo) == 0xC, "DeviceInfo is an invalid size");
611 631
612struct MotionStatus { 632struct MotionStatus {
613 bool is_enabled; 633 bool is_enabled;
diff --git a/src/input_common/helpers/joycon_protocol/poller.cpp b/src/input_common/helpers/joycon_protocol/poller.cpp
index 7f8e093fa..9bb15e935 100644
--- a/src/input_common/helpers/joycon_protocol/poller.cpp
+++ b/src/input_common/helpers/joycon_protocol/poller.cpp
@@ -31,9 +31,7 @@ void JoyconPoller::ReadActiveMode(std::span<u8> buffer, const MotionStatus& moti
31 case Joycon::ControllerType::Pro: 31 case Joycon::ControllerType::Pro:
32 UpdateActiveProPadInput(data, motion_status); 32 UpdateActiveProPadInput(data, motion_status);
33 break; 33 break;
34 case Joycon::ControllerType::Grip: 34 default:
35 case Joycon::ControllerType::Dual:
36 case Joycon::ControllerType::None:
37 break; 35 break;
38 } 36 }
39 37
@@ -58,9 +56,7 @@ void JoyconPoller::ReadPassiveMode(std::span<u8> buffer) {
58 case Joycon::ControllerType::Pro: 56 case Joycon::ControllerType::Pro:
59 UpdatePasiveProPadInput(data); 57 UpdatePasiveProPadInput(data);
60 break; 58 break;
61 case Joycon::ControllerType::Grip: 59 default:
62 case Joycon::ControllerType::Dual:
63 case Joycon::ControllerType::None:
64 break; 60 break;
65 } 61 }
66} 62}
diff --git a/src/input_common/helpers/joycon_protocol/ringcon.cpp b/src/input_common/helpers/joycon_protocol/ringcon.cpp
index 12f81309e..3c2ca4379 100644
--- a/src/input_common/helpers/joycon_protocol/ringcon.cpp
+++ b/src/input_common/helpers/joycon_protocol/ringcon.cpp
@@ -70,14 +70,12 @@ DriverResult RingConProtocol::StartRingconPolling() {
70DriverResult RingConProtocol::IsRingConnected(bool& is_connected) { 70DriverResult RingConProtocol::IsRingConnected(bool& is_connected) {
71 LOG_DEBUG(Input, "IsRingConnected"); 71 LOG_DEBUG(Input, "IsRingConnected");
72 constexpr std::size_t max_tries = 28; 72 constexpr std::size_t max_tries = 28;
73 constexpr u8 ring_controller_id = 0x20;
74 std::vector<u8> output; 73 std::vector<u8> output;
75 std::size_t tries = 0; 74 std::size_t tries = 0;
76 is_connected = false; 75 is_connected = false;
77 76
78 do { 77 do {
79 std::array<u8, 1> empty_data{}; 78 const auto result = SendSubCommand(SubCommand::GET_EXTERNAL_DEVICE_INFO, {}, output);
80 const auto result = SendSubCommand(SubCommand::UNKNOWN_RINGCON, empty_data, output);
81 79
82 if (result != DriverResult::Success) { 80 if (result != DriverResult::Success) {
83 return result; 81 return result;
@@ -86,7 +84,7 @@ DriverResult RingConProtocol::IsRingConnected(bool& is_connected) {
86 if (tries++ >= max_tries) { 84 if (tries++ >= max_tries) {
87 return DriverResult::NoDeviceDetected; 85 return DriverResult::NoDeviceDetected;
88 } 86 }
89 } while (output[16] != ring_controller_id); 87 } while (output[16] != static_cast<u8>(ExternalDeviceId::RingController));
90 88
91 is_connected = true; 89 is_connected = true;
92 return DriverResult::Success; 90 return DriverResult::Success;
@@ -100,14 +98,14 @@ DriverResult RingConProtocol::ConfigureRing() {
100 0x00, 0x00, 0x00, 0x0A, 0x64, 0x0B, 0xE6, 0xA9, 0x22, 0x00, 0x00, 0x04, 0x00, 98 0x00, 0x00, 0x00, 0x0A, 0x64, 0x0B, 0xE6, 0xA9, 0x22, 0x00, 0x00, 0x04, 0x00,
101 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xA8, 0xE1, 0x34, 0x36}; 99 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xA8, 0xE1, 0x34, 0x36};
102 100
103 const DriverResult result = SendSubCommand(SubCommand::UNKNOWN_RINGCON3, ring_config); 101 const DriverResult result = SendSubCommand(SubCommand::SET_EXTERNAL_FORMAT_CONFIG, ring_config);
104 102
105 if (result != DriverResult::Success) { 103 if (result != DriverResult::Success) {
106 return result; 104 return result;
107 } 105 }
108 106
109 static constexpr std::array<u8, 4> ringcon_data{0x04, 0x01, 0x01, 0x02}; 107 static constexpr std::array<u8, 4> ringcon_data{0x04, 0x01, 0x01, 0x02};
110 return SendSubCommand(SubCommand::UNKNOWN_RINGCON2, ringcon_data); 108 return SendSubCommand(SubCommand::ENABLE_EXTERNAL_POLLING, ringcon_data);
111} 109}
112 110
113bool RingConProtocol::IsEnabled() const { 111bool RingConProtocol::IsEnabled() const {