input_common: joycon: Fill missing enum data
This commit is contained in:
parent
07cefe9062
commit
11fea5deea
|
@ -668,12 +668,10 @@ std::string Joycons::JoyconName(Joycon::ControllerType type) const {
|
|||
return "Right Joycon";
|
||||
case Joycon::ControllerType::Pro:
|
||||
return "Pro Controller";
|
||||
case Joycon::ControllerType::Grip:
|
||||
return "Grip Controller";
|
||||
case Joycon::ControllerType::Dual:
|
||||
return "Dual Joycon";
|
||||
default:
|
||||
return "Unknown Joycon";
|
||||
return "Unknown Switch Controller";
|
||||
}
|
||||
}
|
||||
} // namespace InputCommon
|
||||
|
|
|
@ -15,7 +15,7 @@ using SerialNumber = std::array<u8, 15>;
|
|||
struct Battery;
|
||||
struct Color;
|
||||
struct MotionData;
|
||||
enum class ControllerType;
|
||||
enum class ControllerType : u8;
|
||||
enum class DriverResult;
|
||||
enum class IrsResolution;
|
||||
class JoyconDriver;
|
||||
|
|
|
@ -38,7 +38,7 @@ DriverResult GenericProtocol::GetDeviceInfo(DeviceInfo& device_info) {
|
|||
|
||||
device_info = {};
|
||||
if (result == DriverResult::Success) {
|
||||
memcpy(&device_info, output.data(), sizeof(DeviceInfo));
|
||||
memcpy(&device_info, output.data() + 15, sizeof(DeviceInfo));
|
||||
}
|
||||
|
||||
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 SerialNumber = std::array<u8, 15>;
|
||||
|
||||
enum class ControllerType {
|
||||
None,
|
||||
Left,
|
||||
Right,
|
||||
Pro,
|
||||
Grip,
|
||||
Dual,
|
||||
enum class ControllerType : u8 {
|
||||
None = 0x00,
|
||||
Left = 0x01,
|
||||
Right = 0x02,
|
||||
Pro = 0x03,
|
||||
Dual = 0x05, // TODO: Verify this id
|
||||
LarkHvc1 = 0x07,
|
||||
LarkHvc2 = 0x08,
|
||||
LarkNesLeft = 0x09,
|
||||
LarkNesRight = 0x0A,
|
||||
Lucia = 0x0B,
|
||||
Lagon = 0x0C,
|
||||
Lager = 0x0D,
|
||||
};
|
||||
|
||||
enum class PadAxes {
|
||||
|
@ -143,9 +149,10 @@ enum class SubCommand : u8 {
|
|||
ENABLE_VIBRATION = 0x48,
|
||||
GET_REGULATED_VOLTAGE = 0x50,
|
||||
SET_EXTERNAL_CONFIG = 0x58,
|
||||
UNKNOWN_RINGCON = 0x59,
|
||||
UNKNOWN_RINGCON2 = 0x5A,
|
||||
UNKNOWN_RINGCON3 = 0x5C,
|
||||
GET_EXTERNAL_DEVICE_INFO = 0x59,
|
||||
ENABLE_EXTERNAL_POLLING = 0x5A,
|
||||
DISABLE_EXTERNAL_POLLING = 0x5B,
|
||||
SET_EXTERNAL_FORMAT_CONFIG = 0x5C,
|
||||
};
|
||||
|
||||
enum class UsbSubCommand : u8 {
|
||||
|
@ -165,19 +172,25 @@ enum class CalibrationMagic : u8 {
|
|||
};
|
||||
|
||||
enum class SpiAddress {
|
||||
SERIAL_NUMBER = 0X6000,
|
||||
DEVICE_TYPE = 0X6012,
|
||||
COLOR_EXIST = 0X601B,
|
||||
FACT_LEFT_DATA = 0X603d,
|
||||
FACT_RIGHT_DATA = 0X6046,
|
||||
COLOR_DATA = 0X6050,
|
||||
FACT_IMU_DATA = 0X6020,
|
||||
USER_LEFT_MAGIC = 0X8010,
|
||||
USER_LEFT_DATA = 0X8012,
|
||||
USER_RIGHT_MAGIC = 0X801B,
|
||||
USER_RIGHT_DATA = 0X801D,
|
||||
USER_IMU_MAGIC = 0X8026,
|
||||
USER_IMU_DATA = 0X8028,
|
||||
MAGIC = 0x0000,
|
||||
MAC_ADDRESS = 0x0015,
|
||||
PAIRING_INFO = 0x2000,
|
||||
SHIPMENT = 0x5000,
|
||||
SERIAL_NUMBER = 0x6000,
|
||||
DEVICE_TYPE = 0x6012,
|
||||
FORMAT_VERSION = 0x601B,
|
||||
FACT_IMU_DATA = 0x6020,
|
||||
FACT_LEFT_DATA = 0x603d,
|
||||
FACT_RIGHT_DATA = 0x6046,
|
||||
COLOR_DATA = 0x6050,
|
||||
DESIGN_VARIATION = 0x605C,
|
||||
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 {
|
||||
|
@ -359,6 +372,11 @@ enum class IrRegistersAddress : u16 {
|
|||
DenoiseColor = 0x6901,
|
||||
};
|
||||
|
||||
enum class ExternalDeviceId : u8 {
|
||||
RingController = 0x20,
|
||||
Starlink = 0x28,
|
||||
};
|
||||
|
||||
enum class DriverResult {
|
||||
Success,
|
||||
WrongReply,
|
||||
|
@ -605,9 +623,11 @@ static_assert(sizeof(FirmwareVersion) == 0x2, "FirmwareVersion is an invalid siz
|
|||
|
||||
struct DeviceInfo {
|
||||
FirmwareVersion firmware;
|
||||
std::array<u8, 2> unknown_1;
|
||||
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 {
|
||||
bool is_enabled;
|
||||
|
|
|
@ -31,9 +31,7 @@ void JoyconPoller::ReadActiveMode(std::span<u8> buffer, const MotionStatus& moti
|
|||
case Joycon::ControllerType::Pro:
|
||||
UpdateActiveProPadInput(data, motion_status);
|
||||
break;
|
||||
case Joycon::ControllerType::Grip:
|
||||
case Joycon::ControllerType::Dual:
|
||||
case Joycon::ControllerType::None:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -58,9 +56,7 @@ void JoyconPoller::ReadPassiveMode(std::span<u8> buffer) {
|
|||
case Joycon::ControllerType::Pro:
|
||||
UpdatePasiveProPadInput(data);
|
||||
break;
|
||||
case Joycon::ControllerType::Grip:
|
||||
case Joycon::ControllerType::Dual:
|
||||
case Joycon::ControllerType::None:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,14 +70,12 @@ DriverResult RingConProtocol::StartRingconPolling() {
|
|||
DriverResult RingConProtocol::IsRingConnected(bool& is_connected) {
|
||||
LOG_DEBUG(Input, "IsRingConnected");
|
||||
constexpr std::size_t max_tries = 28;
|
||||
constexpr u8 ring_controller_id = 0x20;
|
||||
std::vector<u8> output;
|
||||
std::size_t tries = 0;
|
||||
is_connected = false;
|
||||
|
||||
do {
|
||||
std::array<u8, 1> empty_data{};
|
||||
const auto result = SendSubCommand(SubCommand::UNKNOWN_RINGCON, empty_data, output);
|
||||
const auto result = SendSubCommand(SubCommand::GET_EXTERNAL_DEVICE_INFO, {}, output);
|
||||
|
||||
if (result != DriverResult::Success) {
|
||||
return result;
|
||||
|
@ -86,7 +84,7 @@ DriverResult RingConProtocol::IsRingConnected(bool& is_connected) {
|
|||
if (tries++ >= max_tries) {
|
||||
return DriverResult::NoDeviceDetected;
|
||||
}
|
||||
} while (output[16] != ring_controller_id);
|
||||
} while (output[16] != static_cast<u8>(ExternalDeviceId::RingController));
|
||||
|
||||
is_connected = true;
|
||||
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, 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) {
|
||||
return result;
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
Loading…
Reference in New Issue