Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public static void Wait()
        {
            SdlSystem.SDL_Event e;

            if (SdlSystem.SDL_WaitEvent(out e) == (int)NativeFunctionReturnFlags.Error)
            {
                throw SdlException.Generate();
            }

            ProcessEvent(e);
        }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
 /// <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);
     }
 }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Sdl.Core.SdlException"/> class.
 /// </summary>
 public SdlException()
 {
     throw SdlException.Generate();
 }