From: Kartik Thakore Date: Sun, 2 Aug 2009 20:14:12 +0000 (-0400) Subject: added SDL_PeepEvents support X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8ead669ea4af47d3c68a463f6974c63696ef1ca2;p=sdlgit%2FSDL_perl.git added SDL_PeepEvents support --- diff --git a/lib/SDL/Event.pm b/lib/SDL/Event.pm index bbdb5e8..dd21aff 100644 --- a/lib/SDL/Event.pm +++ b/lib/SDL/Event.pm @@ -42,6 +42,12 @@ sub poll { return SDL::PollEvent($$self); } +sub peep($$$$) +{ + my ($event, $numEvents, $action, $mask) = @_; + return SDL::PeepEvents($$event, $numEvents, $action, $mask); +} + sub push { my $self = shift; return SDL::PushEvent($$self); @@ -228,6 +234,19 @@ Pumps the event loop, gathering events from the input devices. Polls for currently pending events +=head2 peep() + +Checks the event queue for messages and optionally returns them. + +If action is SDL_ADDEVENT, up to numevents events will be added to the back of the event queue. + +If action is SDL_PEEKEVENT, up to numevents events at the front of the event queue, matching mask, will be returned and will not be removed from the queue. + +If action is SDL_GETEVENT, up to numevents events at the front of the event queue, matching mask, will be returned and will be removed from the queue. + +The mask parameter is a bitwise OR of SDL_EVENTMASK(event_type), for all event types you are interested in + + =head2 wait() Waits for an event end returns then. Always returns true. diff --git a/src/SDL.xs b/src/SDL.xs index 9db342c..b880c5c 100644 --- a/src/SDL.xs +++ b/src/SDL.xs @@ -3,7 +3,7 @@ // SDL Perl by David J. Goehrig // // Copyright (C) 2000,2001,2002,2003,2004 David J. Goehrig -// +// Copyright (C) 2009 Kartik Thakore // This software is under the GNU Library General Public License (LGPL) // see the file COPYING for terms of use @@ -527,6 +527,19 @@ FreeEvent ( e ) CODE: safefree(e); + +int +PeepEvents( e, numevents, action, mask) + SDL_Event *e + int numevents + SDL_eventaction action + Uint32 mask + CODE: + RETVAL = SDL_PeepEvents( e, numevents, action, mask); + OUTPUT: + RETVAL + + int PollEvent ( e ) SDL_Event *e diff --git a/t/eventpm.t b/t/eventpm.t index 97822b4..3a1da0f 100644 --- a/t/eventpm.t +++ b/t/eventpm.t @@ -22,6 +22,7 @@ can_ok ('SDL::Event', qw/ type pump poll + peep wait set set_unicode @@ -42,7 +43,8 @@ can_ok ('SDL::Event', qw/ button button_state button_x - button_y /); + button_y + /); diff --git a/typemap b/typemap index 18d0bd5..0eb347c 100644 --- a/typemap +++ b/typemap @@ -13,6 +13,7 @@ Sint16 * T_PTR Sint32 T_IV Sint32 * T_PTR SDL_Event * T_PTR +SDL_eventaction T_PTR SDL_Surface * T_PTR SDL_SysWMmsg * T_PTR SDL_CD * T_PTR