From: Tobias Leich Date: Wed, 4 Nov 2009 16:46:07 +0000 (+0100) Subject: added pump_events(), peep_events() and poll_event() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=77bc9f7a29f2af20c5d158a805d43b924f00b5f1;p=sdlgit%2FSDL_perl.git added pump_events(), peep_events() and poll_event() --- diff --git a/lib/SDL/Constants.pm b/lib/SDL/Constants.pm index 5f27342..1120260 100644 --- a/lib/SDL/Constants.pm +++ b/lib/SDL/Constants.pm @@ -202,7 +202,9 @@ our @EXPORT=qw( SDLK_y SDLK_z SDL_ACTIVEEVENT + SDL_ALLEVENTS SDL_ANYFORMAT + SDL_ADDEVENT SDL_APPACTIVE SDL_APPINPUTFOCUS SDL_APPMOUSEFOCUS @@ -218,6 +220,7 @@ our @EXPORT=qw( SDL_DOUBLEBUF SDL_ENABLE SDL_FULLSCREEN + SDL_GETEVENT SDL_GL_ACCUM_ALPHA_SIZE SDL_GL_ACCUM_BLUE_SIZE SDL_GL_ACCUM_GREEN_SIZE @@ -267,6 +270,7 @@ our @EXPORT=qw( SDL_MOUSEMOTION SDL_OPENGL SDL_OPENGLBLIT + SDL_PEEKEVENT SDL_PREALLOC SDL_PRESSED SDL_QUERY @@ -484,12 +488,14 @@ use constant { SDLK_y => 121, SDLK_z => 122, - SDL_ACTIVEEVENT => 1, - SDL_ANYFORMAT => 268435456, - SDL_APPACTIVE => 4, - SDL_APPINPUTFOCUS => 2, - SDL_APPMOUSEFOCUS => 1, - SDL_ASYNCBLIT => 4, + SDL_ACTIVEEVENT => 1, + SDL_ADDEVENT => 0, + SDL_ALLEVENTS => 0xFFFFFFFF, + SDL_ANYFORMAT => 268435456, + SDL_APPACTIVE => 4, + SDL_APPINPUTFOCUS => 2, + SDL_APPMOUSEFOCUS => 1, + SDL_ASYNCBLIT => 4, SDL_AUDIO_PAUSED => 2, SDL_AUDIO_PLAYING => 1, @@ -505,6 +511,7 @@ use constant { SDL_ENABLE => 1, SDL_FULLSCREEN => -2147483648, + SDL_GETEVENT => 2, SDL_GL_ACCUM_ALPHA_SIZE => 11, SDL_GL_ACCUM_BLUE_SIZE => 10, SDL_GL_ACCUM_GREEN_SIZE => 9, @@ -566,21 +573,28 @@ use constant { SDL_OPENGL => 2, SDL_OPENGLBLIT => 10, + SDL_PEEKEVENT => 1, SDL_PREALLOC => 16777216, SDL_PRESSED => 1, + SDL_QUERY => -1, SDL_QUIT => 12, + SDL_RELEASED => 0, SDL_RESIZABLE => 16, SDL_RLEACCEL => 16384, SDL_RLEACCELOK => 8192, + SDL_SRCALPHA => 65536, SDL_SRCCOLORKEY => 4096, SDL_SWSURFACE => 0, SDL_SYSWMEVENT => 13, + SDL_UYVY_OVERLAY => 1498831189, + SDL_VIDEOEXPOSE => 17, SDL_VIDEORESIZE => 16, + SDL_YUY2_OVERLAY => 844715353, SDL_YV12_OVERLAY => 842094169, SDL_YVYU_OVERLAY => 1431918169, diff --git a/src/Core/Events.xs b/src/Core/Events.xs index 0506af5..8a5d6b3 100644 --- a/src/Core/Events.xs +++ b/src/Core/Events.xs @@ -7,6 +7,47 @@ #endif #include +#include MODULE = SDL::Events PACKAGE = SDL::Events PREFIX = events_ +=for documentation + +The Following are XS bindings to the Event category in the SDL API v2.1.13 + +Describe on the SDL API site. + +See: L + +=cut + +void +events_pump_events() + CODE: + SDL_PumpEvents(); + +int +events_peep_events( events, numevents, action, mask ) + SDL_Event *events + int numevents + int action + Uint32 mask + CODE: + //if(action & (SDL_ADDEVENT | SDL_PEEKEVENT | SDL_GETEVENT)) + //{ + RETVAL = SDL_PeepEvents(events,numevents,action,mask); + /*} + else + { + RETVAL = -1; + }*/ + OUTPUT: + RETVAL + +int +events_poll_event( event ) + SDL_Event *event + CODE: + RETVAL = SDL_PollEvent(event); + OUTPUT: + RETVAL diff --git a/t/constantspm.t b/t/constantspm.t index b6c14ad..f460ff4 100644 --- a/t/constantspm.t +++ b/t/constantspm.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 1 + 544; # use_ok + constants +use Test::More tests => 1 + 552; # use_ok + constants BEGIN { use_ok('SDL::Constants') } @@ -343,6 +343,10 @@ is( SDLK_z(), 122, 'SDLK_z() should also be available' ); is( SDL_ACTIVEEVENT, 1, 'SDL_ACTIVEEVENT should be imported' ); is( SDL_ACTIVEEVENT(), 1, 'SDL_ACTIVEEVENT() should also be available' ); +is( SDL_ADDEVENT, 0, 'SDL_ADDEVENT should be imported' ); +is( SDL_ADDEVENT(), 0, 'SDL_ADDEVENT() should also be available' ); +is( SDL_ALLEVENTS, 0xFFFFFFFF, 'SDL_ALLEVENTS should be imported' ); +is( SDL_ALLEVENTS(), 0xFFFFFFFF, 'SDL_ALLEVENTS() should also be available' ); is( SDL_ANYFORMAT, 268435456, 'SDL_ANYFORMAT should be imported' ); is( SDL_ANYFORMAT(), 268435456, 'SDL_ANYFORMAT() should also be available' ); is( SDL_APPACTIVE, 4, 'SDL_APPACTIVE should be imported' ); @@ -379,6 +383,9 @@ is( SDL_ENABLE(), 1, 'SDL_ENABLE() should also be available' ); is( SDL_FULLSCREEN, -2147483648, 'SDL_FULLSCREEN should be imported' ); is( SDL_FULLSCREEN(), -2147483648, 'SDL_FULLSCREEN() should also be available' ); +is( SDL_GETEVENT, 2, 'SDL_GETEVENT should be imported' ); +is( SDL_GETEVENT(), 2, 'SDL_GETEVENT() should also be available' ); + is( SDL_GL_ACCUM_ALPHA_SIZE, 11, 'SDL_GL_ACCUM_ALPHA_SIZE should be imported' ); is( SDL_GL_ACCUM_ALPHA_SIZE(), 11, 'SDL_GL_ACCUM_ALPHA_SIZE() should also be available' ); is( SDL_GL_ACCUM_BLUE_SIZE, 10, 'SDL_GL_ACCUM_BLUE_SIZE should be imported' ); @@ -489,14 +496,18 @@ is( SDL_OPENGL(), 2, 'SDL_OPENGL() should also be available' ); is( SDL_OPENGLBLIT, 10, 'SDL_OPENGLBLIT should be imported' ); is( SDL_OPENGLBLIT(), 10, 'SDL_OPENGLBLIT() should also be available' ); +is( SDL_PEEKEVENT, 1, 'SDL_PEEKEVENT should be imported' ); +is( SDL_PEEKEVENT(), 1, 'SDL_PEEKEVENT() should also be available' ); is( SDL_PREALLOC, 16777216, 'SDL_PREALLOC should be imported' ); is( SDL_PREALLOC(), 16777216, 'SDL_PREALLOC() should also be available' ); is( SDL_PRESSED, 1, 'SDL_PRESSED should be imported' ); is( SDL_PRESSED(), 1, 'SDL_PRESSED() should also be available' ); + is( SDL_QUERY, -1, 'SDL_QUERY should be imported' ); is( SDL_QUERY(), -1, 'SDL_QUERY() should also be available' ); is( SDL_QUIT, 12, 'SDL_QUIT should be imported' ); is( SDL_QUIT(), 12, 'SDL_QUIT() should also be available' ); + is( SDL_RELEASED, 0, 'SDL_RELEASED should be imported' ); is( SDL_RELEASED(), 0, 'SDL_RELEASED() should also be available' ); is( SDL_RESIZABLE, 16, 'SDL_RESIZABLE should be imported' ); @@ -505,6 +516,7 @@ is( SDL_RLEACCEL, 16384, 'SDL_RLEACCEL should be imported' ); is( SDL_RLEACCEL(), 16384, 'SDL_RLEACCEL() should also be available' ); is( SDL_RLEACCELOK, 8192, 'SDL_RLEACCELOK should be imported' ); is( SDL_RLEACCELOK(), 8192, 'SDL_RLEACCELOK() should also be available' ); + is( SDL_SRCALPHA, 65536, 'SDL_SRCALPHA should be imported' ); is( SDL_SRCALPHA(), 65536, 'SDL_SRCALPHA() should also be available' ); is( SDL_SRCCOLORKEY, 4096, 'SDL_SRCCOLORKEY should be imported' ); @@ -513,12 +525,15 @@ is( SDL_SWSURFACE, 0, 'SDL_SWSURFACE should be imported' ); is( SDL_SWSURFACE(), 0, 'SDL_SWSURFACE() should also be available' ); is( SDL_SYSWMEVENT, 13, 'SDL_SYSWMEVENT should be imported' ); is( SDL_SYSWMEVENT(), 13, 'SDL_SYSWMEVENT() should also be available' ); + is( SDL_UYVY_OVERLAY, 1498831189, 'SDL_UYVY_OVERLAY should be imported' ); is( SDL_UYVY_OVERLAY(), 1498831189,'SDL_UYVY_OVERLAY() should also be available' ); + is( SDL_VIDEOEXPOSE, 17, 'SDL_VIDEOEXPOSE should be imported' ); is( SDL_VIDEOEXPOSE(), 17, 'SDL_VIDEOEXPOSE() should also be available' ); is( SDL_VIDEORESIZE, 16, 'SDL_VIDEORESIZE should be imported' ); is( SDL_VIDEORESIZE(), 16, 'SDL_VIDEORESIZE() should also be available' ); + is( SDL_YUY2_OVERLAY, 844715353, 'SDL_YUY2_OVERLAY should be imported' ); is( SDL_YUY2_OVERLAY(), 844715353,'SDL_YUY2_OVERLAY() should also be available' ); is( SDL_YV12_OVERLAY, 842094169, 'SDL_YV12_OVERLAY should be imported' ); diff --git a/t/core_events.t b/t/core_events.t index d189e22..5648691 100644 --- a/t/core_events.t +++ b/t/core_events.t @@ -1,24 +1,36 @@ #!/usr/bin/perl -w use strict; use SDL; +use SDL::Event; +#use SDL::Surface; +#use SDL::Video; use Test::More; -plan ( tests => 4 ); +plan ( tests => 7 ); -my @done =qw/ none /; +my @done =qw/ +pump_events +peep_events +poll_event +/; -SKIP: -{ -skip 'Not implemented', 2; use_ok( 'SDL::Events' ); can_ok ('SDL::Events', @done); -} + +SDL::init(SDL_INIT_VIDEO); + +is(SDL::Events::pump_events(), undef, '[pump_events] Returns undef'); + +my $events = SDL::Event->new(); +my $num_peep_events = SDL::Events::peep_events( $events, 127, SDL_PEEKEVENT, SDL_ALLEVENTS); +is($num_peep_events >= 0, 1, '[peep_events] Size of event queue is ' . $num_peep_events); + +my $event = SDL::Event->new(); +my $value = SDL::Events::poll_event($event); +is(($value == 1) || ($value == 0), 1, '[poll_event] Returns 1 or 0'); my @left = qw/ -pumpevents -peepevents -pollevent waitevent pushevent seteventfilter diff --git a/t/manifest.t b/t/manifest.t index b4cde68..e0a1559 100644 --- a/t/manifest.t +++ b/t/manifest.t @@ -1,33 +1,33 @@ -#!/usr/bin/perl - -# Test that our MANIFEST describes the distribution - -use strict; - -BEGIN { - use English qw(-no_match_vars); - $OUTPUT_AUTOFLUSH = 1; - $WARNING = 1; -} - -my @MODULES = ( - 'Test::DistManifest 1.001003', -); - -# Don't run tests for installs -use Test::More; -unless ( $ENV{AUTOMATED_TESTING} or $ENV{RELEASE_TESTING} ) { - plan( skip_all => "Author tests not required for installation" ); -} - -# Load the testing modules -foreach my $MODULE ( @MODULES ) { - eval "use $MODULE"; - if ( $EVAL_ERROR ) { - $ENV{RELEASE_TESTING} - ? BAIL_OUT( "Failed to load required release-testing module $MODULE" ) - : plan( skip_all => "$MODULE not available for testing" ); - } -} - -manifest_ok(); +#!/usr/bin/perl + +# Test that our MANIFEST describes the distribution + +use strict; + +BEGIN { + use English qw(-no_match_vars); + $OUTPUT_AUTOFLUSH = 1; + $WARNING = 1; +} + +my @MODULES = ( + 'Test::DistManifest 1.001003', +); + +# Don't run tests for installs +use Test::More; +unless ( $ENV{AUTOMATED_TESTING} or $ENV{RELEASE_TESTING} ) { + plan( skip_all => "Author tests not required for installation" ); +} + +# Load the testing modules +foreach my $MODULE ( @MODULES ) { + eval "use $MODULE"; + if ( $EVAL_ERROR ) { + $ENV{RELEASE_TESTING} + ? BAIL_OUT( "Failed to load required release-testing module $MODULE" ) + : plan( skip_all => "$MODULE not available for testing" ); + } +} + +manifest_ok();