new joycon
This commit is contained in:
parent
ed536603af
commit
b003224ff0
|
@ -203,7 +203,7 @@ void JoyconDriver::OnNewData(std::span<u8> buffer) {
|
|||
if (ring_connected && report_mode == ReportMode::STANDARD_FULL_60HZ) {
|
||||
InputReportActive data{};
|
||||
memcpy(&data, buffer.data(), sizeof(InputReportActive));
|
||||
calibration_protocol->GetRingCalibration(ring_calibration, data.ring_input);
|
||||
// calibration_protocol->GetRingCalibration(ring_calibration, data.ring_input);
|
||||
}
|
||||
|
||||
const RingStatus ring_status{
|
||||
|
|
|
@ -51,7 +51,7 @@ Common::Input::DriverResult GenericProtocol::GetControllerType(ControllerType& c
|
|||
|
||||
Common::Input::DriverResult GenericProtocol::EnableImu(bool enable) {
|
||||
ScopedSetBlocking sb(this);
|
||||
const std::array<u8, 1> buffer{static_cast<u8>(enable ? 1 : 0)};
|
||||
const std::array<u8, 1> buffer{static_cast<u8>(enable ? 2 : 0)};
|
||||
return SendSubCommand(SubCommand::ENABLE_IMU, buffer);
|
||||
}
|
||||
|
||||
|
|
|
@ -528,11 +528,9 @@ struct InputReportActive {
|
|||
std::array<u8, 3> left_stick_state;
|
||||
std::array<u8, 3> right_stick_state;
|
||||
u8 vibration_code;
|
||||
std::array<s16, 6 * 2> motion_input;
|
||||
INSERT_PADDING_BYTES(0x2);
|
||||
s16 ring_input;
|
||||
std::array<s16, 6 * 3> motion_input;
|
||||
};
|
||||
static_assert(sizeof(InputReportActive) == 0x29, "InputReportActive is an invalid size");
|
||||
static_assert(sizeof(InputReportActive) > 0x29, "InputReportActive is an invalid size");
|
||||
|
||||
struct InputReportNfcIr {
|
||||
ReportMode report_mode;
|
||||
|
|
|
@ -36,7 +36,7 @@ void JoyconPoller::ReadActiveMode(std::span<u8> buffer, const MotionStatus& moti
|
|||
}
|
||||
|
||||
if (ring_status.is_enabled) {
|
||||
UpdateRing(data.ring_input, ring_status);
|
||||
// UpdateRing(data.ring_input, ring_status);
|
||||
}
|
||||
|
||||
callbacks.on_battery_data(data.battery_status);
|
||||
|
@ -367,7 +367,72 @@ MotionData JoyconPoller::GetMotionInput(const InputReportActive& input,
|
|||
motion.gyro_y = GetGyroValue(raw_gyro_y, gyro_cal[0], motion_status.gyro_sensitivity);
|
||||
motion.gyro_z = GetGyroValue(raw_gyro_z, gyro_cal[2], motion_status.gyro_sensitivity);
|
||||
|
||||
std::array<u8, 18> gyro_raw{};
|
||||
memcpy(gyro_raw.data(), &input.motion_input[3], 2);
|
||||
memcpy(gyro_raw.data() + 2, &input.motion_input[4], 2);
|
||||
memcpy(gyro_raw.data() + 4, &input.motion_input[5], 2);
|
||||
memcpy(gyro_raw.data() + 6, &input.motion_input[9], 2);
|
||||
memcpy(gyro_raw.data() + 8, &input.motion_input[10], 2);
|
||||
memcpy(gyro_raw.data() + 10, &input.motion_input[11], 2);
|
||||
memcpy(gyro_raw.data() + 12, &input.motion_input[15], 2);
|
||||
memcpy(gyro_raw.data() + 14, &input.motion_input[16], 2);
|
||||
memcpy(gyro_raw.data() + 16, &input.motion_input[17], 2);
|
||||
|
||||
u32 aa = (gyro_raw[4] & 0xe0) << 0xb | (u32)gyro_raw[5] << 0x13 | (u32)gyro_raw[6] << 0x1b;
|
||||
u32 bb =
|
||||
(int)((gyro_raw[0] & 0xe0) << 0xb | (u32)gyro_raw[1] << 0x13 | (u32)gyro_raw[2] << 0x1b) >>
|
||||
0x10;
|
||||
u32 cc =
|
||||
(int)((gyro_raw[2] & 0xe0) << 0xb | (u32)gyro_raw[3] << 0x13 | (u32)gyro_raw[4] << 0x1b) >>
|
||||
0x10;
|
||||
// u32 aa = (gyro_raw[0] & 0xe0) << 0xb | gyro_raw[1] << 0x13 | gyro_raw[2] << 0x1b;
|
||||
// u32 bb = (gyro_raw[2] & 0xe0) << 0xb | gyro_raw[3] << 0x13 | gyro_raw[4] << 0x1b;
|
||||
// u32 cc = (gyro_raw[4] & 0xe0) << 0xb | gyro_raw[5] << 0x13 | gyro_raw[6] << 0x1b;
|
||||
// u32 dd = (gyro_raw[6] & 0xe0) << 0xb | gyro_raw[7] << 0x13 | gyro_raw[8] << 0x1b;
|
||||
// u32 ee = (gyro_raw[8] & 0xe0) << 0xb | gyro_raw[9] << 0x13 | gyro_raw[10] << 0x1b;
|
||||
// u32 ff = (gyro_raw[10] & 0xe0) << 0xb | gyro_raw[11] << 0x13 | gyro_raw[12] << 0x1b;
|
||||
|
||||
// u32 gg = (gyro_raw[0xc] & 0xe0) << 0x13 | gyro_raw[0xd] << 0x1b;
|
||||
// u32 hh = (gyro_raw[0xd] & 0xe0) << 0x13 | gyro_raw[0xe] << 0x1b;
|
||||
// u32 ii = (gyro_raw[0xe] & 0xe0) << 0x13 | gyro_raw[0xf] << 0x1b;
|
||||
|
||||
u32 uVar21 = (gyro_raw[0] & 0xf0) << 7 | (u32)gyro_raw[1] << 0xf | (u32)gyro_raw[2] << 0x17 |
|
||||
(u32)gyro_raw[3] << 0x1f;
|
||||
u32 uVar18 = (gyro_raw[3] & 0xfe) << 10 | (u32)gyro_raw[4] << 0x12 | (u32)gyro_raw[5] << 0x1a;
|
||||
u32 uVar20 = (gyro_raw[5] & 0xc0) << 5 | (u32)gyro_raw[6] << 0xd | (u32)gyro_raw[7] << 0x15 |
|
||||
(u32)gyro_raw[8] << 0x1d;
|
||||
|
||||
u32 iVar13 = (int)uVar21 >> 0xb;
|
||||
s32 iVar9 = iVar13 - ((int)((gyro_raw[8] & 0xf8) << 0x10 | (u32)gyro_raw[9] << 0x18) >> 0x13);
|
||||
u32 iVar26 = (int)uVar18 >> 0xb;
|
||||
s32 iVar10 = iVar26 - ((int)((u32)gyro_raw[10] << 0x13 | (u32)gyro_raw[0xb] << 0x1b) >> 0x13);
|
||||
u32 iVar25 = (int)uVar20 >> 0xb;
|
||||
s32 iVar11 = iVar25 - ((int)((gyro_raw[0xb] & 0xe0) << 0xe | (u32)gyro_raw[0xc] << 0x16 |
|
||||
(u32)gyro_raw[0xd] << 0x1e) >>
|
||||
0x13);
|
||||
|
||||
std::string str = "";
|
||||
for (u8 dddd : gyro_raw) {
|
||||
str += fmt::format("{:02x} ", dddd);
|
||||
}
|
||||
// LOG_ERROR(Input, "{}", str);
|
||||
|
||||
// LOG_ERROR(Input, "{}, {:08x} {:08x} {:08x} {:08x} {:08x} {:08x}, {:08x} {:08x} {:08x}",
|
||||
// gyro_raw[0] & 3, aa, bb, cc, dd, ee, ff, gg, hh, ii);
|
||||
|
||||
// LOG_ERROR(Input, "{}, {} {} {}",
|
||||
// gyro_raw[0] & 3, iVar9, iVar10, iVar11);
|
||||
LOG_ERROR(Input, "{}, {:08x} {:08x} {:08x}", gyro_raw[0] & 3, aa, bb, cc);
|
||||
//
|
||||
// TODO(German77): Return all three samples data
|
||||
|
||||
motion.accel_x = 0;
|
||||
motion.accel_y = 0;
|
||||
motion.accel_z = 0;
|
||||
motion.gyro_x = static_cast<float>(iVar9) / 5000000.0f;
|
||||
motion.gyro_y = static_cast<float>(iVar10) / 5000000.0f;
|
||||
motion.gyro_z = static_cast<float>(iVar11) / 5000000.0f;
|
||||
|
||||
return motion;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue