Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang format #3

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/device/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@ GamepadDevice::GamepadDevice() : m_should_poll(true)
*/
std::this_thread::sleep_for(std::chrono::milliseconds(2000));

m_polling_thread = SDL_CreateThread([](void *data) -> int {
static_cast<GamepadDevice *>(data)->polling_loop();
return 0;
}, "SDL Gamepad capture", this);
m_polling_thread = SDL_CreateThread(
[](void *data) -> int {
static_cast<GamepadDevice *>(data)->polling_loop();
return 0;
},
"SDL Gamepad capture", this);
}

GamepadDevice::~GamepadDevice()
Expand All @@ -160,7 +162,8 @@ void GamepadDevice::polling_iter()
SDL_UpdateGamepads();

std::lock_guard<std::mutex> lock(m_gamepads_mutex); // lock the gamepads vector for the whole iteration
while ((n = SDL_PeepEvents(events, SDL_arraysize(events), SDL_GETEVENT, SDL_EVENT_GAMEPAD_AXIS_MOTION, SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED)) > 0) {
while ((n = SDL_PeepEvents(events, SDL_arraysize(events), SDL_GETEVENT, SDL_EVENT_GAMEPAD_AXIS_MOTION,
SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED)) > 0) {
for (i = 0; i < n; ++i) {
SDL_Event *event = &events[i];
switch (event->type) {
Expand All @@ -172,8 +175,7 @@ void GamepadDevice::polling_iter()
remove_gamepad(event->gdevice.which);
obs_log(LOG_INFO, "Gamepad removed %d", event->gdevice.which);
break;
default:
break;
default: break;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/device/gamepad.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
class GamepadDevice : public InputDevice {
private:
std::vector<SDL_Gamepad *> m_gamepads;
std::mutex m_gamepads_mutex;
std::mutex m_gamepads_mutex;
SDL_Thread *m_polling_thread;
std::atomic<bool> m_should_poll;
std::atomic<bool> m_should_poll;

void add_gamepad(SDL_JoystickID joystickid);
void remove_gamepad(SDL_JoystickID joystickid);
Expand Down