[Input] Add last used controller tracker
This commit is contained in:
parent
0a0cd2a882
commit
842161ca9b
|
@ -100,6 +100,10 @@ X_RESULT InputSystem::GetState(uint32_t user_index, X_INPUT_STATE* out_state) {
|
||||||
if (result == X_ERROR_SUCCESS) {
|
if (result == X_ERROR_SUCCESS) {
|
||||||
UpdateUsedSlot(driver.get(), user_index, any_connected);
|
UpdateUsedSlot(driver.get(), user_index, any_connected);
|
||||||
AdjustDeadzoneLevels(user_index, &out_state->gamepad);
|
AdjustDeadzoneLevels(user_index, &out_state->gamepad);
|
||||||
|
|
||||||
|
if (out_state->gamepad.buttons != 0) {
|
||||||
|
last_used_slot = user_index;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,8 @@ class InputSystem {
|
||||||
return connected_slots;
|
return connected_slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t GetLastUsedSlot() const { return last_used_slot; }
|
||||||
|
|
||||||
std::unique_lock<xe_unlikely_mutex> lock();
|
std::unique_lock<xe_unlikely_mutex> lock();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -73,6 +75,7 @@ class InputSystem {
|
||||||
std::bitset<XUserMaxUserCount> connected_slots = {};
|
std::bitset<XUserMaxUserCount> connected_slots = {};
|
||||||
std::array<std::pair<joystick_value, joystick_value>, XUserMaxUserCount>
|
std::array<std::pair<joystick_value, joystick_value>, XUserMaxUserCount>
|
||||||
controllers_max_joystick_value = {};
|
controllers_max_joystick_value = {};
|
||||||
|
uint32_t last_used_slot = 0;
|
||||||
|
|
||||||
xe_unlikely_mutex lock_;
|
xe_unlikely_mutex lock_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "third_party/fmt/include/fmt/format.h"
|
#include "third_party/fmt/include/fmt/format.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/emulator.h"
|
#include "xenia/emulator.h"
|
||||||
|
#include "xenia/hid/input_system.h"
|
||||||
#include "xenia/kernel/kernel_state.h"
|
#include "xenia/kernel/kernel_state.h"
|
||||||
#include "xenia/kernel/util/crypto_utils.h"
|
#include "xenia/kernel/util/crypto_utils.h"
|
||||||
#include "xenia/vfs/devices/host_path_device.h"
|
#include "xenia/vfs/devices/host_path_device.h"
|
||||||
|
@ -149,6 +150,10 @@ UserProfile* ProfileManager::GetProfile(const uint64_t xuid) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
UserProfile* ProfileManager::GetProfile(uint8_t user_index) const {
|
UserProfile* ProfileManager::GetProfile(uint8_t user_index) const {
|
||||||
|
if (user_index == XUserIndexLatest) {
|
||||||
|
user_index = kernel_state_->emulator()->input_system()->GetLastUsedSlot();
|
||||||
|
}
|
||||||
|
|
||||||
if (user_index == XUserIndexNone) {
|
if (user_index == XUserIndexNone) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue