mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-15 22:54:00 +00:00
input_common: Reset GC sticks center by measuring multiple packets
This commit is contained in:
parent
cd80471c90
commit
729545a946
2 changed files with 7 additions and 2 deletions
|
@ -155,8 +155,12 @@ void Adapter::UpdateStateAxes(std::size_t port, const AdapterPayload& adapter_pa
|
||||||
for (const PadAxes axis : axes) {
|
for (const PadAxes axis : axes) {
|
||||||
const auto index = static_cast<std::size_t>(axis);
|
const auto index = static_cast<std::size_t>(axis);
|
||||||
const u8 axis_value = adapter_payload[offset + 3 + index];
|
const u8 axis_value = adapter_payload[offset + 3 + index];
|
||||||
if (pads[port].axis_origin[index] == 255) {
|
if (pads[port].reset_origin_counter <= 18) {
|
||||||
|
if (pads[port].axis_origin[index] != axis_value) {
|
||||||
|
pads[port].reset_origin_counter = 0;
|
||||||
|
}
|
||||||
pads[port].axis_origin[index] = axis_value;
|
pads[port].axis_origin[index] = axis_value;
|
||||||
|
pads[port].reset_origin_counter++;
|
||||||
}
|
}
|
||||||
pads[port].axis_values[index] =
|
pads[port].axis_values[index] =
|
||||||
static_cast<s16>(axis_value - pads[port].axis_origin[index]);
|
static_cast<s16>(axis_value - pads[port].axis_origin[index]);
|
||||||
|
@ -375,7 +379,7 @@ void Adapter::ResetDevice(std::size_t port) {
|
||||||
pads[port].buttons = 0;
|
pads[port].buttons = 0;
|
||||||
pads[port].last_button = PadButton::Undefined;
|
pads[port].last_button = PadButton::Undefined;
|
||||||
pads[port].axis_values.fill(0);
|
pads[port].axis_values.fill(0);
|
||||||
pads[port].axis_origin.fill(255);
|
pads[port].reset_origin_counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adapter::Reset() {
|
void Adapter::Reset() {
|
||||||
|
|
|
@ -70,6 +70,7 @@ struct GCController {
|
||||||
PadButton last_button{};
|
PadButton last_button{};
|
||||||
std::array<s16, 6> axis_values{};
|
std::array<s16, 6> axis_values{};
|
||||||
std::array<u8, 6> axis_origin{};
|
std::array<u8, 6> axis_origin{};
|
||||||
|
u8 reset_origin_counter{};
|
||||||
};
|
};
|
||||||
|
|
||||||
class Adapter {
|
class Adapter {
|
||||||
|
|
Loading…
Reference in a new issue