[SDL] Fixed spam caused by infinitely increasing packet count
It was incremented with each GetState instead of controller state update
This commit is contained in:
committed by
Radosław Gliński
parent
07501cfcb9
commit
520353e95a
@@ -226,11 +226,9 @@ X_RESULT SDLInputDriver::GetState(uint32_t user_index,
|
|||||||
return X_ERROR_DEVICE_NOT_CONNECTED;
|
return X_ERROR_DEVICE_NOT_CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure packet_number is only incremented by 1, even if there have been
|
if (controller->state_changed) {
|
||||||
// multiple updates between GetState calls. Also track `is_active` to
|
|
||||||
// increment the packet number if it changed.
|
|
||||||
if (controller->is_active || controller->state_changed) {
|
|
||||||
controller->state.packet_number++;
|
controller->state.packet_number++;
|
||||||
|
controller->state_changed = false;
|
||||||
}
|
}
|
||||||
std::memcpy(out_state, &controller->state, sizeof(*out_state));
|
std::memcpy(out_state, &controller->state, sizeof(*out_state));
|
||||||
return X_ERROR_SUCCESS;
|
return X_ERROR_SUCCESS;
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ class SDLInputDriver final : public InputDriver {
|
|||||||
X_INPUT_CAPABILITIES caps;
|
X_INPUT_CAPABILITIES caps;
|
||||||
X_INPUT_STATE state;
|
X_INPUT_STATE state;
|
||||||
bool state_changed;
|
bool state_changed;
|
||||||
bool is_active;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class RepeatState {
|
enum class RepeatState {
|
||||||
|
|||||||
Reference in New Issue
Block a user