mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-27 03:42:51 -06:00
input_common: joycon: Fill missing enum data
This commit is contained in:
parent
07cefe9062
commit
11fea5deea
6 changed files with 53 additions and 41 deletions
|
@ -668,12 +668,10 @@ std::string Joycons::JoyconName(Joycon::ControllerType type) const {
|
||||||
return "Right Joycon";
|
return "Right Joycon";
|
||||||
case Joycon::ControllerType::Pro:
|
case Joycon::ControllerType::Pro:
|
||||||
return "Pro Controller";
|
return "Pro Controller";
|
||||||
case Joycon::ControllerType::Grip:
|
|
||||||
return "Grip Controller";
|
|
||||||
case Joycon::ControllerType::Dual:
|
case Joycon::ControllerType::Dual:
|
||||||
return "Dual Joycon";
|
return "Dual Joycon";
|
||||||
default:
|
default:
|
||||||
return "Unknown Joycon";
|
return "Unknown Switch Controller";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace InputCommon
|
} // namespace InputCommon
|
||||||
|
|
|
@ -15,7 +15,7 @@ using SerialNumber = std::array<u8, 15>;
|
||||||
struct Battery;
|
struct Battery;
|
||||||
struct Color;
|
struct Color;
|
||||||
struct MotionData;
|
struct MotionData;
|
||||||
enum class ControllerType;
|
enum class ControllerType : u8;
|
||||||
enum class DriverResult;
|
enum class DriverResult;
|
||||||
enum class IrsResolution;
|
enum class IrsResolution;
|
||||||
class JoyconDriver;
|
class JoyconDriver;
|
||||||
|
|
|
@ -38,7 +38,7 @@ DriverResult GenericProtocol::GetDeviceInfo(DeviceInfo& device_info) {
|
||||||
|
|
||||||
device_info = {};
|
device_info = {};
|
||||||
if (result == DriverResult::Success) {
|
if (result == DriverResult::Success) {
|
||||||
memcpy(&device_info, output.data(), sizeof(DeviceInfo));
|
memcpy(&device_info, output.data() + 15, sizeof(DeviceInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -26,13 +26,19 @@ constexpr std::array<u8, 8> DefaultVibrationBuffer{0x0, 0x1, 0x40, 0x40, 0x0, 0x
|
||||||
using MacAddress = std::array<u8, 6>;
|
using MacAddress = std::array<u8, 6>;
|
||||||
using SerialNumber = std::array<u8, 15>;
|
using SerialNumber = std::array<u8, 15>;
|
||||||
|
|
||||||
enum class ControllerType {
|
enum class ControllerType : u8 {
|
||||||
None,
|
None = 0x00,
|
||||||
Left,
|
Left = 0x01,
|
||||||
Right,
|
Right = 0x02,
|
||||||
Pro,
|
Pro = 0x03,
|
||||||
Grip,
|
Dual = 0x05, // TODO: Verify this id
|
||||||
Dual,
|
LarkHvc1 = 0x07,
|
||||||
|
LarkHvc2 = 0x08,
|
||||||
|
LarkNesLeft = 0x09,
|
||||||
|
LarkNesRight = 0x0A,
|
||||||
|
Lucia = 0x0B,
|
||||||
|
Lagon = 0x0C,
|
||||||
|
Lager = 0x0D,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class PadAxes {
|
enum class PadAxes {
|
||||||
|
@ -143,9 +149,10 @@ enum class SubCommand : u8 {
|
||||||
ENABLE_VIBRATION = 0x48,
|
ENABLE_VIBRATION = 0x48,
|
||||||
GET_REGULATED_VOLTAGE = 0x50,
|
GET_REGULATED_VOLTAGE = 0x50,
|
||||||
SET_EXTERNAL_CONFIG = 0x58,
|
SET_EXTERNAL_CONFIG = 0x58,
|
||||||
UNKNOWN_RINGCON = 0x59,
|
GET_EXTERNAL_DEVICE_INFO = 0x59,
|
||||||
UNKNOWN_RINGCON2 = 0x5A,
|
ENABLE_EXTERNAL_POLLING = 0x5A,
|
||||||
UNKNOWN_RINGCON3 = 0x5C,
|
DISABLE_EXTERNAL_POLLING = 0x5B,
|
||||||
|
SET_EXTERNAL_FORMAT_CONFIG = 0x5C,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class UsbSubCommand : u8 {
|
enum class UsbSubCommand : u8 {
|
||||||
|
@ -165,19 +172,25 @@ enum class CalibrationMagic : u8 {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class SpiAddress {
|
enum class SpiAddress {
|
||||||
SERIAL_NUMBER = 0X6000,
|
MAGIC = 0x0000,
|
||||||
DEVICE_TYPE = 0X6012,
|
MAC_ADDRESS = 0x0015,
|
||||||
COLOR_EXIST = 0X601B,
|
PAIRING_INFO = 0x2000,
|
||||||
FACT_LEFT_DATA = 0X603d,
|
SHIPMENT = 0x5000,
|
||||||
FACT_RIGHT_DATA = 0X6046,
|
SERIAL_NUMBER = 0x6000,
|
||||||
COLOR_DATA = 0X6050,
|
DEVICE_TYPE = 0x6012,
|
||||||
FACT_IMU_DATA = 0X6020,
|
FORMAT_VERSION = 0x601B,
|
||||||
USER_LEFT_MAGIC = 0X8010,
|
FACT_IMU_DATA = 0x6020,
|
||||||
USER_LEFT_DATA = 0X8012,
|
FACT_LEFT_DATA = 0x603d,
|
||||||
USER_RIGHT_MAGIC = 0X801B,
|
FACT_RIGHT_DATA = 0x6046,
|
||||||
USER_RIGHT_DATA = 0X801D,
|
COLOR_DATA = 0x6050,
|
||||||
USER_IMU_MAGIC = 0X8026,
|
DESIGN_VARIATION = 0x605C,
|
||||||
USER_IMU_DATA = 0X8028,
|
SENSOR_DATA = 0x6080,
|
||||||
|
USER_LEFT_MAGIC = 0x8010,
|
||||||
|
USER_LEFT_DATA = 0x8012,
|
||||||
|
USER_RIGHT_MAGIC = 0x801B,
|
||||||
|
USER_RIGHT_DATA = 0x801D,
|
||||||
|
USER_IMU_MAGIC = 0x8026,
|
||||||
|
USER_IMU_DATA = 0x8028,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ReportMode : u8 {
|
enum class ReportMode : u8 {
|
||||||
|
@ -359,6 +372,11 @@ enum class IrRegistersAddress : u16 {
|
||||||
DenoiseColor = 0x6901,
|
DenoiseColor = 0x6901,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class ExternalDeviceId : u8 {
|
||||||
|
RingController = 0x20,
|
||||||
|
Starlink = 0x28,
|
||||||
|
};
|
||||||
|
|
||||||
enum class DriverResult {
|
enum class DriverResult {
|
||||||
Success,
|
Success,
|
||||||
WrongReply,
|
WrongReply,
|
||||||
|
@ -605,9 +623,11 @@ static_assert(sizeof(FirmwareVersion) == 0x2, "FirmwareVersion is an invalid siz
|
||||||
|
|
||||||
struct DeviceInfo {
|
struct DeviceInfo {
|
||||||
FirmwareVersion firmware;
|
FirmwareVersion firmware;
|
||||||
|
std::array<u8, 2> unknown_1;
|
||||||
MacAddress mac_address;
|
MacAddress mac_address;
|
||||||
|
std::array<u8, 2> unknown_2;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(DeviceInfo) == 0x8, "DeviceInfo is an invalid size");
|
static_assert(sizeof(DeviceInfo) == 0xC, "DeviceInfo is an invalid size");
|
||||||
|
|
||||||
struct MotionStatus {
|
struct MotionStatus {
|
||||||
bool is_enabled;
|
bool is_enabled;
|
||||||
|
|
|
@ -31,9 +31,7 @@ void JoyconPoller::ReadActiveMode(std::span<u8> buffer, const MotionStatus& moti
|
||||||
case Joycon::ControllerType::Pro:
|
case Joycon::ControllerType::Pro:
|
||||||
UpdateActiveProPadInput(data, motion_status);
|
UpdateActiveProPadInput(data, motion_status);
|
||||||
break;
|
break;
|
||||||
case Joycon::ControllerType::Grip:
|
default:
|
||||||
case Joycon::ControllerType::Dual:
|
|
||||||
case Joycon::ControllerType::None:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,9 +56,7 @@ void JoyconPoller::ReadPassiveMode(std::span<u8> buffer) {
|
||||||
case Joycon::ControllerType::Pro:
|
case Joycon::ControllerType::Pro:
|
||||||
UpdatePasiveProPadInput(data);
|
UpdatePasiveProPadInput(data);
|
||||||
break;
|
break;
|
||||||
case Joycon::ControllerType::Grip:
|
default:
|
||||||
case Joycon::ControllerType::Dual:
|
|
||||||
case Joycon::ControllerType::None:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,14 +70,12 @@ DriverResult RingConProtocol::StartRingconPolling() {
|
||||||
DriverResult RingConProtocol::IsRingConnected(bool& is_connected) {
|
DriverResult RingConProtocol::IsRingConnected(bool& is_connected) {
|
||||||
LOG_DEBUG(Input, "IsRingConnected");
|
LOG_DEBUG(Input, "IsRingConnected");
|
||||||
constexpr std::size_t max_tries = 28;
|
constexpr std::size_t max_tries = 28;
|
||||||
constexpr u8 ring_controller_id = 0x20;
|
|
||||||
std::vector<u8> output;
|
std::vector<u8> output;
|
||||||
std::size_t tries = 0;
|
std::size_t tries = 0;
|
||||||
is_connected = false;
|
is_connected = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
std::array<u8, 1> empty_data{};
|
const auto result = SendSubCommand(SubCommand::GET_EXTERNAL_DEVICE_INFO, {}, output);
|
||||||
const auto result = SendSubCommand(SubCommand::UNKNOWN_RINGCON, empty_data, output);
|
|
||||||
|
|
||||||
if (result != DriverResult::Success) {
|
if (result != DriverResult::Success) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -86,7 +84,7 @@ DriverResult RingConProtocol::IsRingConnected(bool& is_connected) {
|
||||||
if (tries++ >= max_tries) {
|
if (tries++ >= max_tries) {
|
||||||
return DriverResult::NoDeviceDetected;
|
return DriverResult::NoDeviceDetected;
|
||||||
}
|
}
|
||||||
} while (output[16] != ring_controller_id);
|
} while (output[16] != static_cast<u8>(ExternalDeviceId::RingController));
|
||||||
|
|
||||||
is_connected = true;
|
is_connected = true;
|
||||||
return DriverResult::Success;
|
return DriverResult::Success;
|
||||||
|
@ -100,14 +98,14 @@ DriverResult RingConProtocol::ConfigureRing() {
|
||||||
0x00, 0x00, 0x00, 0x0A, 0x64, 0x0B, 0xE6, 0xA9, 0x22, 0x00, 0x00, 0x04, 0x00,
|
0x00, 0x00, 0x00, 0x0A, 0x64, 0x0B, 0xE6, 0xA9, 0x22, 0x00, 0x00, 0x04, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xA8, 0xE1, 0x34, 0x36};
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xA8, 0xE1, 0x34, 0x36};
|
||||||
|
|
||||||
const DriverResult result = SendSubCommand(SubCommand::UNKNOWN_RINGCON3, ring_config);
|
const DriverResult result = SendSubCommand(SubCommand::SET_EXTERNAL_FORMAT_CONFIG, ring_config);
|
||||||
|
|
||||||
if (result != DriverResult::Success) {
|
if (result != DriverResult::Success) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr std::array<u8, 4> ringcon_data{0x04, 0x01, 0x01, 0x02};
|
static constexpr std::array<u8, 4> ringcon_data{0x04, 0x01, 0x01, 0x02};
|
||||||
return SendSubCommand(SubCommand::UNKNOWN_RINGCON2, ringcon_data);
|
return SendSubCommand(SubCommand::ENABLE_EXTERNAL_POLLING, ringcon_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RingConProtocol::IsEnabled() const {
|
bool RingConProtocol::IsEnabled() const {
|
||||||
|
|
Loading…
Reference in a new issue