Add footer types and address comments

This commit is contained in:
german 2021-01-11 00:03:17 -06:00
parent 9a9e81f2e9
commit 8019b2b9b5
7 changed files with 106 additions and 58 deletions

View File

@ -56,7 +56,7 @@ void Controller_Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing,
cur_entry.modifier.caps_lock.Assign(keyboard_mods[CapsLock]->GetStatus());
cur_entry.modifier.scroll_lock.Assign(keyboard_mods[ScrollLock]->GetStatus());
cur_entry.modifier.num_lock.Assign(keyboard_mods[NumLock]->GetStatus());
cur_entry.modifier.katana.Assign(0);
cur_entry.modifier.katakana.Assign(0);
cur_entry.modifier.hiragana.Assign(0);
}
std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));

View File

@ -34,7 +34,7 @@ public:
private:
struct Modifiers {
union {
s32_le raw{};
u32_le raw{};
BitField<0, 1, u32> control;
BitField<1, 1, u32> shift;
BitField<2, 1, u32> left_alt;
@ -43,7 +43,7 @@ private:
BitField<8, 1, u32> caps_lock;
BitField<9, 1, u32> scroll_lock;
BitField<10, 1, u32> num_lock;
BitField<11, 1, u32> katana;
BitField<11, 1, u32> katakana;
BitField<12, 1, u32> hiragana;
};
};

View File

