[Input] Add last used controller tracker

This commit is contained in:
NicknineTheEagle
2024-10-07 21:58:59 +03:00
committed by Radosław Gliński
parent 0a0cd2a882
commit 842161ca9b
3 changed files with 12 additions and 0 deletions

View File

@@ -100,6 +100,10 @@ X_RESULT InputSystem::GetState(uint32_t user_index, X_INPUT_STATE* out_state) {
if (result == X_ERROR_SUCCESS) {
UpdateUsedSlot(driver.get(), user_index, any_connected);
AdjustDeadzoneLevels(user_index, &out_state->gamepad);
if (out_state->gamepad.buttons != 0) {
last_used_slot = user_index;
}
return result;
}
}

View File

@@ -53,6 +53,8 @@ class InputSystem {
return connected_slots;
}
uint32_t GetLastUsedSlot() const { return last_used_slot; }
std::unique_lock<xe_unlikely_mutex> lock();
private:
@@ -73,6 +75,7 @@ class InputSystem {
std::bitset<XUserMaxUserCount> connected_slots = {};
std::array<std::pair<joystick_value, joystick_value>, XUserMaxUserCount>
controllers_max_joystick_value = {};
uint32_t last_used_slot = 0;
xe_unlikely_mutex lock_;
};