mirror of https://git.suyu.dev/suyu/suyu
service: hid: Ensure all structs are initialized
This commit is contained in:
parent
61582efeb9
commit
0f3ad939a8
|
@ -316,27 +316,27 @@ static_assert(sizeof(TouchAttribute) == 0x4, "TouchAttribute is an invalid size"
|
||||||
|
|
||||||
// This is nn::hid::TouchState
|
// This is nn::hid::TouchState
|
||||||
struct TouchState {
|
struct TouchState {
|
||||||
u64 delta_time;
|
u64 delta_time{};
|
||||||
TouchAttribute attribute;
|
TouchAttribute attribute{};
|
||||||
u32 finger;
|
u32 finger{};
|
||||||
Common::Point<u32> position;
|
Common::Point<u32> position{};
|
||||||
u32 diameter_x;
|
u32 diameter_x{};
|
||||||
u32 diameter_y;
|
u32 diameter_y{};
|
||||||
u32 rotation_angle;
|
u32 rotation_angle{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(TouchState) == 0x28, "Touchstate is an invalid size");
|
static_assert(sizeof(TouchState) == 0x28, "Touchstate is an invalid size");
|
||||||
|
|
||||||
// This is nn::hid::NpadControllerColor
|
// This is nn::hid::NpadControllerColor
|
||||||
struct NpadControllerColor {
|
struct NpadControllerColor {
|
||||||
u32 body;
|
u32 body{};
|
||||||
u32 button;
|
u32 button{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(NpadControllerColor) == 8, "NpadControllerColor is an invalid size");
|
static_assert(sizeof(NpadControllerColor) == 8, "NpadControllerColor is an invalid size");
|
||||||
|
|
||||||
// This is nn::hid::AnalogStickState
|
// This is nn::hid::AnalogStickState
|
||||||
struct AnalogStickState {
|
struct AnalogStickState {
|
||||||
s32 x;
|
s32 x{};
|
||||||
s32 y;
|
s32 y{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(AnalogStickState) == 8, "AnalogStickState is an invalid size");
|
static_assert(sizeof(AnalogStickState) == 8, "AnalogStickState is an invalid size");
|
||||||
|
|
||||||
|
@ -354,10 +354,10 @@ static_assert(sizeof(NpadBatteryLevel) == 0x4, "NpadBatteryLevel is an invalid s
|
||||||
|
|
||||||
// This is nn::hid::system::NpadPowerInfo
|
// This is nn::hid::system::NpadPowerInfo
|
||||||
struct NpadPowerInfo {
|
struct NpadPowerInfo {
|
||||||
bool is_powered;
|
bool is_powered{};
|
||||||
bool is_charging;
|
bool is_charging{};
|
||||||
INSERT_PADDING_BYTES(0x6);
|
INSERT_PADDING_BYTES(0x6);
|
||||||
NpadBatteryLevel battery_level;
|
NpadBatteryLevel battery_level{8};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(NpadPowerInfo) == 0xC, "NpadPowerInfo is an invalid size");
|
static_assert(sizeof(NpadPowerInfo) == 0xC, "NpadPowerInfo is an invalid size");
|
||||||
|
|
||||||
|
@ -474,8 +474,8 @@ static_assert(sizeof(DebugPadButton) == 0x4, "DebugPadButton is an invalid size"
|
||||||
|
|
||||||
// This is nn::hid::ConsoleSixAxisSensorHandle
|
// This is nn::hid::ConsoleSixAxisSensorHandle
|
||||||
struct ConsoleSixAxisSensorHandle {
|
struct ConsoleSixAxisSensorHandle {
|
||||||
u8 unknown_1;
|
u8 unknown_1{};
|
||||||
u8 unknown_2;
|
u8 unknown_2{};
|
||||||
INSERT_PADDING_BYTES_NOINIT(2);
|
INSERT_PADDING_BYTES_NOINIT(2);
|
||||||
};
|
};
|
||||||
static_assert(sizeof(ConsoleSixAxisSensorHandle) == 4,
|
static_assert(sizeof(ConsoleSixAxisSensorHandle) == 4,
|
||||||
|
@ -483,9 +483,9 @@ static_assert(sizeof(ConsoleSixAxisSensorHandle) == 4,
|
||||||
|
|
||||||
// This is nn::hid::SixAxisSensorHandle
|
// This is nn::hid::SixAxisSensorHandle
|
||||||
struct SixAxisSensorHandle {
|
struct SixAxisSensorHandle {
|
||||||
NpadStyleIndex npad_type;
|
NpadStyleIndex npad_type{NpadStyleIndex::None};
|
||||||
u8 npad_id;
|
u8 npad_id{};
|
||||||
DeviceIndex device_index;
|
DeviceIndex device_index{DeviceIndex::None};
|
||||||
INSERT_PADDING_BYTES_NOINIT(1);
|
INSERT_PADDING_BYTES_NOINIT(1);
|
||||||
};
|
};
|
||||||
static_assert(sizeof(SixAxisSensorHandle) == 4, "SixAxisSensorHandle is an invalid size");
|
static_assert(sizeof(SixAxisSensorHandle) == 4, "SixAxisSensorHandle is an invalid size");
|
||||||
|
@ -500,19 +500,19 @@ static_assert(sizeof(SixAxisSensorFusionParameters) == 8,
|
||||||
|
|
||||||
// This is nn::hid::VibrationDeviceHandle
|
// This is nn::hid::VibrationDeviceHandle
|
||||||
struct VibrationDeviceHandle {
|
struct VibrationDeviceHandle {
|
||||||
NpadStyleIndex npad_type;
|
NpadStyleIndex npad_type{NpadStyleIndex::None};
|
||||||
u8 npad_id;
|
u8 npad_id{};
|
||||||
DeviceIndex device_index;
|
DeviceIndex device_index{DeviceIndex::None};
|
||||||
INSERT_PADDING_BYTES_NOINIT(1);
|
INSERT_PADDING_BYTES_NOINIT(1);
|
||||||
};
|
};
|
||||||
static_assert(sizeof(VibrationDeviceHandle) == 4, "SixAxisSensorHandle is an invalid size");
|
static_assert(sizeof(VibrationDeviceHandle) == 4, "SixAxisSensorHandle is an invalid size");
|
||||||
|
|
||||||
// This is nn::hid::VibrationValue
|
// This is nn::hid::VibrationValue
|
||||||
struct VibrationValue {
|
struct VibrationValue {
|
||||||
f32 low_amplitude;
|
f32 low_amplitude{};
|
||||||
f32 low_frequency;
|
f32 low_frequency{};
|
||||||
f32 high_amplitude;
|
f32 high_amplitude{};
|
||||||
f32 high_frequency;
|
f32 high_frequency{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(VibrationValue) == 0x10, "VibrationValue has incorrect size.");
|
static_assert(sizeof(VibrationValue) == 0x10, "VibrationValue has incorrect size.");
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ static_assert(sizeof(KeyboardAttribute) == 0x4, "KeyboardAttribute is an invalid
|
||||||
// This is nn::hid::KeyboardKey
|
// This is nn::hid::KeyboardKey
|
||||||
struct KeyboardKey {
|
struct KeyboardKey {
|
||||||
// This should be a 256 bit flag
|
// This should be a 256 bit flag
|
||||||
std::array<u8, 32> key;
|
std::array<u8, 32> key{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(KeyboardKey) == 0x20, "KeyboardKey is an invalid size");
|
static_assert(sizeof(KeyboardKey) == 0x20, "KeyboardKey is an invalid size");
|
||||||
|
|
||||||
|
@ -590,16 +590,16 @@ static_assert(sizeof(MouseAttribute) == 0x4, "MouseAttribute is an invalid size"
|
||||||
|
|
||||||
// This is nn::hid::detail::MouseState
|
// This is nn::hid::detail::MouseState
|
||||||
struct MouseState {
|
struct MouseState {
|
||||||
s64 sampling_number;
|
s64 sampling_number{};
|
||||||
s32 x;
|
s32 x{};
|
||||||
s32 y;
|
s32 y{};
|
||||||
s32 delta_x;
|
s32 delta_x{};
|
||||||
s32 delta_y;
|
s32 delta_y{};
|
||||||
// Axis Order in HW is switched for the wheel
|
// Axis Order in HW is switched for the wheel
|
||||||
s32 delta_wheel_y;
|
s32 delta_wheel_y{};
|
||||||
s32 delta_wheel_x;
|
s32 delta_wheel_x{};
|
||||||
MouseButton button;
|
MouseButton button{};
|
||||||
MouseAttribute attribute;
|
MouseAttribute attribute{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(MouseState) == 0x28, "MouseState is an invalid size");
|
static_assert(sizeof(MouseState) == 0x28, "MouseState is an invalid size");
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ Controller_ConsoleSixAxis::Controller_ConsoleSixAxis(Core::HID::HIDCore& hid_cor
|
||||||
console = hid_core.GetEmulatedConsole();
|
console = hid_core.GetEmulatedConsole();
|
||||||
static_assert(SHARED_MEMORY_OFFSET + sizeof(ConsoleSharedMemory) < shared_memory_size,
|
static_assert(SHARED_MEMORY_OFFSET + sizeof(ConsoleSharedMemory) < shared_memory_size,
|
||||||
"ConsoleSharedMemory is bigger than the shared memory");
|
"ConsoleSharedMemory is bigger than the shared memory");
|
||||||
shared_memory =
|
shared_memory = std::construct_at(
|
||||||
std::construct_at(reinterpret_cast<ConsoleSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
reinterpret_cast<ConsoleSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller_ConsoleSixAxis::~Controller_ConsoleSixAxis() = default;
|
Controller_ConsoleSixAxis::~Controller_ConsoleSixAxis() = default;
|
||||||
|
|
|
@ -61,13 +61,13 @@ private:
|
||||||
Lifo<SevenSixAxisState, 0x21> seven_sixaxis_lifo{};
|
Lifo<SevenSixAxisState, 0x21> seven_sixaxis_lifo{};
|
||||||
static_assert(sizeof(seven_sixaxis_lifo) == 0xA70, "SevenSixAxisState is an invalid size");
|
static_assert(sizeof(seven_sixaxis_lifo) == 0xA70, "SevenSixAxisState is an invalid size");
|
||||||
|
|
||||||
ConsoleSharedMemory* shared_memory;
|
SevenSixAxisState next_seven_sixaxis_state{};
|
||||||
|
|
||||||
Core::HID::EmulatedConsole* console;
|
|
||||||
u8* transfer_memory = nullptr;
|
u8* transfer_memory = nullptr;
|
||||||
|
ConsoleSharedMemory* shared_memory = nullptr;
|
||||||
|
Core::HID::EmulatedConsole* console = nullptr;
|
||||||
|
|
||||||
bool is_transfer_memory_set = false;
|
bool is_transfer_memory_set = false;
|
||||||
u64 last_saved_timestamp{};
|
u64 last_saved_timestamp{};
|
||||||
u64 last_global_timestamp{};
|
u64 last_global_timestamp{};
|
||||||
SevenSixAxisState next_seven_sixaxis_state{};
|
|
||||||
};
|
};
|
||||||
} // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -41,11 +41,11 @@ private:
|
||||||
|
|
||||||
// This is nn::hid::DebugPadState
|
// This is nn::hid::DebugPadState
|
||||||
struct DebugPadState {
|
struct DebugPadState {
|
||||||
s64 sampling_number;
|
s64 sampling_number{};
|
||||||
DebugPadAttribute attribute;
|
DebugPadAttribute attribute{};
|
||||||
Core::HID::DebugPadButton pad_state;
|
Core::HID::DebugPadButton pad_state{};
|
||||||
Core::HID::AnalogStickState r_stick;
|
Core::HID::AnalogStickState r_stick{};
|
||||||
Core::HID::AnalogStickState l_stick;
|
Core::HID::AnalogStickState l_stick{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(DebugPadState) == 0x20, "DebugPadState is an invalid state");
|
static_assert(sizeof(DebugPadState) == 0x20, "DebugPadState is an invalid state");
|
||||||
|
|
||||||
|
@ -57,9 +57,8 @@ private:
|
||||||
};
|
};
|
||||||
static_assert(sizeof(DebugPadSharedMemory) == 0x400, "DebugPadSharedMemory is an invalid size");
|
static_assert(sizeof(DebugPadSharedMemory) == 0x400, "DebugPadSharedMemory is an invalid size");
|
||||||
|
|
||||||
DebugPadSharedMemory* shared_memory;
|
|
||||||
|
|
||||||
DebugPadState next_state{};
|
DebugPadState next_state{};
|
||||||
Core::HID::EmulatedController* controller;
|
DebugPadSharedMemory* shared_memory = nullptr;
|
||||||
|
Core::HID::EmulatedController* controller = nullptr;
|
||||||
};
|
};
|
||||||
} // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -27,8 +27,8 @@ Controller_Gesture::Controller_Gesture(Core::HID::HIDCore& hid_core_, u8* raw_sh
|
||||||
: ControllerBase(hid_core_) {
|
: ControllerBase(hid_core_) {
|
||||||
static_assert(SHARED_MEMORY_OFFSET + sizeof(GestureSharedMemory) < shared_memory_size,
|
static_assert(SHARED_MEMORY_OFFSET + sizeof(GestureSharedMemory) < shared_memory_size,
|
||||||
"GestureSharedMemory is bigger than the shared memory");
|
"GestureSharedMemory is bigger than the shared memory");
|
||||||
shared_memory =
|
shared_memory = std::construct_at(
|
||||||
std::construct_at(reinterpret_cast<GestureSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
reinterpret_cast<GestureSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
||||||
console = hid_core.GetEmulatedConsole();
|
console = hid_core.GetEmulatedConsole();
|
||||||
}
|
}
|
||||||
Controller_Gesture::~Controller_Gesture() = default;
|
Controller_Gesture::~Controller_Gesture() = default;
|
||||||
|
|
|
@ -66,19 +66,19 @@ private:
|
||||||
|
|
||||||
// This is nn::hid::GestureState
|
// This is nn::hid::GestureState
|
||||||
struct GestureState {
|
struct GestureState {
|
||||||
s64 sampling_number;
|
s64 sampling_number{};
|
||||||
s64 detection_count;
|
s64 detection_count{};
|
||||||
GestureType type;
|
GestureType type{GestureType::Idle};
|
||||||
GestureDirection direction;
|
GestureDirection direction{GestureDirection::None};
|
||||||
Common::Point<s32> pos;
|
Common::Point<s32> pos{};
|
||||||
Common::Point<s32> delta;
|
Common::Point<s32> delta{};
|
||||||
f32 vel_x;
|
f32 vel_x{};
|
||||||
f32 vel_y;
|
f32 vel_y{};
|
||||||
GestureAttribute attributes;
|
GestureAttribute attributes{};
|
||||||
f32 scale;
|
f32 scale{};
|
||||||
f32 rotation_angle;
|
f32 rotation_angle{};
|
||||||
s32 point_count;
|
s32 point_count{};
|
||||||
std::array<Common::Point<s32>, 4> points;
|
std::array<Common::Point<s32>, 4> points{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(GestureState) == 0x60, "GestureState is an invalid size");
|
static_assert(sizeof(GestureState) == 0x60, "GestureState is an invalid size");
|
||||||
|
|
||||||
|
@ -142,9 +142,9 @@ private:
|
||||||
// Returns the average distance, angle and middle point of the active fingers
|
// Returns the average distance, angle and middle point of the active fingers
|
||||||
GestureProperties GetGestureProperties();
|
GestureProperties GetGestureProperties();
|
||||||
|
|
||||||
GestureSharedMemory* shared_memory;
|
|
||||||
GestureState next_state{};
|
GestureState next_state{};
|
||||||
Core::HID::EmulatedConsole* console;
|
GestureSharedMemory* shared_memory = nullptr;
|
||||||
|
Core::HID::EmulatedConsole* console = nullptr;
|
||||||
|
|
||||||
std::array<Core::HID::TouchFinger, MAX_POINTS> fingers{};
|
std::array<Core::HID::TouchFinger, MAX_POINTS> fingers{};
|
||||||
GestureProperties last_gesture{};
|
GestureProperties last_gesture{};
|
||||||
|
|
|
@ -16,8 +16,8 @@ Controller_Keyboard::Controller_Keyboard(Core::HID::HIDCore& hid_core_, u8* raw_
|
||||||
: ControllerBase{hid_core_} {
|
: ControllerBase{hid_core_} {
|
||||||
static_assert(SHARED_MEMORY_OFFSET + sizeof(KeyboardSharedMemory) < shared_memory_size,
|
static_assert(SHARED_MEMORY_OFFSET + sizeof(KeyboardSharedMemory) < shared_memory_size,
|
||||||
"KeyboardSharedMemory is bigger than the shared memory");
|
"KeyboardSharedMemory is bigger than the shared memory");
|
||||||
shared_memory =
|
shared_memory = std::construct_at(
|
||||||
std::construct_at(reinterpret_cast<KeyboardSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
reinterpret_cast<KeyboardSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
||||||
emulated_devices = hid_core.GetEmulatedDevices();
|
emulated_devices = hid_core.GetEmulatedDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,10 @@ public:
|
||||||
private:
|
private:
|
||||||
// This is nn::hid::detail::KeyboardState
|
// This is nn::hid::detail::KeyboardState
|
||||||
struct KeyboardState {
|
struct KeyboardState {
|
||||||
s64 sampling_number;
|
s64 sampling_number{};
|
||||||
Core::HID::KeyboardModifier modifier;
|
Core::HID::KeyboardModifier modifier{};
|
||||||
Core::HID::KeyboardAttribute attribute;
|
Core::HID::KeyboardAttribute attribute{};
|
||||||
Core::HID::KeyboardKey key;
|
Core::HID::KeyboardKey key{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(KeyboardState) == 0x30, "KeyboardState is an invalid size");
|
static_assert(sizeof(KeyboardState) == 0x30, "KeyboardState is an invalid size");
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ private:
|
||||||
};
|
};
|
||||||
static_assert(sizeof(KeyboardSharedMemory) == 0x400, "KeyboardSharedMemory is an invalid size");
|
static_assert(sizeof(KeyboardSharedMemory) == 0x400, "KeyboardSharedMemory is an invalid size");
|
||||||
|
|
||||||
KeyboardSharedMemory* shared_memory;
|
|
||||||
KeyboardState next_state{};
|
KeyboardState next_state{};
|
||||||
Core::HID::EmulatedDevices* emulated_devices;
|
KeyboardSharedMemory* shared_memory = nullptr;
|
||||||
|
Core::HID::EmulatedDevices* emulated_devices = nullptr;
|
||||||
};
|
};
|
||||||
} // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -16,7 +16,8 @@ Controller_Mouse::Controller_Mouse(Core::HID::HIDCore& hid_core_, u8* raw_shared
|
||||||
: ControllerBase{hid_core_} {
|
: ControllerBase{hid_core_} {
|
||||||
static_assert(SHARED_MEMORY_OFFSET + sizeof(MouseSharedMemory) < shared_memory_size,
|
static_assert(SHARED_MEMORY_OFFSET + sizeof(MouseSharedMemory) < shared_memory_size,
|
||||||
"MouseSharedMemory is bigger than the shared memory");
|
"MouseSharedMemory is bigger than the shared memory");
|
||||||
shared_memory = std::construct_at(reinterpret_cast<MouseSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
shared_memory = std::construct_at(
|
||||||
|
reinterpret_cast<MouseSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
||||||
emulated_devices = hid_core.GetEmulatedDevices();
|
emulated_devices = hid_core.GetEmulatedDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,9 @@ private:
|
||||||
};
|
};
|
||||||
static_assert(sizeof(MouseSharedMemory) == 0x400, "MouseSharedMemory is an invalid size");
|
static_assert(sizeof(MouseSharedMemory) == 0x400, "MouseSharedMemory is an invalid size");
|
||||||
|
|
||||||
MouseSharedMemory* shared_memory;
|
|
||||||
Core::HID::MouseState next_state{};
|
Core::HID::MouseState next_state{};
|
||||||
Core::HID::AnalogStickState last_mouse_wheel_state{};
|
Core::HID::AnalogStickState last_mouse_wheel_state{};
|
||||||
Core::HID::EmulatedDevices* emulated_devices;
|
MouseSharedMemory* shared_memory = nullptr;
|
||||||
|
Core::HID::EmulatedDevices* emulated_devices = nullptr;
|
||||||
};
|
};
|
||||||
} // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -187,7 +187,7 @@ public:
|
||||||
static bool IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle);
|
static bool IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const std::size_t NPAD_COUNT = 10;
|
static constexpr std::size_t NPAD_COUNT = 10;
|
||||||
|
|
||||||
// This is nn::hid::detail::ColorAttribute
|
// This is nn::hid::detail::ColorAttribute
|
||||||
enum class ColorAttribute : u32 {
|
enum class ColorAttribute : u32 {
|
||||||
|
@ -470,9 +470,9 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NpadControllerData {
|
struct NpadControllerData {
|
||||||
Core::HID::EmulatedController* device;
|
|
||||||
Kernel::KEvent* styleset_changed_event{};
|
Kernel::KEvent* styleset_changed_event{};
|
||||||
NpadInternalState* shared_memory;
|
NpadInternalState* shared_memory = nullptr;
|
||||||
|
Core::HID::EmulatedController* device = nullptr;
|
||||||
|
|
||||||
std::array<VibrationData, 2> vibration{};
|
std::array<VibrationData, 2> vibration{};
|
||||||
bool unintended_home_button_input_protection{};
|
bool unintended_home_button_input_protection{};
|
||||||
|
@ -502,8 +502,7 @@ private:
|
||||||
SixAxisSensorState sixaxis_dual_right_state{};
|
SixAxisSensorState sixaxis_dual_right_state{};
|
||||||
SixAxisSensorState sixaxis_left_lifo_state{};
|
SixAxisSensorState sixaxis_left_lifo_state{};
|
||||||
SixAxisSensorState sixaxis_right_lifo_state{};
|
SixAxisSensorState sixaxis_right_lifo_state{};
|
||||||
|
int callback_key{};
|
||||||
int callback_key;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void ControllerUpdate(Core::HID::ControllerTriggerType type, std::size_t controller_idx);
|
void ControllerUpdate(Core::HID::ControllerTriggerType type, std::size_t controller_idx);
|
||||||
|
|
|
@ -25,14 +25,14 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct CommonHeader {
|
struct CommonHeader {
|
||||||
s64 timestamp;
|
s64 timestamp{};
|
||||||
s64 total_entry_count;
|
s64 total_entry_count{};
|
||||||
s64 last_entry_index;
|
s64 last_entry_index{};
|
||||||
s64 entry_count;
|
s64 entry_count{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size");
|
static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size");
|
||||||
|
|
||||||
u8* raw_shared_memory;
|
u8* raw_shared_memory = nullptr;
|
||||||
bool smart_update{};
|
bool smart_update{};
|
||||||
std::size_t common_offset{};
|
std::size_t common_offset{};
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,8 @@ Controller_Touchscreen::Controller_Touchscreen(Core::HID::HIDCore& hid_core_,
|
||||||
: ControllerBase{hid_core_} {
|
: ControllerBase{hid_core_} {
|
||||||
static_assert(SHARED_MEMORY_OFFSET + sizeof(TouchSharedMemory) < shared_memory_size,
|
static_assert(SHARED_MEMORY_OFFSET + sizeof(TouchSharedMemory) < shared_memory_size,
|
||||||
"TouchSharedMemory is bigger than the shared memory");
|
"TouchSharedMemory is bigger than the shared memory");
|
||||||
shared_memory = std::construct_at(reinterpret_cast<TouchSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
shared_memory = std::construct_at(
|
||||||
|
reinterpret_cast<TouchSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
||||||
console = hid_core.GetEmulatedConsole();
|
console = hid_core.GetEmulatedConsole();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
|
|
||||||
// This is nn::hid::TouchScreenConfigurationForNx
|
// This is nn::hid::TouchScreenConfigurationForNx
|
||||||
struct TouchScreenConfigurationForNx {
|
struct TouchScreenConfigurationForNx {
|
||||||
TouchScreenModeForNx mode;
|
TouchScreenModeForNx mode{TouchScreenModeForNx::UseSystemSetting};
|
||||||
INSERT_PADDING_BYTES_NOINIT(0x7);
|
INSERT_PADDING_BYTES_NOINIT(0x7);
|
||||||
INSERT_PADDING_BYTES_NOINIT(0xF); // Reserved
|
INSERT_PADDING_BYTES_NOINIT(0xF); // Reserved
|
||||||
};
|
};
|
||||||
|
@ -49,10 +49,10 @@ private:
|
||||||
|
|
||||||
// This is nn::hid::TouchScreenState
|
// This is nn::hid::TouchScreenState
|
||||||
struct TouchScreenState {
|
struct TouchScreenState {
|
||||||
s64 sampling_number;
|
s64 sampling_number{};
|
||||||
s32 entry_count;
|
s32 entry_count{};
|
||||||
INSERT_PADDING_BYTES(4); // Reserved
|
INSERT_PADDING_BYTES(4); // Reserved
|
||||||
std::array<Core::HID::TouchState, MAX_FINGERS> states;
|
std::array<Core::HID::TouchState, MAX_FINGERS> states{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(TouchScreenState) == 0x290, "TouchScreenState is an invalid size");
|
static_assert(sizeof(TouchScreenState) == 0x290, "TouchScreenState is an invalid size");
|
||||||
|
|
||||||
|
@ -64,10 +64,10 @@ private:
|
||||||
};
|
};
|
||||||
static_assert(sizeof(TouchSharedMemory) == 0x3000, "TouchSharedMemory is an invalid size");
|
static_assert(sizeof(TouchSharedMemory) == 0x3000, "TouchSharedMemory is an invalid size");
|
||||||
|
|
||||||
TouchSharedMemory* shared_memory;
|
|
||||||
|
|
||||||
TouchScreenState next_state{};
|
TouchScreenState next_state{};
|
||||||
std::array<Core::HID::TouchFinger, MAX_FINGERS> fingers;
|
TouchSharedMemory* shared_memory = nullptr;
|
||||||
Core::HID::EmulatedConsole* console;
|
Core::HID::EmulatedConsole* console = nullptr;
|
||||||
|
|
||||||
|
std::array<Core::HID::TouchFinger, MAX_FINGERS> fingers{};
|
||||||
};
|
};
|
||||||
} // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -14,7 +14,8 @@ Controller_XPad::Controller_XPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_m
|
||||||
: ControllerBase{hid_core_} {
|
: ControllerBase{hid_core_} {
|
||||||
static_assert(SHARED_MEMORY_OFFSET + sizeof(XpadSharedMemory) < shared_memory_size,
|
static_assert(SHARED_MEMORY_OFFSET + sizeof(XpadSharedMemory) < shared_memory_size,
|
||||||
"XpadSharedMemory is bigger than the shared memory");
|
"XpadSharedMemory is bigger than the shared memory");
|
||||||
shared_memory = std::construct_at(reinterpret_cast<XpadSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
shared_memory = std::construct_at(
|
||||||
|
reinterpret_cast<XpadSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
||||||
}
|
}
|
||||||
Controller_XPad::~Controller_XPad() = default;
|
Controller_XPad::~Controller_XPad() = default;
|
||||||
|
|
||||||
|
|
|
@ -90,11 +90,11 @@ private:
|
||||||
|
|
||||||
// This is nn::hid::detail::BasicXpadState
|
// This is nn::hid::detail::BasicXpadState
|
||||||
struct BasicXpadState {
|
struct BasicXpadState {
|
||||||
s64 sampling_number;
|
s64 sampling_number{};
|
||||||
BasicXpadAttributeSet attributes;
|
BasicXpadAttributeSet attributes{};
|
||||||
BasicXpadButtonSet pad_states;
|
BasicXpadButtonSet pad_states{};
|
||||||
Core::HID::AnalogStickState l_stick;
|
Core::HID::AnalogStickState l_stick{};
|
||||||
Core::HID::AnalogStickState r_stick;
|
Core::HID::AnalogStickState r_stick{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(BasicXpadState) == 0x20, "BasicXpadState is an invalid size");
|
static_assert(sizeof(BasicXpadState) == 0x20, "BasicXpadState is an invalid size");
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ private:
|
||||||
};
|
};
|
||||||
static_assert(sizeof(XpadSharedMemory) == 0x400, "XpadSharedMemory is an invalid size");
|
static_assert(sizeof(XpadSharedMemory) == 0x400, "XpadSharedMemory is an invalid size");
|
||||||
|
|
||||||
XpadSharedMemory* shared_memory;
|
|
||||||
BasicXpadState next_state{};
|
BasicXpadState next_state{};
|
||||||
|
XpadSharedMemory* shared_memory = nullptr;
|
||||||
};
|
};
|
||||||
} // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
Loading…
Reference in New Issue