mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 08:13:05 +00:00
controller: merge stick and sensor events into the newest unread pad sample
This commit is contained in:
1 parent
7ff8aff5e6
commit
39faa62ebd
2 files changed
+35
No files matched your search
@@ -519,7 +519,20 @@ void GameController::SetDevices(int active_id) {
|
|||||||
m_trigger_state = {};
|
m_trigger_state = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Input that changes no button or touch contact updates the newest unread sample, so a burst of
|
||||||
|
// stick or sensor events between two reads cannot push unread button or touch changes out.
|
||||||
void GameController::AddState() {
|
void GameController::AddState() {
|
||||||
|
if (m_states_num != 0) {
|
||||||
|
const auto newest = (m_first_state + m_states_num - 1) % STATES_MAX;
|
||||||
|
auto& last = m_states[newest];
|
||||||
|
if (!m_obtained[newest] && last.buttons == m_state.buttons &&
|
||||||
|
last.touch[0].down == m_state.touch[0].down &&
|
||||||
|
last.touch[1].down == m_state.touch[1].down) {
|
||||||
|
last = m_state;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_states_num >= STATES_MAX) {
|
if (m_states_num >= STATES_MAX) {
|
||||||
m_states_num = STATES_MAX - 1;
|
m_states_num = STATES_MAX - 1;
|
||||||
m_first_state = (m_first_state + 1) % STATES_MAX;
|
m_first_state = (m_first_state + 1) % STATES_MAX;
|
||||||
|
|||||||
@@ -689,6 +689,27 @@ void TestTriggerEffectState() {
|
|||||||
check_state(0, 0, "switching controllers retained effect states");
|
check_state(0, 0, "switching controllers retained effect states");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestUnreadPressSurvivesStickBurst() {
|
||||||
|
Controller controller;
|
||||||
|
std::array<PadData, 64> data {};
|
||||||
|
SetButton(1, PAD_BUTTON_CROSS, true);
|
||||||
|
for (int value = 0; value < 100; value++) {
|
||||||
|
SetAxis(1, Axis::LeftX, value);
|
||||||
|
}
|
||||||
|
SetButton(1, PAD_BUTTON_CROSS, false);
|
||||||
|
for (int value = 100; value < 200; value++) {
|
||||||
|
SetAxis(1, Axis::LeftX, value);
|
||||||
|
}
|
||||||
|
Check(PadRead(1, data.data(), 64) == 2 && data[0].buttons == PAD_BUTTON_CROSS &&
|
||||||
|
data[0].left_stick_x == 99 && data[1].buttons == 0 && data[1].left_stick_x == 199,
|
||||||
|
"a stick burst pushed an unread press out of the pad history");
|
||||||
|
SetAxis(1, Axis::LeftX, 50);
|
||||||
|
SetButton(1, PAD_BUTTON_CROSS, true);
|
||||||
|
Check(PadRead(1, data.data(), 64) == 2 && data[0].buttons == 0 &&
|
||||||
|
data[0].left_stick_x == 50 && data[1].buttons == PAD_BUTTON_CROSS,
|
||||||
|
"a stick move after a read did not add a sample");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
@@ -702,6 +723,7 @@ int main() {
|
|||||||
TestMaskedTriggersAndValidation();
|
TestMaskedTriggersAndValidation();
|
||||||
TestIndependentOutputsAndPadSwitch();
|
TestIndependentOutputsAndPadSwitch();
|
||||||
TestTriggerEffectState();
|
TestTriggerEffectState();
|
||||||
|
TestUnreadPressSurvivesStickBurst();
|
||||||
TestMultiplayerRouting();
|
TestMultiplayerRouting();
|
||||||
TestDedicatedKeyboardOutputs();
|
TestDedicatedKeyboardOutputs();
|
||||||
Config::Shutdown();
|
Config::Shutdown();
|
||||||
|
|||||||
Reference in new issue
Block a user