diff options
Diffstat (limited to 'src/core/hid/hid_types.h')
-rw-r--r-- | src/core/hid/hid_types.h | 134 |
1 files changed, 93 insertions, 41 deletions
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h index 778b328b9..e3b1cfbc6 100644 --- a/src/core/hid/hid_types.h +++ b/src/core/hid/hid_types.h @@ -1,6 +1,5 @@ -// Copyright 2021 yuzu Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. +// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -273,6 +272,7 @@ enum class VibrationDeviceType : u32 { Unknown = 0, LinearResonantActuator = 1, GcErm = 2, + N64 = 3, }; // This is nn::hid::VibrationGcErmCommand @@ -317,27 +317,35 @@ static_assert(sizeof(TouchAttribute) == 0x4, "TouchAttribute is an invalid size" // This is nn::hid::TouchState struct TouchState { - u64 delta_time; - TouchAttribute attribute; - u32 finger; - Common::Point<u32> position; - u32 diameter_x; - u32 diameter_y; - u32 rotation_angle; + u64 delta_time{}; + TouchAttribute attribute{}; + u32 finger{}; + Common::Point<u32> position{}; + u32 diameter_x{}; + u32 diameter_y{}; + u32 rotation_angle{}; }; static_assert(sizeof(TouchState) == 0x28, "Touchstate is an invalid size"); +struct NpadColor { + u8 r{}; + u8 g{}; + u8 b{}; + u8 a{}; +}; +static_assert(sizeof(NpadColor) == 4, "NpadColor is an invalid size"); + // This is nn::hid::NpadControllerColor struct NpadControllerColor { - u32 body; - u32 button; + NpadColor body{}; + NpadColor button{}; }; static_assert(sizeof(NpadControllerColor) == 8, "NpadControllerColor is an invalid size"); // This is nn::hid::AnalogStickState struct AnalogStickState { - s32 x; - s32 y; + s32 x{}; + s32 y{}; }; static_assert(sizeof(AnalogStickState) == 8, "AnalogStickState is an invalid size"); @@ -355,10 +363,10 @@ static_assert(sizeof(NpadBatteryLevel) == 0x4, "NpadBatteryLevel is an invalid s // This is nn::hid::system::NpadPowerInfo struct NpadPowerInfo { - bool is_powered; - bool is_charging; + bool is_powered{}; + bool is_charging{}; INSERT_PADDING_BYTES(0x6); - NpadBatteryLevel battery_level; + NpadBatteryLevel battery_level{8}; }; static_assert(sizeof(NpadPowerInfo) == 0xC, "NpadPowerInfo is an invalid size"); @@ -475,8 +483,8 @@ static_assert(sizeof(DebugPadButton) == 0x4, "DebugPadButton is an invalid size" // This is nn::hid::ConsoleSixAxisSensorHandle struct ConsoleSixAxisSensorHandle { - u8 unknown_1; - u8 unknown_2; + u8 unknown_1{}; + u8 unknown_2{}; INSERT_PADDING_BYTES_NOINIT(2); }; static_assert(sizeof(ConsoleSixAxisSensorHandle) == 4, @@ -484,35 +492,79 @@ static_assert(sizeof(ConsoleSixAxisSensorHandle) == 4, // This is nn::hid::SixAxisSensorHandle struct SixAxisSensorHandle { - NpadStyleIndex npad_type; - u8 npad_id; - DeviceIndex device_index; + NpadStyleIndex npad_type{NpadStyleIndex::None}; + u8 npad_id{}; + DeviceIndex device_index{DeviceIndex::None}; INSERT_PADDING_BYTES_NOINIT(1); }; static_assert(sizeof(SixAxisSensorHandle) == 4, "SixAxisSensorHandle is an invalid size"); +// These parameters seem related to how much gyro/accelerometer is used struct SixAxisSensorFusionParameters { - f32 parameter1; - f32 parameter2; + f32 parameter1{0.03f}; // Range 0.0 to 1.0, default 0.03 + f32 parameter2{0.4f}; // Default 0.4 }; static_assert(sizeof(SixAxisSensorFusionParameters) == 8, "SixAxisSensorFusionParameters is an invalid size"); +// This is nn::hid::server::SixAxisSensorProperties +struct SixAxisSensorProperties { + union { + u8 raw{}; + BitField<0, 1, u8> is_newly_assigned; + BitField<1, 1, u8> is_firmware_update_available; + }; +}; +static_assert(sizeof(SixAxisSensorProperties) == 1, "SixAxisSensorProperties is an invalid size"); + +// This is nn::hid::SixAxisSensorCalibrationParameter +struct SixAxisSensorCalibrationParameter { + std::array<u8, 0x744> unknown_data{}; +}; +static_assert(sizeof(SixAxisSensorCalibrationParameter) == 0x744, + "SixAxisSensorCalibrationParameter is an invalid size"); + +// This is nn::hid::SixAxisSensorIcInformation +struct SixAxisSensorIcInformation { + f32 angular_rate{2000.0f}; // dps + std::array<f32, 6> unknown_gyro_data1{ + -10.0f, -10.0f, -10.0f, 10.0f, 10.0f, 10.0f, + }; // dps + std::array<f32, 9> unknown_gyro_data2{ + 0.95f, -0.003f, -0.003f, -0.003f, 0.95f, -0.003f, -0.003f, -0.003f, 0.95f, + }; + std::array<f32, 9> unknown_gyro_data3{ + 1.05f, 0.003f, 0.003f, 0.003f, 1.05f, 0.003f, 0.003f, 0.003f, 1.05f, + }; + f32 acceleration_range{8.0f}; // g force + std::array<f32, 6> unknown_accel_data1{ + -0.0612f, -0.0612f, -0.0612f, 0.0612f, 0.0612f, 0.0612f, + }; // g force + std::array<f32, 9> unknown_accel_data2{ + 0.95f, -0.003f, -0.003f, -0.003f, 0.95f, -0.003f, -0.003f, -0.003f, 0.95f, + }; + std::array<f32, 9> unknown_accel_data3{ + 1.05f, 0.003f, 0.003f, 0.003f, 1.05f, 0.003f, 0.003f, 0.003f, 1.05f, + }; +}; +static_assert(sizeof(SixAxisSensorIcInformation) == 0xC8, + "SixAxisSensorIcInformation is an invalid size"); + // This is nn::hid::VibrationDeviceHandle struct VibrationDeviceHandle { - NpadStyleIndex npad_type; - u8 npad_id; - DeviceIndex device_index; + NpadStyleIndex npad_type{NpadStyleIndex::None}; + u8 npad_id{}; + DeviceIndex device_index{DeviceIndex::None}; INSERT_PADDING_BYTES_NOINIT(1); }; static_assert(sizeof(VibrationDeviceHandle) == 4, "SixAxisSensorHandle is an invalid size"); // This is nn::hid::VibrationValue struct VibrationValue { - f32 low_amplitude; - f32 low_frequency; - f32 high_amplitude; - f32 high_frequency; + f32 low_amplitude{}; + f32 low_frequency{}; + f32 high_amplitude{}; + f32 high_frequency{}; }; static_assert(sizeof(VibrationValue) == 0x10, "VibrationValue has incorrect size."); @@ -561,7 +613,7 @@ static_assert(sizeof(KeyboardAttribute) == 0x4, "KeyboardAttribute is an invalid // This is nn::hid::KeyboardKey struct KeyboardKey { // 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"); @@ -590,16 +642,16 @@ static_assert(sizeof(MouseAttribute) == 0x4, "MouseAttribute is an invalid size" // This is nn::hid::detail::MouseState struct MouseState { - s64 sampling_number; - s32 x; - s32 y; - s32 delta_x; - s32 delta_y; + s64 sampling_number{}; + s32 x{}; + s32 y{}; + s32 delta_x{}; + s32 delta_y{}; // Axis Order in HW is switched for the wheel - s32 delta_wheel_y; - s32 delta_wheel_x; - MouseButton button; - MouseAttribute attribute; + s32 delta_wheel_y{}; + s32 delta_wheel_x{}; + MouseButton button{}; + MouseAttribute attribute{}; }; static_assert(sizeof(MouseState) == 0x28, "MouseState is an invalid size"); |