Add poll interval to libScePad (#1415)

This commit is contained in:
Vladislav Mikhalin 2024-10-19 15:57:01 +03:00 committed by GitHub
parent 87f8fea4de
commit c38e3f77f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 38 additions and 2 deletions

View file

@ -4,6 +4,7 @@
#include <SDL3/SDL_events.h>
#include <SDL3/SDL_init.h>
#include <SDL3/SDL_properties.h>
#include <SDL3/SDL_timer.h>
#include <SDL3/SDL_video.h>
#include "common/assert.h"
#include "common/config.h"
@ -20,6 +21,11 @@
namespace Frontend {
static Uint32 SDLCALL PollController(void* userdata, SDL_TimerID timer_id, Uint32 interval) {
auto* controller = reinterpret_cast<Input::GameController*>(userdata);
return controller->Poll();
}
WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_,
std::string_view window_title)
: width{width_}, height{height_}, controller{controller_} {
@ -119,6 +125,10 @@ void WindowSDL::waitEvent() {
}
}
void WindowSDL::initTimers() {
SDL_AddTimer(100, &PollController, controller);
}
void WindowSDL::onResize() {
SDL_GetWindowSizeInPixels(window, &width, &height);
ImGui::Core::OnResize();