Merge pull request #8123 from german77/bombslinger
service: hid: Remove inaccurate behavior on initialization
This commit is contained in:
commit
b5910ad0ba
@ -262,11 +262,6 @@ void Controller_NPad::OnInit() {
|
|||||||
service_context.CreateEvent(fmt::format("npad:NpadStyleSetChanged_{}", i));
|
service_context.CreateEvent(fmt::format("npad:NpadStyleSetChanged_{}", i));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hid_core.GetSupportedStyleTag().raw == Core::HID::NpadStyleSet::None) {
|
|
||||||
// We want to support all controllers
|
|
||||||
hid_core.SetSupportedStyleTag({Core::HID::NpadStyleSet::All});
|
|
||||||
}
|
|
||||||
|
|
||||||
supported_npad_id_types.resize(npad_id_list.size());
|
supported_npad_id_types.resize(npad_id_list.size());
|
||||||
std::memcpy(supported_npad_id_types.data(), npad_id_list.data(),
|
std::memcpy(supported_npad_id_types.data(), npad_id_list.data(),
|
||||||
npad_id_list.size() * sizeof(Core::HID::NpadIdType));
|
npad_id_list.size() * sizeof(Core::HID::NpadIdType));
|
||||||
@ -288,14 +283,6 @@ void Controller_NPad::OnInit() {
|
|||||||
WriteEmptyEntry(npad);
|
WriteEmptyEntry(npad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect controllers
|
|
||||||
for (auto& controller : controller_data) {
|
|
||||||
const auto& device = controller.device;
|
|
||||||
if (device->IsConnected()) {
|
|
||||||
AddNewControllerAt(device->GetNpadStyleIndex(), device->GetNpadIdType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_NPad::WriteEmptyEntry(NpadInternalState& npad) {
|
void Controller_NPad::WriteEmptyEntry(NpadInternalState& npad) {
|
||||||
@ -320,6 +307,7 @@ void Controller_NPad::WriteEmptyEntry(NpadInternalState& npad) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Controller_NPad::OnRelease() {
|
void Controller_NPad::OnRelease() {
|
||||||
|
is_controller_initialized = false;
|
||||||
for (std::size_t i = 0; i < controller_data.size(); ++i) {
|
for (std::size_t i = 0; i < controller_data.size(); ++i) {
|
||||||
auto& controller = controller_data[i];
|
auto& controller = controller_data[i];
|
||||||
service_context.CloseEvent(controller.styleset_changed_event);
|
service_context.CloseEvent(controller.styleset_changed_event);
|
||||||
@ -651,9 +639,27 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing
|
|||||||
|
|
||||||
void Controller_NPad::SetSupportedStyleSet(Core::HID::NpadStyleTag style_set) {
|
void Controller_NPad::SetSupportedStyleSet(Core::HID::NpadStyleTag style_set) {
|
||||||
hid_core.SetSupportedStyleTag(style_set);
|
hid_core.SetSupportedStyleTag(style_set);
|
||||||
|
|
||||||
|
if (is_controller_initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Once SetSupportedStyleSet is called controllers are fully initialized
|
||||||
|
is_controller_initialized = true;
|
||||||
|
|
||||||
|
// Connect all active controllers
|
||||||
|
for (auto& controller : controller_data) {
|
||||||
|
const auto& device = controller.device;
|
||||||
|
if (device->IsConnected()) {
|
||||||
|
AddNewControllerAt(device->GetNpadStyleIndex(), device->GetNpadIdType());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::HID::NpadStyleTag Controller_NPad::GetSupportedStyleSet() const {
|
Core::HID::NpadStyleTag Controller_NPad::GetSupportedStyleSet() const {
|
||||||
|
if (!is_controller_initialized) {
|
||||||
|
return {Core::HID::NpadStyleSet::None};
|
||||||
|
}
|
||||||
return hid_core.GetSupportedStyleTag();
|
return hid_core.GetSupportedStyleTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,16 +191,16 @@ private:
|
|||||||
|
|
||||||
// This is nn::hid::detail::NpadFullKeyColorState
|
// This is nn::hid::detail::NpadFullKeyColorState
|
||||||
struct NpadFullKeyColorState {
|
struct NpadFullKeyColorState {
|
||||||
ColorAttribute attribute;
|
ColorAttribute attribute{ColorAttribute::NoController};
|
||||||
Core::HID::NpadControllerColor fullkey;
|
Core::HID::NpadControllerColor fullkey{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(NpadFullKeyColorState) == 0xC, "NpadFullKeyColorState is an invalid size");
|
static_assert(sizeof(NpadFullKeyColorState) == 0xC, "NpadFullKeyColorState is an invalid size");
|
||||||
|
|
||||||
// This is nn::hid::detail::NpadJoyColorState
|
// This is nn::hid::detail::NpadJoyColorState
|
||||||
struct NpadJoyColorState {
|
struct NpadJoyColorState {
|
||||||
ColorAttribute attribute;
|
ColorAttribute attribute{ColorAttribute::NoController};
|
||||||
Core::HID::NpadControllerColor left;
|
Core::HID::NpadControllerColor left{};
|
||||||
Core::HID::NpadControllerColor right;
|
Core::HID::NpadControllerColor right{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(NpadJoyColorState) == 0x14, "NpadJoyColorState is an invalid size");
|
static_assert(sizeof(NpadJoyColorState) == 0x14, "NpadJoyColorState is an invalid size");
|
||||||
|
|
||||||
@ -226,11 +226,11 @@ private:
|
|||||||
// This is nn::hid::NpadPalmaState
|
// This is nn::hid::NpadPalmaState
|
||||||
// This is nn::hid::NpadSystemExtState
|
// This is nn::hid::NpadSystemExtState
|
||||||
struct NPadGenericState {
|
struct NPadGenericState {
|
||||||
s64_le sampling_number;
|
s64_le sampling_number{};
|
||||||
Core::HID::NpadButtonState npad_buttons;
|
Core::HID::NpadButtonState npad_buttons{};
|
||||||
Core::HID::AnalogStickState l_stick;
|
Core::HID::AnalogStickState l_stick{};
|
||||||
Core::HID::AnalogStickState r_stick;
|
Core::HID::AnalogStickState r_stick{};
|
||||||
NpadAttribute connection_status;
|
NpadAttribute connection_status{};
|
||||||
INSERT_PADDING_BYTES(4); // Reserved
|
INSERT_PADDING_BYTES(4); // Reserved
|
||||||
};
|
};
|
||||||
static_assert(sizeof(NPadGenericState) == 0x28, "NPadGenericState is an invalid size");
|
static_assert(sizeof(NPadGenericState) == 0x28, "NPadGenericState is an invalid size");
|
||||||
@ -253,7 +253,7 @@ private:
|
|||||||
Common::Vec3f gyro{};
|
Common::Vec3f gyro{};
|
||||||
Common::Vec3f rotation{};
|
Common::Vec3f rotation{};
|
||||||
std::array<Common::Vec3f, 3> orientation{};
|
std::array<Common::Vec3f, 3> orientation{};
|
||||||
SixAxisSensorAttribute attribute;
|
SixAxisSensorAttribute attribute{};
|
||||||
INSERT_PADDING_BYTES(4); // Reserved
|
INSERT_PADDING_BYTES(4); // Reserved
|
||||||
};
|
};
|
||||||
static_assert(sizeof(SixAxisSensorState) == 0x60, "SixAxisSensorState is an invalid size");
|
static_assert(sizeof(SixAxisSensorState) == 0x60, "SixAxisSensorState is an invalid size");
|
||||||
@ -325,11 +325,11 @@ private:
|
|||||||
|
|
||||||
// This is nn::hid::detail::NfcXcdDeviceHandleStateImpl
|
// This is nn::hid::detail::NfcXcdDeviceHandleStateImpl
|
||||||
struct NfcXcdDeviceHandleStateImpl {
|
struct NfcXcdDeviceHandleStateImpl {
|
||||||
u64 handle;
|
u64 handle{};
|
||||||
bool is_available;
|
bool is_available{};
|
||||||
bool is_activated;
|
bool is_activated{};
|
||||||
INSERT_PADDING_BYTES(0x6); // Reserved
|
INSERT_PADDING_BYTES(0x6); // Reserved
|
||||||
u64 sampling_number;
|
u64 sampling_number{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(NfcXcdDeviceHandleStateImpl) == 0x18,
|
static_assert(sizeof(NfcXcdDeviceHandleStateImpl) == 0x18,
|
||||||
"NfcXcdDeviceHandleStateImpl is an invalid size");
|
"NfcXcdDeviceHandleStateImpl is an invalid size");
|
||||||
@ -366,8 +366,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct AppletFooterUi {
|
struct AppletFooterUi {
|
||||||
AppletFooterUiAttributes attributes;
|
AppletFooterUiAttributes attributes{};
|
||||||
AppletFooterUiType type;
|
AppletFooterUiType type{AppletFooterUiType::None};
|
||||||
INSERT_PADDING_BYTES(0x5B); // Reserved
|
INSERT_PADDING_BYTES(0x5B); // Reserved
|
||||||
};
|
};
|
||||||
static_assert(sizeof(AppletFooterUi) == 0x60, "AppletFooterUi is an invalid size");
|
static_assert(sizeof(AppletFooterUi) == 0x60, "AppletFooterUi is an invalid size");
|
||||||
@ -404,41 +404,41 @@ private:
|
|||||||
|
|
||||||
// This is nn::hid::detail::NpadInternalState
|
// This is nn::hid::detail::NpadInternalState
|
||||||
struct NpadInternalState {
|
struct NpadInternalState {
|
||||||
Core::HID::NpadStyleTag style_tag;
|
Core::HID::NpadStyleTag style_tag{Core::HID::NpadStyleSet::None};
|
||||||
NpadJoyAssignmentMode assignment_mode;
|
NpadJoyAssignmentMode assignment_mode{NpadJoyAssignmentMode::Dual};
|
||||||
NpadFullKeyColorState fullkey_color;
|
NpadFullKeyColorState fullkey_color{};
|
||||||
NpadJoyColorState joycon_color;
|
NpadJoyColorState joycon_color{};
|
||||||
Lifo<NPadGenericState, hid_entry_count> fullkey_lifo;
|
Lifo<NPadGenericState, hid_entry_count> fullkey_lifo{};
|
||||||
Lifo<NPadGenericState, hid_entry_count> handheld_lifo;
|
Lifo<NPadGenericState, hid_entry_count> handheld_lifo{};
|
||||||
Lifo<NPadGenericState, hid_entry_count> joy_dual_lifo;
|
Lifo<NPadGenericState, hid_entry_count> joy_dual_lifo{};
|
||||||
Lifo<NPadGenericState, hid_entry_count> joy_left_lifo;
|
Lifo<NPadGenericState, hid_entry_count> joy_left_lifo{};
|
||||||
Lifo<NPadGenericState, hid_entry_count> joy_right_lifo;
|
Lifo<NPadGenericState, hid_entry_count> joy_right_lifo{};
|
||||||
Lifo<NPadGenericState, hid_entry_count> palma_lifo;
|
Lifo<NPadGenericState, hid_entry_count> palma_lifo{};
|
||||||
Lifo<NPadGenericState, hid_entry_count> system_ext_lifo;
|
Lifo<NPadGenericState, hid_entry_count> system_ext_lifo{};
|
||||||
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_fullkey_lifo;
|
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_fullkey_lifo{};
|
||||||
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_handheld_lifo;
|
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_handheld_lifo{};
|
||||||
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_dual_left_lifo;
|
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_dual_left_lifo{};
|
||||||
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_dual_right_lifo;
|
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_dual_right_lifo{};
|
||||||
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_left_lifo;
|
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_left_lifo{};
|
||||||
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_right_lifo;
|
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_right_lifo{};
|
||||||
DeviceType device_type;
|
DeviceType device_type{};
|
||||||
INSERT_PADDING_BYTES(0x4); // Reserved
|
INSERT_PADDING_BYTES(0x4); // Reserved
|
||||||
NPadSystemProperties system_properties;
|
NPadSystemProperties system_properties{};
|
||||||
NpadSystemButtonProperties button_properties;
|
NpadSystemButtonProperties button_properties{};
|
||||||
Core::HID::NpadBatteryLevel battery_level_dual;
|
Core::HID::NpadBatteryLevel battery_level_dual{};
|
||||||
Core::HID::NpadBatteryLevel battery_level_left;
|
Core::HID::NpadBatteryLevel battery_level_left{};
|
||||||
Core::HID::NpadBatteryLevel battery_level_right;
|
Core::HID::NpadBatteryLevel battery_level_right{};
|
||||||
union {
|
union {
|
||||||
Lifo<NfcXcdDeviceHandleStateImpl, 0x2> nfc_xcd_device_lifo{};
|
AppletFooterUi applet_footer{};
|
||||||
AppletFooterUi applet_footer;
|
Lifo<NfcXcdDeviceHandleStateImpl, 0x2> nfc_xcd_device_lifo;
|
||||||
};
|
};
|
||||||
INSERT_PADDING_BYTES(0x20); // Unknown
|
INSERT_PADDING_BYTES(0x20); // Unknown
|
||||||
Lifo<NpadGcTriggerState, hid_entry_count> gc_trigger_lifo;
|
Lifo<NpadGcTriggerState, hid_entry_count> gc_trigger_lifo{};
|
||||||
NpadLarkType lark_type_l_and_main;
|
NpadLarkType lark_type_l_and_main{};
|
||||||
NpadLarkType lark_type_r;
|
NpadLarkType lark_type_r{};
|
||||||
NpadLuciaType lucia_type;
|
NpadLuciaType lucia_type{};
|
||||||
NpadLagonType lagon_type;
|
NpadLagonType lagon_type{};
|
||||||
NpadLagerType lager_type;
|
NpadLagerType lager_type{};
|
||||||
// FW 13.x Investigate there is some sort of bitflag related to joycons
|
// FW 13.x Investigate there is some sort of bitflag related to joycons
|
||||||
INSERT_PADDING_BYTES(0x4);
|
INSERT_PADDING_BYTES(0x4);
|
||||||
INSERT_PADDING_BYTES(0xc08); // Unknown
|
INSERT_PADDING_BYTES(0xc08); // Unknown
|
||||||
@ -511,7 +511,8 @@ private:
|
|||||||
NpadHandheldActivationMode handheld_activation_mode{NpadHandheldActivationMode::Dual};
|
NpadHandheldActivationMode handheld_activation_mode{NpadHandheldActivationMode::Dual};
|
||||||
NpadCommunicationMode communication_mode{NpadCommunicationMode::Default};
|
NpadCommunicationMode communication_mode{NpadCommunicationMode::Default};
|
||||||
bool permit_vibration_session_enabled{false};
|
bool permit_vibration_session_enabled{false};
|
||||||
bool analog_stick_use_center_clamp{};
|
bool analog_stick_use_center_clamp{false};
|
||||||
bool is_in_lr_assignment_mode{false};
|
bool is_in_lr_assignment_mode{false};
|
||||||
|
bool is_controller_initialized{false};
|
||||||
};
|
};
|
||||||
} // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
@ -63,10 +63,6 @@ IAppletResource::IAppletResource(Core::System& system_,
|
|||||||
MakeController<Controller_Gesture>(HidController::Gesture);
|
MakeController<Controller_Gesture>(HidController::Gesture);
|
||||||
MakeController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor);
|
MakeController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor);
|
||||||
|
|
||||||
// Homebrew doesn't try to activate some controllers, so we activate them by default
|
|
||||||
GetController<Controller_NPad>(HidController::NPad).ActivateController();
|
|
||||||
GetController<Controller_Touchscreen>(HidController::Touchscreen).ActivateController();
|
|
||||||
|
|
||||||
GetController<Controller_Stubbed>(HidController::HomeButton).SetCommonHeaderOffset(0x4C00);
|
GetController<Controller_Stubbed>(HidController::HomeButton).SetCommonHeaderOffset(0x4C00);
|
||||||
GetController<Controller_Stubbed>(HidController::SleepButton).SetCommonHeaderOffset(0x4E00);
|
GetController<Controller_Stubbed>(HidController::SleepButton).SetCommonHeaderOffset(0x4E00);
|
||||||
GetController<Controller_Stubbed>(HidController::CaptureButton).SetCommonHeaderOffset(0x5000);
|
GetController<Controller_Stubbed>(HidController::CaptureButton).SetCommonHeaderOffset(0x5000);
|
||||||
|
Loading…
Reference in New Issue
Block a user