@ -35,6 +35,7 @@ void Controller_Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
cur_entry.sampling_number = last_entry.sampling_number + 1;
cur_entry.sampling_number2 = cur_entry.sampling_number;
cur_entry.attribute.raw = 0;
if (Settings::values.mouse_enabled) {
const auto [px, py, sx, sy] = mouse_device->GetStatus();

View File

@ -33,7 +33,7 @@ public:
private:
struct Buttons {
union {
s32_le raw{};
u32_le raw{};
BitField<0, 1, u32> left;
BitField<1, 1, u32> right;
BitField<2, 1, u32> middle;
@ -45,7 +45,7 @@ private:
struct Attributes {
union {
s32_le raw{};
u32_le raw{};
BitField<0, 1, u32> transferable;
BitField<1, 1, u32> is_connected;
};

View File

@ -170,6 +170,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
controller.system_properties.use_plus.Assign(1);
controller.system_properties.use_minus.Assign(1);
controller.assignment_mode = NpadAssignments::Single;
controller.footer_type = AppletFooterUiType::SwitchProController;
break;
case NPadControllerType::Handheld:
controller.style_set.handheld.Assign(1);
@ -179,6 +180,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
controller.system_properties.use_plus.Assign(1);
controller.system_properties.use_minus.Assign(1);
controller.assignment_mode = NpadAssignments::Dual;
controller.footer_type = AppletFooterUiType::HandheldJoyConLeftJoyConRight;
break;
case NPadControllerType::JoyDual:
controller.style_set.joycon_dual.Assign(1);
@ -188,6 +190,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
controller.system_properties.use_plus.Assign(1);
controller.system_properties.use_minus.Assign(1);
controller.assignment_mode = NpadAssignments::Dual;
controller.footer_type = AppletFooterUiType::JoyDual;
break;
case NPadControllerType::JoyLeft:
controller.style_set.joycon_left.Assign(1);
@ -195,6 +198,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
controller.system_properties.is_horizontal.Assign(1);
controller.system_properties.use_minus.Assign(1);
controller.assignment_mode = NpadAssignments::Single;
controller.footer_type = AppletFooterUiType::JoyLeftHorizontal;
break;
case NPadControllerType::JoyRight:
controller.style_set.joycon_right.Assign(1);
@ -202,6 +206,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
controller.system_properties.is_horizontal.Assign(1);
controller.system_properties.use_plus.Assign(1);
controller.assignment_mode = NpadAssignments::Single;
controller.footer_type = AppletFooterUiType::JoyRightHorizontal;
break;
case NPadControllerType::Pokeball:
controller.style_set.palma.Assign(1);
@ -224,6 +229,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
controller.joycon_color.right.button =
Settings::values.players.GetValue()[controller_idx].button_color_right;
// TODO: Investigate when we should report all batery types
controller.battery_level_dual = BATTERY_FULL;
controller.battery_level_left = BATTERY_FULL;
controller.battery_level_right = BATTERY_FULL;
@ -450,7 +456,7 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
npad.system_ext_states.npad[npad.system_ext_states.common.last_entry_index];
libnx_entry.connection_status.raw = 0;
libnx_entry.connection_status.IsConnected.Assign(1);
libnx_entry.connection_status.is_connected.Assign(1);
switch (controller_type) {
case NPadControllerType::None:
@ -458,67 +464,67 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
break;
case NPadControllerType::ProController:
main_controller.connection_status.raw = 0;
main_controller.connection_status.IsConnected.Assign(1);
main_controller.connection_status.IsWired.Assign(1);
main_controller.connection_status.is_connected.Assign(1);
main_controller.connection_status.is_wired.Assign(1);
main_controller.pad.pad_states.raw = pad_state.pad_states.raw;
main_controller.pad.l_stick = pad_state.l_stick;
main_controller.pad.r_stick = pad_state.r_stick;
libnx_entry.connection_status.IsWired.Assign(1);
libnx_entry.connection_status.is_wired.Assign(1);
break;
case NPadControllerType::Handheld:
handheld_entry.connection_status.raw = 0;
handheld_entry.connection_status.IsConnected.Assign(1);
handheld_entry.connection_status.IsWired.Assign(1);
handheld_entry.connection_status.IsLeftJoyConnected.Assign(1);
handheld_entry.connection_status.IsRightJoyConnected.Assign(1);
handheld_entry.connection_status.IsLeftJoyWired.Assign(1);
handheld_entry.connection_status.IsRightJoyWired.Assign(1);
handheld_entry.connection_status.is_connected.Assign(1);
handheld_entry.connection_status.is_wired.Assign(1);
handheld_entry.connection_status.is_left_connected.Assign(1);
handheld_entry.connection_status.is_right_connected.Assign(1);
handheld_entry.connection_status.is_left_wired.Assign(1);
handheld_entry.connection_status.is_right_wired.Assign(1);
handheld_entry.pad.pad_states.raw = pad_state.pad_states.raw;
handheld_entry.pad.l_stick = pad_state.l_stick;
handheld_entry.pad.r_stick = pad_state.r_stick;
libnx_entry.connection_status.IsWired.Assign(1);
libnx_entry.connection_status.IsLeftJoyConnected.Assign(1);
libnx_entry.connection_status.IsRightJoyConnected.Assign(1);
libnx_entry.connection_status.IsLeftJoyWired.Assign(1);
libnx_entry.connection_status.IsRightJoyWired.Assign(1);
libnx_entry.connection_status.is_wired.Assign(1);
libnx_entry.connection_status.is_left_connected.Assign(1);
libnx_entry.connection_status.is_right_connected.Assign(1);
libnx_entry.connection_status.is_left_wired.Assign(1);
libnx_entry.connection_status.is_right_wired.Assign(1);
break;
case NPadControllerType::JoyDual:
dual_entry.connection_status.raw = 0;
dual_entry.connection_status.IsConnected.Assign(1);
dual_entry.connection_status.IsLeftJoyConnected.Assign(1);
dual_entry.connection_status.IsRightJoyConnected.Assign(1);
dual_entry.connection_status.is_connected.Assign(1);
dual_entry.connection_status.is_left_connected.Assign(1);
dual_entry.connection_status.is_right_connected.Assign(1);
dual_entry.pad.pad_states.raw = pad_state.pad_states.raw;
dual_entry.pad.l_stick = pad_state.l_stick;
dual_entry.pad.r_stick = pad_state.r_stick;
libnx_entry.connection_status.IsLeftJoyConnected.Assign(1);
libnx_entry.connection_status.IsRightJoyConnected.Assign(1);
libnx_entry.connection_status.is_left_connected.Assign(1);
libnx_entry.connection_status.is_right_connected.Assign(1);
break;
case NPadControllerType::JoyLeft:
left_entry.connection_status.raw = 0;
left_entry.connection_status.IsConnected.Assign(1);
left_entry.connection_status.IsLeftJoyConnected.Assign(1);
left_entry.connection_status.is_connected.Assign(1);
left_entry.connection_status.is_left_connected.Assign(1);
left_entry.pad.pad_states.raw = pad_state.pad_states.raw;
left_entry.pad.l_stick = pad_state.l_stick;
left_entry.pad.r_stick = pad_state.r_stick;
libnx_entry.connection_status.IsLeftJoyConnected.Assign(1);
libnx_entry.connection_status.is_left_connected.Assign(1);
break;
case NPadControllerType::JoyRight:
right_entry.connection_status.raw = 0;
right_entry.connection_status.IsConnected.Assign(1);
right_entry.connection_status.IsRightJoyConnected.Assign(1);
right_entry.connection_status.is_connected.Assign(1);
right_entry.connection_status.is_right_connected.Assign(1);
right_entry.pad.pad_states.raw = pad_state.pad_states.raw;
right_entry.pad.l_stick = pad_state.l_stick;
right_entry.pad.r_stick = pad_state.r_stick;
libnx_entry.connection_status.IsRightJoyConnected.Assign(1);
libnx_entry.connection_status.is_right_connected.Assign(1);
break;
case NPadControllerType::Pokeball:
pokeball_entry.connection_status.raw = 0;
pokeball_entry.connection_status.IsConnected.Assign(1);
pokeball_entry.connection_status.is_connected.Assign(1);
pokeball_entry.pad.pad_states.raw = pad_state.pad_states.raw;
pokeball_entry.pad.l_stick = pad_state.l_stick;
pokeball_entry.pad.r_stick = pad_state.r_stick;
@ -609,7 +615,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing
case NPadControllerType::ProController:
full_sixaxis_entry.attribute.raw = 0;
if (sixaxis_sensors_enabled && motions[i][0]) {
full_sixaxis_entry.attribute.IsConnected.Assign(1);
full_sixaxis_entry.attribute.is_connected.Assign(1);
full_sixaxis_entry.accel = motion_devices[0].accel;
full_sixaxis_entry.gyro = motion_devices[0].gyro;
full_sixaxis_entry.rotation = motion_devices[0].rotation;
@ -619,7 +625,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing
case NPadControllerType::Handheld:
handheld_sixaxis_entry.attribute.raw = 0;
if (sixaxis_sensors_enabled && motions[i][0]) {
handheld_sixaxis_entry.attribute.IsConnected.Assign(1);
handheld_sixaxis_entry.attribute.is_connected.Assign(1);
handheld_sixaxis_entry.accel = motion_devices[0].accel;
handheld_sixaxis_entry.gyro = motion_devices[0].gyro;
handheld_sixaxis_entry.rotation = motion_devices[0].rotation;
@ -631,7 +637,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing
dual_right_sixaxis_entry.attribute.raw = 0;
if (sixaxis_sensors_enabled && motions[i][0]) {
// Set motion for the left joycon
dual_left_sixaxis_entry.attribute.IsConnected.Assign(1);
dual_left_sixaxis_entry.attribute.is_connected.Assign(1);
dual_left_sixaxis_entry.accel = motion_devices[0].accel;
dual_left_sixaxis_entry.gyro = motion_devices[0].gyro;
dual_left_sixaxis_entry.rotation = motion_devices[0].rotation;
@ -639,7 +645,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing
}
if (sixaxis_sensors_enabled && motions[i][1]) {
// Set motion for the right joycon
dual_right_sixaxis_entry.attribute.IsConnected.Assign(1);
dual_right_sixaxis_entry.attribute.is_connected.Assign(1);
dual_right_sixaxis_entry.accel = motion_devices[1].accel;
dual_right_sixaxis_entry.gyro = motion_devices[1].gyro;
dual_right_sixaxis_entry.rotation = motion_devices[1].rotation;
@ -649,7 +655,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing
case NPadControllerType::JoyLeft:
left_sixaxis_entry.attribute.raw = 0;
if (sixaxis_sensors_enabled && motions[i][0]) {
left_sixaxis_entry.attribute.IsConnected.Assign(1);
left_sixaxis_entry.attribute.is_connected.Assign(1);
left_sixaxis_entry.accel = motion_devices[0].accel;
left_sixaxis_entry.gyro = motion_devices[0].gyro;
left_sixaxis_entry.rotation = motion_devices[0].rotation;
@ -659,7 +665,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing
case NPadControllerType::JoyRight:
right_sixaxis_entry.attribute.raw = 0;
if (sixaxis_sensors_enabled && motions[i][1]) {
right_sixaxis_entry.attribute.IsConnected.Assign(1);
right_sixaxis_entry.attribute.is_connected.Assign(1);
right_sixaxis_entry.accel = motion_devices[1].accel;
right_sixaxis_entry.gyro = motion_devices[1].gyro;
right_sixaxis_entry.rotation = motion_devices[1].rotation;
@ -937,6 +943,13 @@ void Controller_NPad::DisconnectNpadAtIndex(std::size_t npad_index) {
controller.device_type.raw = 0;
controller.system_properties.raw = 0;
controller.button_properties.raw = 0;
controller.battery_level_dual = 0;
controller.battery_level_left = 0;
controller.battery_level_right = 0;
controller.fullkey_color = {};
controller.joycon_color = {};
controller.assignment_mode = NpadAssignments::Dual;
controller.footer_type = AppletFooterUiType::None;
SignalStyleSetChangedEvent(IndexToNPad(npad_index));
}

View File

@ -326,12 +326,12 @@ private:
struct ConnectionState {
union {
u32_le raw{};
BitField<0, 1, u32> IsConnected;
BitField<1, 1, u32> IsWired;
BitField<2, 1, u32> IsLeftJoyConnected;
BitField<3, 1, u32> IsLeftJoyWired;
BitField<4, 1, u32> IsRightJoyConnected;
BitField<5, 1, u32> IsRightJoyWired;
BitField<0, 1, u32> is_connected;
BitField<1, 1, u32> is_wired;
BitField<2, 1, u32> is_left_connected;
BitField<3, 1, u32> is_left_wired;
BitField<4, 1, u32> is_right_connected;
BitField<5, 1, u32> is_right_wired;
};
};
static_assert(sizeof(ConnectionState) == 4, "ConnectionState is an invalid size");
@ -360,8 +360,8 @@ private:
struct SixAxisAttributes {
union {
u32_le raw{};
BitField<0, 1, u32> IsConnected;
BitField<1, 1, u32> IsInterpolated;
BitField<0, 1, u32> is_connected;
BitField<1, 1, u32> is_interpolated;
};
};
static_assert(sizeof(SixAxisAttributes) == 4, "SixAxisAttributes is an invalid size");
@ -394,8 +394,8 @@ private:
BitField<3, 1, s64> is_powered_joy_dual;
BitField<4, 1, s64> is_powered_joy_left;
BitField<5, 1, s64> is_powered_joy_right;
BitField<9, 1, s64> is_system_unsuported_button;
BitField<10, 1, s64> is_system_ext_unsuported_button;
BitField<9, 1, s64> is_system_unsupported_button;
BitField<10, 1, s64> is_system_ext_unsupported_button;
BitField<11, 1, s64> is_vertical;
BitField<12, 1, s64> is_horizontal;
BitField<13, 1, s64> use_plus;
@ -443,6 +443,38 @@ private:
std::array<Common::Vec3f, 3> orientation;
};
struct NfcXcdHandle {
INSERT_PADDING_BYTES(0x60);
};
struct AppletFooterUiAttributes {
INSERT_PADDING_BYTES(0x4);
};
enum class AppletFooterUiType : u8 {
None = 0,
HandheldNone = 1,
HandheldJoyConLeftOnly = 1,
HandheldJoyConRightOnly = 3,
HandheldJoyConLeftJoyConRight = 4,
JoyDual = 5,
JoyDualLeftOnly = 6,
JoyDualRightOnly = 7,
JoyLeftHorizontal = 8,
JoyLeftVertical = 9,
JoyRightHorizontal = 10,
JoyRightVertical = 11,
SwitchProController = 12,
CompatibleProController = 13,
CompatibleJoyCon = 14,
LarkHvc1 = 15,
LarkHvc2 = 16,
LarkNesLeft = 17,
LarkNesRight = 18,
Lucia = 19,
Verification = 20,
};
struct NPadEntry {
NpadStyleSet style_set;
NpadAssignments assignment_mode;
@ -469,8 +501,11 @@ private:
u32 battery_level_dual;
u32 battery_level_left;
u32 battery_level_right;
INSERT_PADDING_BYTES(0x5c);
INSERT_PADDING_BYTES(0xdf8);
AppletFooterUiAttributes footer_attributes;
AppletFooterUiType footer_type;
// nfc_states needs to be checked switchbrew does not match with HW
NfcXcdHandle nfc_states;
INSERT_PADDING_BYTES(0xdef);
};
static_assert(sizeof(NPadEntry) == 0x5000, "NPadEntry is an invalid size");
@ -506,7 +541,6 @@ private:
std::vector<u32> supported_npad_id_types{};
NpadHoldType hold_type{NpadHoldType::Vertical};
NpadHandheldActivationMode handheld_activation_mode{NpadHandheldActivationMode::Dual};
// NpadCommunicationMode is unknown, default value is 1
NpadCommunicationMode communication_mode{NpadCommunicationMode::Default};
// Each controller should have their own styleset changed event
std::array<Kernel::EventPair, 10> styleset_changed_events;

View File

@ -31,13 +31,13 @@ public:
private:
struct Attributes {
union {
s32_le raw{};
BitField<0, 1, u32> IsConnected;
BitField<1, 1, u32> IsWired;
BitField<2, 1, u32> IsLeftConnected;
BitField<3, 1, u32> IsLeftWired;
BitField<4, 1, u32> IsRightConnected;
BitField<5, 1, u32> IsRightWired;
u32_le raw{};
BitField<0, 1, u32> is_connected;
BitField<1, 1, u32> is_wired;
BitField<2, 1, u32> is_left_connected;
BitField<3, 1, u32> is_left_wired;
BitField<4, 1, u32> is_right_connected;
BitField<5, 1, u32> is_right_wired;
};
};
static_assert(sizeof(Attributes) == 4, "Attributes is an invalid size");