[HID] Removed controllers_mutex from SDL.
Seems like it is unnecessary as there is some internal mutex that causes deadlocks with this one
This commit is contained in:
parent
cce070c129
commit
288900ff7e
|
@ -40,7 +40,6 @@ SDLInputDriver::SDLInputDriver(xe::ui::Window* window, size_t window_z_order)
|
||||||
sdl_events_unflushed_(0),
|
sdl_events_unflushed_(0),
|
||||||
sdl_pumpevents_queued_(false),
|
sdl_pumpevents_queued_(false),
|
||||||
controllers_(),
|
controllers_(),
|
||||||
controllers_mutex_(),
|
|
||||||
keystroke_states_() {}
|
keystroke_states_() {}
|
||||||
|
|
||||||
SDLInputDriver::~SDLInputDriver() {
|
SDLInputDriver::~SDLInputDriver() {
|
||||||
|
@ -151,8 +150,6 @@ X_RESULT SDLInputDriver::GetCapabilities(uint32_t user_index, uint32_t flags,
|
||||||
|
|
||||||
QueueControllerUpdate();
|
QueueControllerUpdate();
|
||||||
|
|
||||||
std::unique_lock<std::mutex> guard(controllers_mutex_);
|
|
||||||
|
|
||||||
auto controller = GetControllerState(user_index);
|
auto controller = GetControllerState(user_index);
|
||||||
if (!controller) {
|
if (!controller) {
|
||||||
return X_ERROR_DEVICE_NOT_CONNECTED;
|
return X_ERROR_DEVICE_NOT_CONNECTED;
|
||||||
|
@ -180,8 +177,6 @@ X_RESULT SDLInputDriver::GetState(uint32_t user_index,
|
||||||
QueueControllerUpdate();
|
QueueControllerUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_lock<std::mutex> guard(controllers_mutex_);
|
|
||||||
|
|
||||||
auto controller = GetControllerState(user_index);
|
auto controller = GetControllerState(user_index);
|
||||||
if (!controller) {
|
if (!controller) {
|
||||||
return X_ERROR_DEVICE_NOT_CONNECTED;
|
return X_ERROR_DEVICE_NOT_CONNECTED;
|
||||||
|
@ -295,8 +290,6 @@ X_RESULT SDLInputDriver::GetKeystroke(uint32_t users, uint32_t flags,
|
||||||
QueueControllerUpdate();
|
QueueControllerUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_lock<std::mutex> guard(controllers_mutex_);
|
|
||||||
|
|
||||||
for (uint32_t user_index = (user_any ? 0 : users);
|
for (uint32_t user_index = (user_any ? 0 : users);
|
||||||
user_index < (user_any ? HID_SDL_USER_COUNT : users + 1); user_index++) {
|
user_index < (user_any ? HID_SDL_USER_COUNT : users + 1); user_index++) {
|
||||||
auto controller = GetControllerState(user_index);
|
auto controller = GetControllerState(user_index);
|
||||||
|
@ -420,8 +413,6 @@ void SDLInputDriver::HandleEvent(const SDL_Event& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLInputDriver::OnControllerDeviceAdded(const SDL_Event& event) {
|
void SDLInputDriver::OnControllerDeviceAdded(const SDL_Event& event) {
|
||||||
std::unique_lock<std::mutex> guard(controllers_mutex_);
|
|
||||||
|
|
||||||
// Open the controller.
|
// Open the controller.
|
||||||
const auto controller = SDL_GameControllerOpen(event.cdevice.which);
|
const auto controller = SDL_GameControllerOpen(event.cdevice.which);
|
||||||
if (!controller) {
|
if (!controller) {
|
||||||
|
@ -485,8 +476,6 @@ void SDLInputDriver::OnControllerDeviceAdded(const SDL_Event& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLInputDriver::OnControllerDeviceRemoved(const SDL_Event& event) {
|
void SDLInputDriver::OnControllerDeviceRemoved(const SDL_Event& event) {
|
||||||
std::unique_lock<std::mutex> guard(controllers_mutex_);
|
|
||||||
|
|
||||||
// Find the disconnected gamecontroller and close it.
|
// Find the disconnected gamecontroller and close it.
|
||||||
auto idx = GetControllerIndexFromInstanceID(event.cdevice.which);
|
auto idx = GetControllerIndexFromInstanceID(event.cdevice.which);
|
||||||
if (idx) {
|
if (idx) {
|
||||||
|
@ -501,8 +490,6 @@ void SDLInputDriver::OnControllerDeviceRemoved(const SDL_Event& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLInputDriver::OnControllerDeviceAxisMotion(const SDL_Event& event) {
|
void SDLInputDriver::OnControllerDeviceAxisMotion(const SDL_Event& event) {
|
||||||
std::unique_lock<std::mutex> guard(controllers_mutex_);
|
|
||||||
|
|
||||||
auto idx = GetControllerIndexFromInstanceID(event.caxis.which);
|
auto idx = GetControllerIndexFromInstanceID(event.caxis.which);
|
||||||
assert(idx);
|
assert(idx);
|
||||||
auto& pad = controllers_.at(*idx).state.gamepad;
|
auto& pad = controllers_.at(*idx).state.gamepad;
|
||||||
|
@ -533,8 +520,6 @@ void SDLInputDriver::OnControllerDeviceAxisMotion(const SDL_Event& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLInputDriver::OnControllerDeviceButtonChanged(const SDL_Event& event) {
|
void SDLInputDriver::OnControllerDeviceButtonChanged(const SDL_Event& event) {
|
||||||
std::unique_lock<std::mutex> guard(controllers_mutex_);
|
|
||||||
|
|
||||||
// Define a lookup table to map between SDL and XInput button codes.
|
// Define a lookup table to map between SDL and XInput button codes.
|
||||||
// These need to be in the order of the SDL_GameControllerButton enum.
|
// These need to be in the order of the SDL_GameControllerButton enum.
|
||||||
static constexpr std::array<
|
static constexpr std::array<
|
||||||
|
|
|
@ -84,7 +84,6 @@ class SDLInputDriver final : public InputDriver {
|
||||||
int sdl_events_unflushed_;
|
int sdl_events_unflushed_;
|
||||||
std::atomic<bool> sdl_pumpevents_queued_;
|
std::atomic<bool> sdl_pumpevents_queued_;
|
||||||
std::array<ControllerState, HID_SDL_USER_COUNT> controllers_;
|
std::array<ControllerState, HID_SDL_USER_COUNT> controllers_;
|
||||||
std::mutex controllers_mutex_;
|
|
||||||
std::array<KeystrokeState, HID_SDL_USER_COUNT> keystroke_states_;
|
std::array<KeystrokeState, HID_SDL_USER_COUNT> keystroke_states_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue