Compare commits
1 Commits
burning-pr
...
ring_proto
Author | SHA1 | Date | |
---|---|---|---|
0495a13e31 |
@ -111,25 +111,16 @@ void EmulatedController::ReloadFromSettings() {
|
|||||||
|
|
||||||
ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs);
|
ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs);
|
||||||
|
|
||||||
// Player 1 shares config with handheld. Disable controller when handheld is selected
|
// Other or debug controller should always be a pro controller
|
||||||
// if (npad_id_type == NpadIdType::Player1 && npad_type == NpadStyleIndex::Handheld) {
|
if (npad_id_type != NpadIdType::Other) {
|
||||||
// Disconnect();
|
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
|
||||||
// ReloadInput();
|
original_npad_type = npad_type;
|
||||||
// return;
|
} else {
|
||||||
//}
|
SetNpadStyleIndex(NpadStyleIndex::ProController);
|
||||||
|
original_npad_type = npad_type;
|
||||||
// Handheld shares config with player 1. Disable controller when handheld isn't selected
|
|
||||||
if (npad_id_type == NpadIdType::Handheld && npad_type != NpadStyleIndex::Handheld) {
|
|
||||||
Disconnect();
|
|
||||||
ReloadInput();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Disconnect();
|
Disconnect();
|
||||||
|
|
||||||
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
|
|
||||||
original_npad_type = npad_type;
|
|
||||||
|
|
||||||
if (player.connected) {
|
if (player.connected) {
|
||||||
Connect();
|
Connect();
|
||||||
}
|
}
|
||||||
@ -602,14 +593,8 @@ bool EmulatedController::IsConfiguring() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EmulatedController::SaveCurrentConfig() {
|
void EmulatedController::SaveCurrentConfig() {
|
||||||
// Other and Handheld can't alter the config from here
|
const auto player_index = NpadIdTypeToIndex(npad_id_type);
|
||||||
if (npad_id_type == NpadIdType::Other || npad_id_type == NpadIdType::Handheld) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto player_index = NpadIdTypeToConfigIndex(npad_id_type);
|
|
||||||
auto& player = Settings::values.players.GetValue()[player_index];
|
auto& player = Settings::values.players.GetValue()[player_index];
|
||||||
|
|
||||||
player.connected = is_connected;
|
player.connected = is_connected;
|
||||||
player.controller_type = MapNPadToSettingsType(npad_type);
|
player.controller_type = MapNPadToSettingsType(npad_type);
|
||||||
for (std::size_t index = 0; index < player.buttons.size(); ++index) {
|
for (std::size_t index = 0; index < player.buttons.size(); ++index) {
|
||||||
|
@ -388,6 +388,32 @@ enum class ExternalDeviceId : u16 {
|
|||||||
Starlink = 0x2800,
|
Starlink = 0x2800,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Most missing command names are leftovers from other firmware versions
|
||||||
|
enum class RingConCommand : u32 {
|
||||||
|
GetFirmwareVersion = 0x00020000,
|
||||||
|
ReadId = 0x00020100,
|
||||||
|
JoyPolling = 0x00020101,
|
||||||
|
Unknown1 = 0x00020104,
|
||||||
|
c20105 = 0x00020105,
|
||||||
|
Unknown2 = 0x00020204,
|
||||||
|
Unknown3 = 0x00020304,
|
||||||
|
Unknown4 = 0x00020404,
|
||||||
|
ReadUnkCal = 0x00020504,
|
||||||
|
ReadFactoryCal = 0x00020A04,
|
||||||
|
Unknown5 = 0x00021104,
|
||||||
|
Unknown6 = 0x00021204,
|
||||||
|
Unknown7 = 0x00021304,
|
||||||
|
ReadUserCal = 0x00021A04,
|
||||||
|
ReadRepCount = 0x00023104,
|
||||||
|
ReadTotalPushCount = 0x00023204,
|
||||||
|
ResetRepCount = 0x04013104,
|
||||||
|
Unknown8 = 0x04011104,
|
||||||
|
Unknown9 = 0x04011204,
|
||||||
|
Unknown10 = 0x04011304,
|
||||||
|
SaveCalData = 0x10011A04,
|
||||||
|
Error = 0xFFFFFFFF,
|
||||||
|
};
|
||||||
|
|
||||||
enum class DriverResult {
|
enum class DriverResult {
|
||||||
Success,
|
Success,
|
||||||
WrongReply,
|
WrongReply,
|
||||||
@ -687,6 +713,57 @@ struct RingStatus {
|
|||||||
s16 min_value;
|
s16 min_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
struct RingCommandData {
|
||||||
|
u8 data_type;
|
||||||
|
RingConCommand command;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(RingCommandData) == 0x5, "RingCommandData is an invalid size");
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
struct RingFactoryCalibration {
|
||||||
|
s32_le os_max;
|
||||||
|
s32_le hk_max;
|
||||||
|
s32_le zero_min;
|
||||||
|
s32_le zero_max;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(RingFactoryCalibration) == 0x10, "RingFactoryCalibration is an invalid size");
|
||||||
|
|
||||||
|
struct RingCalibrationValue {
|
||||||
|
s16 value;
|
||||||
|
u16 crc;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(RingCalibrationValue) == 0x4, "RingCalibrationValue is an invalid size");
|
||||||
|
|
||||||
|
struct RingUserCalibration {
|
||||||
|
RingCalibrationValue os_max;
|
||||||
|
RingCalibrationValue hk_max;
|
||||||
|
RingCalibrationValue zero;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(RingUserCalibration) == 0xC, "RingUserCalibration is an invalid size");
|
||||||
|
|
||||||
|
struct RingReadId {
|
||||||
|
u16 id_l_x0;
|
||||||
|
u16 id_l_x0_2;
|
||||||
|
u16 id_l_x4;
|
||||||
|
u16 id_h_x0;
|
||||||
|
u16 id_h_x0_2;
|
||||||
|
u16 id_h_x4;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(RingReadId) == 0xC, "RingReadId is an invalid size");
|
||||||
|
|
||||||
|
struct RingCommandReply {
|
||||||
|
DriverResult result;
|
||||||
|
RingConCommand command;
|
||||||
|
FirmwareVersion firmware;
|
||||||
|
RingFactoryCalibration factory_calibration;
|
||||||
|
RingUserCalibration user_calibration;
|
||||||
|
RingReadId read_id;
|
||||||
|
u8 c20105;
|
||||||
|
u8 total_push_count;
|
||||||
|
u8 total_rep_count;
|
||||||
|
};
|
||||||
|
|
||||||
struct VibrationPacket {
|
struct VibrationPacket {
|
||||||
OutputReport output_report;
|
OutputReport output_report;
|
||||||
u8 packet_counter;
|
u8 packet_counter;
|
||||||
|
@ -108,6 +108,65 @@ DriverResult RingConProtocol::ConfigureRing() {
|
|||||||
return SendSubCommand(SubCommand::ENABLE_EXTERNAL_POLLING, ringcon_data);
|
return SendSubCommand(SubCommand::ENABLE_EXTERNAL_POLLING, ringcon_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DriverResult RingConProtocol::SendCommand(RingConCommand command) {
|
||||||
|
SubCommandResponce output{};
|
||||||
|
RingCommandData data{
|
||||||
|
.data_type = 0x04, // This seems to be always 4 for this command
|
||||||
|
.command = command,
|
||||||
|
};
|
||||||
|
RingCommandReply reply{
|
||||||
|
.result = DriverResult::Success,
|
||||||
|
.command = command,
|
||||||
|
};
|
||||||
|
|
||||||
|
std::array<u8, sizeof(RingCommandData)> raw_data{};
|
||||||
|
memcpy(raw_data.data(), &data, sizeof(RingCommandData));
|
||||||
|
const DriverResult result = SendSubCommand(SubCommand::SET_EXTERNAL_CONFIG, raw_data, output);
|
||||||
|
|
||||||
|
if (result != DriverResult::Success) {
|
||||||
|
reply.result = result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (command) {
|
||||||
|
case RingConCommand::GetFirmwareVersion:
|
||||||
|
memcpy(&reply.firmware, output.command_data.data() + 6, sizeof(FirmwareVersion));
|
||||||
|
break;
|
||||||
|
case RingConCommand::ReadId:
|
||||||
|
memcpy(&reply.read_id, output.command_data.data() + 6,
|
||||||
|
sizeof(RingReadId));
|
||||||
|
break;
|
||||||
|
case RingConCommand::c20105:
|
||||||
|
reply.c20105 = output.command_data[6];
|
||||||
|
break;
|
||||||
|
case RingConCommand::ReadUnkCal:
|
||||||
|
break;
|
||||||
|
case RingConCommand::ReadFactoryCal:
|
||||||
|
memcpy(&reply.factory_calibration, output.command_data.data() + 6,
|
||||||
|
sizeof(RingFactoryCalibration));
|
||||||
|
break;
|
||||||
|
case RingConCommand::ReadUserCal:
|
||||||
|
memcpy(&reply.user_calibration, output.command_data.data() + 6, sizeof(RingUserCalibration));
|
||||||
|
break;
|
||||||
|
case RingConCommand::ReadRepCount:
|
||||||
|
reply.total_rep_count = output.command_data[6];
|
||||||
|
break;
|
||||||
|
case RingConCommand::ReadTotalPushCount:
|
||||||
|
reply.total_push_count = output.command_data[6];
|
||||||
|
break;
|
||||||
|
case RingConCommand::ResetRepCount:
|
||||||
|
break;
|
||||||
|
case RingConCommand::SaveCalData:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
reply.result = DriverResult::NotSupported;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
bool RingConProtocol::IsEnabled() const {
|
bool RingConProtocol::IsEnabled() const {
|
||||||
return is_enabled;
|
return is_enabled;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,9 @@ public:
|
|||||||
|
|
||||||
DriverResult StartRingconPolling();
|
DriverResult StartRingconPolling();
|
||||||
|
|
||||||
|
// Hidbus can send individual commands to the ring each one with an unique reply
|
||||||
|
DriverResult SendCommand(RingConCommand command);
|
||||||
|
|
||||||
bool IsEnabled() const;
|
bool IsEnabled() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -196,7 +196,6 @@ void ConfigureInput::ApplyConfiguration() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
advanced->ApplyConfiguration();
|
advanced->ApplyConfiguration();
|
||||||
system.HIDCore().ReloadInputDevices();
|
|
||||||
|
|
||||||
const bool pre_docked_mode = Settings::values.use_docked_mode.GetValue();
|
const bool pre_docked_mode = Settings::values.use_docked_mode.GetValue();
|
||||||
Settings::values.use_docked_mode.SetValue(ui->radioDocked->isChecked());
|
Settings::values.use_docked_mode.SetValue(ui->radioDocked->isChecked());
|
||||||
|
@ -89,12 +89,17 @@ void ConfigureInputPerGame::LoadConfiguration() {
|
|||||||
|
|
||||||
emulated_controller->ReloadFromSettings();
|
emulated_controller->ReloadFromSettings();
|
||||||
|
|
||||||
if (player_index != HANDHELD_INDEX) {
|
if (player_index > 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle Handheld cases
|
// Handle Handheld cases
|
||||||
auto handheld_controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
auto& handheld_player = Settings::values.players.GetValue()[HANDHELD_INDEX];
|
||||||
|
auto* handheld_controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||||
|
if (player.controller_type == Settings::ControllerType::Handheld) {
|
||||||
|
handheld_player = player;
|
||||||
|
} else {
|
||||||
|
handheld_player = {};
|
||||||
|
}
|
||||||
handheld_controller->ReloadFromSettings();
|
handheld_controller->ReloadFromSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,11 +296,26 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
|||||||
is_powered_on{is_powered_on_}, input_subsystem{input_subsystem_}, profiles(profiles_),
|
is_powered_on{is_powered_on_}, input_subsystem{input_subsystem_}, profiles(profiles_),
|
||||||
timeout_timer(std::make_unique<QTimer>()),
|
timeout_timer(std::make_unique<QTimer>()),
|
||||||
poll_timer(std::make_unique<QTimer>()), bottom_row{bottom_row_}, hid_core{hid_core_} {
|
poll_timer(std::make_unique<QTimer>()), bottom_row{bottom_row_}, hid_core{hid_core_} {
|
||||||
|
if (player_index == 0) {
|
||||||
|
auto* emulated_controller_p1 =
|
||||||
|
hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
|
||||||
|
auto* emulated_controller_handheld =
|
||||||
|
hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||||
|
emulated_controller_p1->SaveCurrentConfig();
|
||||||
|
emulated_controller_p1->EnableConfiguration();
|
||||||
|
emulated_controller_handheld->SaveCurrentConfig();
|
||||||
|
emulated_controller_handheld->EnableConfiguration();
|
||||||
|
if (emulated_controller_handheld->IsConnected(true)) {
|
||||||
|
emulated_controller_p1->Disconnect();
|
||||||
|
emulated_controller = emulated_controller_handheld;
|
||||||
|
} else {
|
||||||
|
emulated_controller = emulated_controller_p1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
emulated_controller = hid_core.GetEmulatedControllerByIndex(player_index);
|
emulated_controller = hid_core.GetEmulatedControllerByIndex(player_index);
|
||||||
emulated_controller->SaveCurrentConfig();
|
emulated_controller->SaveCurrentConfig();
|
||||||
emulated_controller->EnableConfiguration();
|
emulated_controller->EnableConfiguration();
|
||||||
|
}
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
setFocusPolicy(Qt::ClickFocus);
|
setFocusPolicy(Qt::ClickFocus);
|
||||||
@ -732,6 +747,29 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
|||||||
UpdateMotionButtons();
|
UpdateMotionButtons();
|
||||||
const Core::HID::NpadStyleIndex type =
|
const Core::HID::NpadStyleIndex type =
|
||||||
GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
|
GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
|
||||||
|
|
||||||
|
if (player_index == 0) {
|
||||||
|
auto* emulated_controller_p1 =
|
||||||
|
hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
|
||||||
|
auto* emulated_controller_handheld =
|
||||||
|
hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||||
|
bool is_connected = emulated_controller->IsConnected(true);
|
||||||
|
|
||||||
|
emulated_controller_p1->SetNpadStyleIndex(type);
|
||||||
|
emulated_controller_handheld->SetNpadStyleIndex(type);
|
||||||
|
if (is_connected) {
|
||||||
|
if (type == Core::HID::NpadStyleIndex::Handheld) {
|
||||||
|
emulated_controller_p1->Disconnect();
|
||||||
|
emulated_controller_handheld->Connect(true);
|
||||||
|
emulated_controller = emulated_controller_handheld;
|
||||||
|
} else {
|
||||||
|
emulated_controller_handheld->Disconnect();
|
||||||
|
emulated_controller_p1->Connect(true);
|
||||||
|
emulated_controller = emulated_controller_p1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui->controllerFrame->SetController(emulated_controller);
|
||||||
|
}
|
||||||
emulated_controller->SetNpadStyleIndex(type);
|
emulated_controller->SetNpadStyleIndex(type);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -767,10 +805,32 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConfigureInputPlayer::~ConfigureInputPlayer() {
|
ConfigureInputPlayer::~ConfigureInputPlayer() {
|
||||||
|
if (player_index == 0) {
|
||||||
|
auto* emulated_controller_p1 =
|
||||||
|
hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
|
||||||
|
auto* emulated_controller_handheld =
|
||||||
|
hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||||
|
emulated_controller_p1->DisableConfiguration();
|
||||||
|
emulated_controller_handheld->DisableConfiguration();
|
||||||
|
} else {
|
||||||
emulated_controller->DisableConfiguration();
|
emulated_controller->DisableConfiguration();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigureInputPlayer::ApplyConfiguration() {
|
void ConfigureInputPlayer::ApplyConfiguration() {
|
||||||
|
if (player_index == 0) {
|
||||||
|
auto* emulated_controller_p1 =
|
||||||
|
hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
|
||||||
|
auto* emulated_controller_handheld =
|
||||||
|
hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||||
|
emulated_controller_p1->DisableConfiguration();
|
||||||
|
emulated_controller_p1->SaveCurrentConfig();
|
||||||
|
emulated_controller_p1->EnableConfiguration();
|
||||||
|
emulated_controller_handheld->DisableConfiguration();
|
||||||
|
emulated_controller_handheld->SaveCurrentConfig();
|
||||||
|
emulated_controller_handheld->EnableConfiguration();
|
||||||
|
return;
|
||||||
|
}
|
||||||
emulated_controller->DisableConfiguration();
|
emulated_controller->DisableConfiguration();
|
||||||
emulated_controller->SaveCurrentConfig();
|
emulated_controller->SaveCurrentConfig();
|
||||||
emulated_controller->EnableConfiguration();
|
emulated_controller->EnableConfiguration();
|
||||||
|
Reference in New Issue
Block a user