Пример #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);
        }
Пример #2
0
        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 */
            }
        }
Пример #3
0
        public static void PushAllEvent(SdlEventArgs[] sdl_events) {
            if ( null == sdl_events )
                throw new ArgumentNullException( "sdl_events" );

            foreach ( SdlEventArgs sdl_event in sdl_events ) {
                PushEvent( sdl_event );
            }
        }
Пример #4
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;
        }
Пример #5
0
        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 */
            }
        }