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