1 Commits

Author SHA1 Message Date
66ccd77115 yuzu: config: Remove most special config cases for handheld 2023-06-06 17:39:12 -06:00
7 changed files with 33 additions and 221 deletions

View File

@ -111,16 +111,25 @@ void EmulatedController::ReloadFromSettings() {
ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs);
// Other or debug controller should always be a pro controller
if (npad_id_type != NpadIdType::Other) {
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
original_npad_type = npad_type;
} else {
SetNpadStyleIndex(NpadStyleIndex::ProController);
original_npad_type = npad_type;
// Player 1 shares config with handheld. Disable controller when handheld is selected
// if (npad_id_type == NpadIdType::Player1 && npad_type == NpadStyleIndex::Handheld) {
// Disconnect();
// ReloadInput();
// return;
//}
// 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();
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
original_npad_type = npad_type;
if (player.connected) {
Connect();
}
@ -593,8 +602,14 @@ bool EmulatedController::IsConfiguring() const {
}
void EmulatedController::SaveCurrentConfig() {
const auto player_index = NpadIdTypeToIndex(npad_id_type);
// Other and Handheld can't alter the config from here
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];
player.connected = is_connected;
player.controller_type = MapNPadToSettingsType(npad_type);
for (std::size_t index = 0; index < player.buttons.size(); ++index) {

View File

@ -388,32 +388,6 @@ enum class ExternalDeviceId : u16 {
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 {
Success,
WrongReply,
@ -713,57 +687,6 @@ struct RingStatus {
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 {
OutputReport output_report;
u8 packet_counter;

View File

@ -108,65 +108,6 @@ DriverResult RingConProtocol::ConfigureRing() {
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 {
return is_enabled;
}

View File

@ -25,9 +25,6 @@ public:
DriverResult StartRingconPolling();
// Hidbus can send individual commands to the ring each one with an unique reply
DriverResult SendCommand(RingConCommand command);
bool IsEnabled() const;
private:

View File

@ -196,6 +196,7 @@ void ConfigureInput::ApplyConfiguration() {
}
advanced->ApplyConfiguration();
system.HIDCore().ReloadInputDevices();
const bool pre_docked_mode = Settings::values.use_docked_mode.GetValue();
Settings::values.use_docked_mode.SetValue(ui->radioDocked->isChecked());

View File

@ -89,17 +89,12 @@ void ConfigureInputPerGame::LoadConfiguration() {
emulated_controller->ReloadFromSettings();
if (player_index > 0) {
if (player_index != HANDHELD_INDEX) {
continue;
}
// Handle Handheld cases
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 = {};
}
auto handheld_controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
handheld_controller->ReloadFromSettings();
}
}

View File

@ -296,26 +296,11 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
is_powered_on{is_powered_on_}, input_subsystem{input_subsystem_}, profiles(profiles_),
timeout_timer(std::make_unique<QTimer>()),
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->SaveCurrentConfig();
emulated_controller->EnableConfiguration();
}
emulated_controller = hid_core.GetEmulatedControllerByIndex(player_index);
emulated_controller->SaveCurrentConfig();
emulated_controller->EnableConfiguration();
ui->setupUi(this);
setFocusPolicy(Qt::ClickFocus);
@ -747,29 +732,6 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
UpdateMotionButtons();
const Core::HID::NpadStyleIndex type =
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);
});
@ -805,32 +767,10 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
}
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() {
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->SaveCurrentConfig();
emulated_controller->EnableConfiguration();