init static method

bool init({
  1. Duration eventLoopInterval = const Duration(milliseconds: 100),
})

Initializes the SDL library and starts the event loop.

Implementation

static bool init({
  Duration eventLoopInterval = const Duration(milliseconds: 100),
}) {
  if (isInitialized) return true;
  // Without this hint, events will not process on Windows.
  // For more details, see: https://github.com/libsdl-org/SDL/issues/10576
  sdl.sdlSetHint(sdl.SDL_HINT_JOYSTICK_THREAD, "1");
  final result = sdl.sdlInit(sdl.SDL_INIT_GAMEPAD);
  if (!result) return false;
  _eventLoop = Timer.periodic(eventLoopInterval, _update);
  isInitialized = true;
  return true;
}