public static SdlEventArgs[] Peek(EventMask event_mask, int number_of_events) { SdlSystem.SDL_Event[] events = new SdlSystem.SDL_Event[number_of_events]; SdlSystem.SDL_PumpEvents(); int ret = SdlSystem.SDL_PeepEvents(out events, events.Length, SdlSystem.SDL_eventaction.SDL_PEEKEVENT, (uint)event_mask); if (ret == (int)NativeFunctionReturnFlags.Error) { throw SdlException.Generate(); } SdlEventArgs[] eventargs_array = new SdlEventArgs[ret]; for (int i = 0; i < eventargs_array.Length; ++i) { if (events[i].type == (byte)EventTypes.UserEvent) { eventargs_array[i] = __user_events[events[i].user.code.ToString()]; __user_events.Remove(events[i].user.code.ToString()); } else { eventargs_array[i] = SdlEventArgs.CreateEventArgs(events[i]); } } return(eventargs_array); }
public static void Close() { Active = null; KeyboardDown = null; KeyboardUp = null; MouseMotion = null; MouseButtonDown = null; MouseButtonUp = null; JoystickButtonDown = null; JoystickButtonUp = null; JoystickAxisMotion = null; JoystickHatMotion = null; JoystickBallMotion = null; VideoResize = null; VideoExpose = null; WindowManagerEvent = null; ChannelFinished = null; MusicFinished = null; Tick = null; Events.CloseJoysticks(); Events.CloseCDRom(); Events.CloseMixer(); Events.CloseTimer(); Events.CloseVideo(); SdlSystem.SDL_Quit(); Quit = null; }
public static bool Poll(int number_of_events) { SdlSystem.SDL_Event e; bool ret = false; for (int i = 0; i < number_of_events; ++i) { int retval = SdlSystem.SDL_PollEvent(out e); if (retval == (int)NativeFunctionReturnFlags.Error) { throw SdlException.Generate(); } if (retval == (int)NativeFunctionReturnFlags.None) { ret = true; break; } else { ProcessEvent(e); } } return(ret); }
/// <summary> /// Closes any system. /// </summary> /// <param name='system_flag'> /// System_flag. /// </param> private static void CloseAnySystem(int system_flag) { if (SdlSystem.SDL_WasInit((uint)system_flag) != 0) { SdlSystem.SDL_QuitSubSystem((uint)system_flag); } }
/// <summary> /// Close this instance. /// </summary> public static void Close() { if (SdlSystem.SDL_WasInit(SdlSystem.SDL_INIT_TIMER) != 0) { SdlSystem.SDL_QuitSubSystem(SdlSystem.SDL_INIT_TIMER); } }
/// <summary> /// Closes the audio. /// </summary> public static void CloseAudio() { SdlSystem.SDL_CloseAudio(); Mixer.AudioOpen = false; Mixer.AudioLocked = false; Events.CloseMixer(); }
public static void Wait() { SdlSystem.SDL_Event e; if (SdlSystem.SDL_WaitEvent(out e) == (int)NativeFunctionReturnFlags.Error) { throw SdlException.Generate(); } ProcessEvent(e); }
/// <summary> /// Generate this instance. /// </summary> public static SdlException Generate() { string message = SdlSystem.SDL_GetError(); if (message.IndexOf("Surface was lost") == -1) { return(new SdlException(message)); } else { return(new SurfaceLostException(message)); } }
public static void PushEvent(SdlEventArgs sdl_event) { if (null == sdl_event) { throw new ArgumentNullException("sdl_event"); } SdlSystem.SDL_Event e = sdl_event.EventStruct; if (SdlSystem.SDL_PushEvent(out e) != (int)NativeFunctionReturnFlags.Success) { /* nothing */ } }
/// <summary> /// Delaies the seconds. /// </summary> /// <param name='delay_time'> /// Delay_time. /// </param> /// <exception cref='OverflowException'> /// Is thrown when the result of an arithmetic operation is too large to be represented by the destination type. /// </exception> public static void DelaySeconds(int delay_time) { int delay_time_max = int.MaxValue / 1000; int delay_time_temp = delay_time * 1000; if (delay_time_temp <= delay_time_max) { SdlSystem.SDL_Delay((uint)delay_time); } else { throw new OverflowException(); } }
public static void Remove(EventMask event_mask, int number_of_events) { SdlSystem.SDL_Event[] events = new SdlSystem.SDL_Event[number_of_events]; SdlSystem.SDL_PumpEvents(); int ret = SdlSystem.SDL_PeepEvents(out events, events.Length, SdlSystem.SDL_eventaction.SDL_GETEVENT, (uint)event_mask); if (ret == (int)NativeFunctionReturnFlags.Error) { throw SdlException.Generate(); } }
/// <summary> /// Initialize this instance. /// </summary> public static bool Initialize() { if (SdlSystem.SDL_WasInit(SdlSystem.SDL_INIT_TIMER) == (int)NativeFunctionReturnFlags.FalseValue) { if (SdlSystem.SDL_Init(SdlSystem.SDL_INIT_TIMER) == (int)NativeFunctionReturnFlags.Success) { return(true); } else { throw SdlException.Generate(); } } else { return(true); } }
public static void PushUserEvent(UserEventArgs user_event) { if (null == user_event) { throw new ArgumentNullException("user_event"); } lock ( __instance ) { __user_events[__user_event_id.ToString()] = user_event; user_event.UserCode = __user_event_id; ++__user_event_id; } SdlSystem.SDL_Event e = user_event.EventStruct; if (SdlSystem.SDL_PushEvent(out e) != (int)NativeFunctionReturnFlags.Success) { /* nothing */ } }
public static bool Poll() { try { SdlSystem.SDL_Event e; int ret = SdlSystem.SDL_PollEvent(out e); if (ret == (int)NativeFunctionReturnFlags.Error) { throw SdlException.Generate(); } if (ret == (int)NativeFunctionReturnFlags.None) { return(false); } else { ProcessEvent(e); return(true); } } catch (AccessViolationException) { return(false); } }
/// <summary> /// Initializes a new instance of the <see cref="Sdl.Core.WindowManagerEventArgs"/> class. /// </summary> /// <param name='ev'> /// Ev. /// </param> internal WindowManagerEventArgs(SdlSystem.SDL_Event ev) : base( ev ) { }
/// <summary> /// Creates the event arguments. /// </summary> /// <returns> /// The event arguments. /// </returns> /// <param name='e'> /// The ${ParameterType} instance containing the event data. /// </param> /// <exception cref='NotImplementedException'> /// Is thrown when a requested operation is not implemented for a given type. /// </exception> public static new WindowManagerEventArgs CreateEventArgs(SdlSystem.SDL_Event e) { return new WindowManagerEventArgs( e ); }
/// <summary> /// Initializes a new instance of the <see cref="Sdl.Graphics.VideoExposeEventArgs"/> class. /// </summary> /// <param name='ev'> /// Ev. /// </param> internal VideoExposeEventArgs(SdlSystem.SDL_Event ev) : base( ev ) { }
/// <summary> /// Initializes a new instance of the <see cref="Sdl.Input.JoystickBallEventArgs"/> class. /// </summary> /// <param name='ev'> /// Ev. /// </param> internal JoystickBallEventArgs(SdlSystem.SDL_Event ev) : base(ev) { }
/// <summary> /// Initializes a new instance of the <see cref="Sdl.Core.ActiveEventArgs"/> class. /// </summary> /// <param name='ev'> /// Ev. /// </param> internal ActiveEventArgs(SdlSystem.SDL_Event ev) : base(ev) { }
/// <summary> /// Processes the event. /// </summary> /// <param name='e'> /// E. /// </param> private static void ProcessEvent(SdlSystem.SDL_Event e) { switch ( (EventTypes)e.type ) { case EventTypes.ActiveEvent: OnActiveEvent( ActiveEventArgs.CreateEventArgs( e ) ); break; case EventTypes.KeyDown: OnKeyboardDown( KeyboardEventArgs.CreateEventArgs( e ) ); break; case EventTypes.KeyUp: OnKeyboardUp( KeyboardEventArgs.CreateEventArgs( e ) ); break; case EventTypes.MouseMotion: OnMouseMotion( MouseMotionEventArgs.CreateEventArgs( e ) ); break; case EventTypes.MouseButtonDown: OnMouseButtonDown( MouseButtonEventArgs.CreateEventArgs( e ) ); break; case EventTypes.MouseButtonUp: OnMouseButtonUp( MouseButtonEventArgs.CreateEventArgs( e ) ); break; case EventTypes.JoystickAxisMotion: OnJoystickAxisMotion( JoystickAxisEventArgs.CreateEventArgs( e ) ); break; case EventTypes.JoystickBallMotion: OnJoystickBallMotion( JoystickBallEventArgs.CreateEventArgs( e ) ); break; case EventTypes.JoystickHatMotion: OnJoystickHatMotion( JoystickHatEventArgs.CreateEventArgs( e ) ); break; case EventTypes.JoystickButtonDown: OnJoystickButtonDown( JoystickButtonEventArgs.CreateEventArgs( e ) ); break; case EventTypes.JoystickButtonUp: OnJoystickButtonUp( JoystickButtonEventArgs.CreateEventArgs( e ) ); break; case EventTypes.VideoResize: OnVideoResize( VideoResizeEventArgs.CreateEventArgs( e ) ); break; case EventTypes.VideoExpose: OnVideoExpose( VideoExposeEventArgs.CreateEventArgs( e ) ); break; case EventTypes.Quit: OnQuit( QuitEventArgs.CreateEventArgs( e ) ); break; case EventTypes.WindowManagerEvent: OnWindowManagerEvent( WindowManagerEventArgs.CreateEventArgs( e ) ); break; case EventTypes.UserEvent: OnUserEvent( UserEventArgs.CreateEventArgs( e ) ); break; } }
/// <summary> /// Initializes a new instance of the <see cref="Sdl.Core.SdlEventArgs"/> class. /// </summary> /// <param name='event_struct'> /// Event_struct. /// </param> internal SdlEventArgs(SdlSystem.SDL_Event event_struct) { this.event_struct_ = event_struct; }
/// <summary> /// Delaies the ticks. /// </summary> /// <param name='delay_time'> /// Delay_time. /// </param> public static void DelayTicks(uint delay_time) { SdlSystem.SDL_Delay(delay_time); }
/// <summary> /// Initializes a new instance of the <see cref="Sdl.Input.MouseButtonEventArgs"/> class. /// </summary> /// <param name='ev'> /// Ev. /// </param> internal MouseButtonEventArgs(SdlSystem.SDL_Event ev) : base(ev) { }
/// <summary> /// Creates the event arguments. /// </summary> /// <returns> /// The event arguments. /// </returns> /// <param name='ev'> /// The ${ParameterType} instance containing the event data. /// </param> internal static SdlEventArgs CreateEventArgs(SdlSystem.SDL_Event ev) { switch ( (EventTypes)ev.type ) { case EventTypes.ActiveEvent: return new ActiveEventArgs( ev ); case EventTypes.KeyDown: return new KeyboardEventArgs( ev ); case EventTypes.KeyUp: return new KeyboardEventArgs( ev ); case EventTypes.MouseMotion: return new MouseMotionEventArgs( ev ); case EventTypes.MouseButtonDown: return new MouseButtonEventArgs( ev ); case EventTypes.MouseButtonUp: return new MouseButtonEventArgs( ev ); case EventTypes.JoystickAxisMotion: return new JoystickAxisEventArgs( ev ); case EventTypes.JoystickBallMotion: return new JoystickBallEventArgs( ev ); case EventTypes.JoystickHatMotion: return new JoystickHatEventArgs( ev ); case EventTypes.JoystickButtonDown: return new JoystickButtonEventArgs( ev ); case EventTypes.JoystickButtonUp: return new JoystickButtonEventArgs( ev ); case EventTypes.VideoResize: return new VideoResizeEventArgs( ev ); case EventTypes.VideoExpose: return new VideoExposeEventArgs( ev ); case EventTypes.Quit: return new QuitEventArgs( ev ); case EventTypes.WindowManagerEvent: return new WindowManagerEventArgs( ev ); case EventTypes.UserEvent: return new UserEventArgs( ev ); default: return new SdlEventArgs( ev ); } }
/// <summary> /// Creates the event arguments. /// </summary> /// <returns> /// The event arguments. /// </returns> /// <param name='e'> /// The ${ParameterType} instance containing the event data. /// </param> /// <exception cref='NotImplementedException'> /// Is thrown when a requested operation is not implemented for a given type. /// </exception> public static new VideoExposeEventArgs CreateEventArgs(SdlSystem.SDL_Event e) { return new VideoExposeEventArgs( e ); }
/// <summary> /// Creates the event arguments. /// </summary> /// <returns> /// The event arguments. /// </returns> /// <param name='e'> /// The ${ParameterType} instance containing the event data. /// </param> /// <exception cref='NotImplementedException'> /// Is thrown when a requested operation is not implemented for a given type. /// </exception> public static new MouseButtonEventArgs CreateEventArgs(SdlSystem. SDL_Event e) { return new MouseButtonEventArgs( e ); }
public static void IgnoreEvent(EventTypes event_type) { SdlSystem.SDL_EventState((byte)event_type, SdlSystem.SDL_IGNORE); }
/// <summary> /// Initializes a new instance of the <see cref="Sdl.Core.QuitEventArgs"/> class. /// </summary> /// <param name='event_struct'>Event struct.</param> internal QuitEventArgs(SdlSystem.SDL_Event event_struct) : base(event_struct) { }
public static void EnableEvent(EventTypes event_type) { SdlSystem.SDL_EventState((byte)event_type, SdlSystem.SDL_ENABLE); }
/// <summary> /// Creates the event arguments. /// </summary> /// <returns> /// The event arguments. /// </returns> /// <param name='e'> /// The ${ParameterType} instance containing the event data. /// </param> /// <exception cref='NotImplementedException'> /// Is thrown when a requested operation is not implemented for a given type. /// </exception> public static new ActiveEventArgs CreateEventArgs(SdlSystem.SDL_Event e) { return new ActiveEventArgs( e ); }
public static bool IsEventEnabled(EventTypes event_type) { return(SdlSystem.SDL_EventState((byte)event_type, SdlSystem.SDL_QUERY) == SdlSystem.SDL_ENABLE); }
/// <summary> /// Creates the event arguments. /// </summary> /// <returns> /// The event arguments. /// </returns> /// <param name='e'> /// The ${ParameterType} instance containing the event data. /// </param> /// <exception cref='NotImplementedException'> /// Is thrown when a requested operation is not implemented for a given type. /// </exception> public static new JoystickBallEventArgs CreateEventArgs(SdlSystem.SDL_Event e) { return new JoystickBallEventArgs( e ); }
/// <summary> /// Initializes a new instance of the <see cref="Sdl.Graphics.VideoResizeEventArgs"/> class. /// </summary> /// <param name='ev'> /// Ev. /// </param> internal VideoResizeEventArgs(SdlSystem.SDL_Event ev) : base( ev ) { }