Only activate sixaxis for controller type + fix cemuhookudp
Cemuhookudp patch from johngalt
This commit is contained in:
@@ -236,8 +236,7 @@ void Controller_NPad::OnLoadInputDevices() {
|
|||||||
players[i].analogs.begin() + Settings::NativeAnalog::STICK_HID_END,
|
players[i].analogs.begin() + Settings::NativeAnalog::STICK_HID_END,
|
||||||
sticks[i].begin(), Input::CreateDevice<Input::AnalogDevice>);
|
sticks[i].begin(), Input::CreateDevice<Input::AnalogDevice>);
|
||||||
}
|
}
|
||||||
motion_sensors[Settings::values.udp_pad_index] =
|
motion_sensors[0] = Input::CreateDevice<Input::MotionDevice>(Settings::values.motion_device);
|
||||||
Input::CreateDevice<Input::MotionDevice>(Settings::values.motion_device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_NPad::OnRelease() {}
|
void Controller_NPad::OnRelease() {}
|
||||||
@@ -368,6 +367,12 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
|
|||||||
RequestPadStateUpdate(npad_index);
|
RequestPadStateUpdate(npad_index);
|
||||||
auto& pad_state = npad_pad_states[npad_index];
|
auto& pad_state = npad_pad_states[npad_index];
|
||||||
|
|
||||||
|
// Try to get motion sensor state if it exists
|
||||||
|
Common::Vec3f accel, gyro;
|
||||||
|
if (sixaxis_sensor_enabled && motion_sensors[i]) {
|
||||||
|
std::tie(accel, gyro) = motion_sensors[i]->GetStatus();
|
||||||
|
}
|
||||||
|
|
||||||
auto& main_controller =
|
auto& main_controller =
|
||||||
npad.main_controller_states.npad[npad.main_controller_states.common.last_entry_index];
|
npad.main_controller_states.npad[npad.main_controller_states.common.last_entry_index];
|
||||||
auto& handheld_entry =
|
auto& handheld_entry =
|
||||||
@@ -396,6 +401,11 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
|
|||||||
handheld_entry.pad.pad_states.raw = pad_state.pad_states.raw;
|
handheld_entry.pad.pad_states.raw = pad_state.pad_states.raw;
|
||||||
handheld_entry.pad.l_stick = pad_state.l_stick;
|
handheld_entry.pad.l_stick = pad_state.l_stick;
|
||||||
handheld_entry.pad.r_stick = pad_state.r_stick;
|
handheld_entry.pad.r_stick = pad_state.r_stick;
|
||||||
|
|
||||||
|
if (sixaxis_sensor_enabled && motion_sensors[i]) {
|
||||||
|
npad.handheld.sixaxis[npad.handheld.common.last_entry_index].accelerometer = accel;
|
||||||
|
npad.handheld.sixaxis[npad.handheld.common.last_entry_index].gyroscope = gyro;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NPadControllerType::JoyDual:
|
case NPadControllerType::JoyDual:
|
||||||
dual_entry.connection_status.raw = 0;
|
dual_entry.connection_status.raw = 0;
|
||||||
@@ -411,6 +421,17 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
|
|||||||
dual_entry.pad.pad_states.raw = pad_state.pad_states.raw;
|
dual_entry.pad.pad_states.raw = pad_state.pad_states.raw;
|
||||||
dual_entry.pad.l_stick = pad_state.l_stick;
|
dual_entry.pad.l_stick = pad_state.l_stick;
|
||||||
dual_entry.pad.r_stick = pad_state.r_stick;
|
dual_entry.pad.r_stick = pad_state.r_stick;
|
||||||
|
|
||||||
|
if (sixaxis_sensor_enabled && motion_sensors[i]) {
|
||||||
|
// TODO(anirudhb): Separate inputs for dual joy-cons.
|
||||||
|
npad.left_dual.sixaxis[npad.left_dual.common.last_entry_index].accelerometer =
|
||||||
|
accel;
|
||||||
|
npad.left_dual.sixaxis[npad.left_dual.common.last_entry_index].gyroscope = gyro;
|
||||||
|
|
||||||
|
npad.right_dual.sixaxis[npad.right_dual.common.last_entry_index].accelerometer =
|
||||||
|
accel;
|
||||||
|
npad.right_dual.sixaxis[npad.right_dual.common.last_entry_index].gyroscope = gyro;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NPadControllerType::JoyLeft:
|
case NPadControllerType::JoyLeft:
|
||||||
left_entry.connection_status.raw = 0;
|
left_entry.connection_status.raw = 0;
|
||||||
@@ -419,6 +440,11 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
|
|||||||
left_entry.pad.pad_states.raw = pad_state.pad_states.raw;
|
left_entry.pad.pad_states.raw = pad_state.pad_states.raw;
|
||||||
left_entry.pad.l_stick = pad_state.l_stick;
|
left_entry.pad.l_stick = pad_state.l_stick;
|
||||||
left_entry.pad.r_stick = pad_state.r_stick;
|
left_entry.pad.r_stick = pad_state.r_stick;
|
||||||
|
|
||||||
|
if (sixaxis_sensor_enabled && motion_sensors[i]) {
|
||||||
|
npad.left.sixaxis[npad.left.common.last_entry_index].accelerometer = accel;
|
||||||
|
npad.left.sixaxis[npad.left.common.last_entry_index].gyroscope = gyro;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NPadControllerType::JoyRight:
|
case NPadControllerType::JoyRight:
|
||||||
right_entry.connection_status.raw = 0;
|
right_entry.connection_status.raw = 0;
|
||||||
@@ -427,6 +453,11 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
|
|||||||
right_entry.pad.pad_states.raw = pad_state.pad_states.raw;
|
right_entry.pad.pad_states.raw = pad_state.pad_states.raw;
|
||||||
right_entry.pad.l_stick = pad_state.l_stick;
|
right_entry.pad.l_stick = pad_state.l_stick;
|
||||||
right_entry.pad.r_stick = pad_state.r_stick;
|
right_entry.pad.r_stick = pad_state.r_stick;
|
||||||
|
|
||||||
|
if (sixaxis_sensor_enabled && motion_sensors[i]) {
|
||||||
|
npad.right.sixaxis[npad.right.common.last_entry_index].accelerometer = accel;
|
||||||
|
npad.right.sixaxis[npad.right.common.last_entry_index].gyroscope = gyro;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NPadControllerType::Pokeball:
|
case NPadControllerType::Pokeball:
|
||||||
pokeball_entry.connection_status.raw = 0;
|
pokeball_entry.connection_status.raw = 0;
|
||||||
@@ -446,6 +477,11 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
|
|||||||
main_controller.pad.pad_states.raw = pad_state.pad_states.raw;
|
main_controller.pad.pad_states.raw = pad_state.pad_states.raw;
|
||||||
main_controller.pad.l_stick = pad_state.l_stick;
|
main_controller.pad.l_stick = pad_state.l_stick;
|
||||||
main_controller.pad.r_stick = pad_state.r_stick;
|
main_controller.pad.r_stick = pad_state.r_stick;
|
||||||
|
|
||||||
|
if (sixaxis_sensor_enabled && motion_sensors[i]) {
|
||||||
|
npad.full.sixaxis[npad.full.common.last_entry_index].accelerometer = accel;
|
||||||
|
npad.full.sixaxis[npad.full.common.last_entry_index].gyroscope = gyro;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,19 +491,6 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
|
|||||||
libnx_entry.pad.l_stick = pad_state.l_stick;
|
libnx_entry.pad.l_stick = pad_state.l_stick;
|
||||||
libnx_entry.pad.r_stick = pad_state.r_stick;
|
libnx_entry.pad.r_stick = pad_state.r_stick;
|
||||||
|
|
||||||
// Set this entry regardless of the controller type, for now.
|
|
||||||
if (motion_sensors[i] && sixaxis_sensor_enabled) {
|
|
||||||
const auto& sensor = motion_sensors[i];
|
|
||||||
Common::Vec3f accel, gyro;
|
|
||||||
std::tie(accel, gyro) = sensor->GetStatus();
|
|
||||||
// Try to set it for all entries
|
|
||||||
for (auto* sixaxis : controller_sixaxes) {
|
|
||||||
sixaxis->sixaxis[sixaxis->common.last_entry_index].accelerometer = accel;
|
|
||||||
sixaxis->sixaxis[sixaxis->common.last_entry_index].gyroscope = gyro;
|
|
||||||
sixaxis->sixaxis[sixaxis->common.last_entry_index].always_one = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
press_state |= static_cast<u32>(pad_state.pad_states.raw);
|
press_state |= static_cast<u32>(pad_state.pad_states.raw);
|
||||||
}
|
}
|
||||||
std::memcpy(data + NPAD_OFFSET, shared_memory_entries.data(),
|
std::memcpy(data + NPAD_OFFSET, shared_memory_entries.data(),
|
||||||
|
|||||||
@@ -238,14 +238,14 @@ private:
|
|||||||
static_assert(sizeof(NPadGeneric) == 0x350, "NPadGeneric is an invalid size");
|
static_assert(sizeof(NPadGeneric) == 0x350, "NPadGeneric is an invalid size");
|
||||||
|
|
||||||
struct SixAxisState {
|
struct SixAxisState {
|
||||||
s64_le timestamp;
|
s64_le timestamp{};
|
||||||
INSERT_PADDING_BYTES(8); // unknown
|
INSERT_PADDING_WORDS(2); // unknown
|
||||||
s64_le timestamp2;
|
s64_le timestamp2{};
|
||||||
Common::Vec3f accelerometer;
|
Common::Vec3f accelerometer{};
|
||||||
Common::Vec3f gyroscope;
|
Common::Vec3f gyroscope{};
|
||||||
INSERT_PADDING_BYTES(12); // unknown sensor data
|
INSERT_PADDING_WORDS(3); // unknown
|
||||||
std::array<Common::Vec3f, 3> orientation;
|
std::array<Common::Vec3f, 3> orientation{};
|
||||||
s64_le always_one; // always 1
|
s64_le always_one{1}; // always 1
|
||||||
};
|
};
|
||||||
static_assert(sizeof(SixAxisState) == 0x68, "SixAxisState is an invalid size");
|
static_assert(sizeof(SixAxisState) == 0x68, "SixAxisState is an invalid size");
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StartSend(const clock::time_point& from) {
|
void StartSend(const clock::time_point& from) {
|
||||||
timer.expires_at(from + std::chrono::seconds(3));
|
timer.expires_at(from);
|
||||||
timer.async_wait([this](const boost::system::error_code& error) { HandleSend(error); });
|
timer.async_wait([this](const boost::system::error_code& error) { HandleSend(error); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user