public void Dispose () { var e = new SDL.SDL_Event() { quit = { type = SDL.SDL_EventType.SDL_QUIT, } }; foreach (var view in _views) view.EnqueueEvent(e); foreach (var view in _views) view.Join(); }
public static void ProgramInit() { /* SDL2 might complain if an OS that uses SDL_main has not actually * used SDL_main by the time you initialize SDL2. * The only platform that is affected is Windows, but we can skip * their WinMain. This was only added to prevent iOS from exploding. * -flibit */ SDL.SDL_SetMainReady(); // If available, load the SDL_GameControllerDB string mappingsDB = Path.Combine( TitleContainer.Location, "gamecontrollerdb.txt" ); if (File.Exists(mappingsDB)) { SDL.SDL_GameControllerAddMappingsFromFile( mappingsDB ); } // This _should_ be the first real SDL call we make... SDL.SDL_Init( SDL.SDL_INIT_VIDEO | SDL.SDL_INIT_JOYSTICK | SDL.SDL_INIT_GAMECONTROLLER | SDL.SDL_INIT_HAPTIC ); // Set any hints to match XNA4 behavior... string hint = SDL.SDL_GetHint(SDL.SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS); if (String.IsNullOrEmpty(hint)) { SDL.SDL_SetHint( SDL.SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1" ); } // We want to initialize the controllers ASAP! SDL.SDL_Event[] evt = new SDL.SDL_Event[1]; SDL.SDL_PumpEvents(); while (SDL.SDL_PeepEvents( evt, 1, SDL.SDL_eventaction.SDL_GETEVENT, SDL.SDL_EventType.SDL_CONTROLLERDEVICEADDED, SDL.SDL_EventType.SDL_CONTROLLERDEVICEADDED ) == 1) { INTERNAL_AddInstance(evt[0].cdevice.which); } }
private static void RunGame() { // Create the main render window. SDLWindow window = new SDLWindow( "An SDL2 window", 100, 100, 800, 600 ); SDLRenderer renderer = new SDLRenderer( window ); // Load a test image. SDLTexture texture = new SDLTexture( renderer, "hello.bmp" ); SDLFont font = new SDLFont( renderer, "hello.ttf", 24 ); SDLTexture textTexture = font.RenderTextBlended( renderer, "Hello World!!", Color.BlueColor ); // Event loop. SDL.SDL_Event eventInfo = new SDL.SDL_Event(); bool shouldQuit = false; while ( !shouldQuit ) { CheckForSDLErrors(); // Pump and process pending OS events. while ( SDL.SDL_PollEvent( out eventInfo ) != 0 ) { if ( eventInfo.type == SDL.SDL_EventType.SDL_QUIT ) { shouldQuit = true; } } // Render all of our stuffs. renderer.Clear(); renderer.Draw( texture, 32, 32 ); renderer.Draw( textTexture, 0, 400 ); renderer.Present(); } }
public override void BeforeInitialize() { base.BeforeInitialize(); // We want to initialize the controllers ASAP! SDL.SDL_Event[] evt = new SDL.SDL_Event[1]; SDL.SDL_PumpEvents(); // Required to get OSX device events this early. while (SDL.SDL_PeepEvents( evt, 1, SDL.SDL_eventaction.SDL_GETEVENT, SDL.SDL_EventType.SDL_CONTROLLERDEVICEADDED, SDL.SDL_EventType.SDL_CONTROLLERDEVICEADDED ) == 1) { GamePad.INTERNAL_AddInstance(evt[0].cdevice.which); } //Sometimes Android hates us. Sometimes it hates us horribly. And sometimes THIS happens! if (OSVersion.Equals("Android")) { int numJoysticks = SDL.SDL_NumJoysticks(); for (int i = 0; i < numJoysticks; i++) { GamePad.INTERNAL_AddInstance(i); } } }
public override void BeforeInitialize() { base.BeforeInitialize(); // We want to initialize the controllers ASAP! SDL.SDL_Event[] evt = new SDL.SDL_Event[1]; SDL.SDL_PumpEvents(); // Required to get OSX device events this early. while (SDL.SDL_PeepEvents( evt, 1, SDL.SDL_eventaction.SDL_GETEVENT, SDL.SDL_EventType.SDL_JOYDEVICEADDED, SDL.SDL_EventType.SDL_JOYDEVICEADDED ) == 1) { GamePad.INTERNAL_AddInstance(evt[0].jdevice.which); } // Also, initialize the MonoGameJoystick.cfg file. GamePad.INTERNAL_InitMonoGameJoystick(); }
public static void BeforeInitialize() { // We want to initialize the controllers ASAP! SDL.SDL_Event[] evt = new SDL.SDL_Event[1]; SDL.SDL_PumpEvents(); // Required to get OSX device events this early. while (SDL.SDL_PeepEvents( evt, 1, SDL.SDL_eventaction.SDL_GETEVENT, SDL.SDL_EventType.SDL_CONTROLLERDEVICEADDED, SDL.SDL_EventType.SDL_CONTROLLERDEVICEADDED ) == 1) { INTERNAL_AddInstance(evt[0].cdevice.which); } }
// Called from main thread public void Dispose () { if (_isDisposed) return; var e = new SDL.SDL_Event() { window = { type = SDL.SDL_EventType.SDL_WINDOWEVENT, windowID = _windowId, windowEvent = SDL.SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE, } }; if (_thread != null) { EnqueueEvent(e); Join(); } else SDL.SDL_PushEvent(ref e); }
public SDL2EventArgs (SDL.SDL_Event sdlEvent) { _event = sdlEvent; }