mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-07-11 02:14:43 -06:00
attempt to fix event_queue bugs
This commit is contained in:
parent
a6b3c3236f
commit
303ba4fb4e
@ -28,6 +28,7 @@ ControllerSequenceDialog::ControllerSequenceDialog(QWidget* parent)
|
||||
|
||||
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
connect(this, &QDialog::finished, this, [this](int) { StopPolling(); });
|
||||
|
||||
LaunchPollers();
|
||||
}
|
||||
@ -90,4 +91,11 @@ void ControllerSequenceDialog::LaunchPollers() {
|
||||
}
|
||||
});
|
||||
poll_timer->start(100);
|
||||
}
|
||||
|
||||
void ControllerSequenceDialog::StopPolling() {
|
||||
poll_timer->stop();
|
||||
for (auto& poller : device_pollers) {
|
||||
poller->Stop();
|
||||
}
|
||||
}
|
||||
@ -22,6 +22,7 @@ public:
|
||||
|
||||
private:
|
||||
void LaunchPollers();
|
||||
void StopPolling();
|
||||
QLabel* textBox;
|
||||
QString key_sequence;
|
||||
Common::ParamPackage params1, params2;
|
||||
|
||||
@ -141,6 +141,10 @@ static int SDLEventWatcher(void* userdata, SDL_Event* event) {
|
||||
}
|
||||
// deal
|
||||
if (sdl_state->polling) {
|
||||
if (sdl_state->event_queue.Size() >= sdl_state->MAX_EVENT_QUEUE_SIZE) {
|
||||
// safety - before pushing, clear if it has somehow ballooned in size
|
||||
sdl_state->event_queue.Clear();
|
||||
}
|
||||
sdl_state->event_queue.Push(*event);
|
||||
} else {
|
||||
sdl_state->HandleGameControllerEvent(*event);
|
||||
@ -938,6 +942,7 @@ public:
|
||||
}
|
||||
|
||||
void Stop() override {
|
||||
state.event_queue.Clear();
|
||||
state.polling = false;
|
||||
}
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@ public:
|
||||
/// Used by the Pollers during config
|
||||
std::atomic<bool> polling = false;
|
||||
Common::SPSCQueue<SDL_Event> event_queue;
|
||||
static constexpr size_t MAX_EVENT_QUEUE_SIZE = 10000;
|
||||
|
||||
private:
|
||||
void InitJoystick(int joystick_index);
|
||||
@ -72,5 +73,6 @@ private:
|
||||
std::atomic<bool> initialized = false;
|
||||
|
||||
std::thread poll_thread;
|
||||
// maximum events allowed in the queue - if more than this are there, something is wrong
|
||||
};
|
||||
} // namespace InputCommon::SDL
|
||||
|
||||
Loading…
Reference in New Issue
Block a user