I don't know how you guys like to receive patches (I've gotten yelled
for submitting, to other projects, unified diffs rather than context
diffs or vise versa :)), but here's a patch that adds two new functions
to Event.pm, along with the xs code to implement them.
The two new functions are related.
The Event::settype function sets the type of an event. You pass in one
of the event type constants (SDLK_, KMOD_, etc).
The Event::push function pushes an event into the event queue, to be
picked up by ::wait and ::poll, and friends.
All the xs code does is call the corresponding SDL functions. No magic
there. :)
I also took the liberty of changing the pod for Event::set, which is
related to event filtering, and may cause confusion with this patch
applied (although I think the original docs were just plain wrong and
confusing anyway). It now matches (and references) the SDL docs.
You'll want to apply it with patch -p1 while in the SDL-Perl-version
directory, of course. I notice there might be a few line wrap issues on
the section header lines in this pasted in patch. I can resend as an
attachment if necessary.
It would be great if this was rolled in the offical tree.
Andy Bakun
----------------------------------------------------
diff -Naur SDL_Perl-2.1.0.orig/lib/SDL/Event.pm
SDL_Perl-2.1.0/lib/SDL/Event.pm
--- SDL_Perl-2.1.0.orig/lib/SDL/Event.pm 2004-02-23 19:55:43 -0600
+++ SDL_Perl-2.1.0/lib/SDL/Event.pm 2004-03-25 01:51:19 -0600
@@ -30,10 +30,21 @@
return SDL::EventType($$self);
}
+sub settype {
+ my $self = shift;
+ my $type = shift;
+ return SDL::SetEventType($$self, $type);
+}
+
sub pump {
SDL::PumpEvents();
}
+sub push {
+ my $self = shift;
+ return SDL::PushEvent($$self);
+}
+
sub poll {
my $self = shift;
return SDL::PollEvent($$self);
@@ -215,15 +226,22 @@
=head2 pump()
+=head2 push()
+
=head2 poll()
=head2 wait()
Waits for an event end returns then. Always returns true.
+=head2 settype(type)
+
+Sets the type of the event. Commonly used with push()
+
=head2 set( type, state )
-Set type and state of the event.
+Allows you to set the state of processing certain events.
+See SDL_EventState in the SDL library documentation.
=head2 set_unicode( toggle )
diff -Naur SDL_Perl-2.1.0.orig/lib/SDL.pm SDL_Perl-2.1.0/lib/SDL.pm
--- SDL_Perl-2.1.0.orig/lib/SDL.pm 2004-02-23 19:55:43 -0600
+++ SDL_Perl-2.1.0/lib/SDL.pm 2004-03-25 01:48:18 -0600
@@ -249,6 +249,10 @@
=head2 PollEvent
+=head2 PushEvent
+
+=head2 SetEventType
+
=head2 WaitEvent
=head2 EventState
diff -Naur SDL_Perl-2.1.0.orig/src/SDL.xs SDL_Perl-2.1.0/src/SDL.xs
--- SDL_Perl-2.1.0.orig/src/SDL.xs 2004-02-23 19:55:43 -0600
+++ SDL_Perl-2.1.0/src/SDL.xs 2004-03-25 01:41:23 -0600
@@ -480,6 +480,14 @@
CODE:
SDL_PumpEvents();
+int
+PushEvent( e )
+ SDL_Event *e
+ CODE:
+ RETVAL = SDL_PushEvent(e);
+ OUTPUT:
+ RETVAL
+
SDL_Event *
NewEvent ()
CODE:
@@ -527,6 +535,16 @@
RETVAL
Uint8
+SetEventType ( e, type )
+ SDL_Event *e
+ Uint8 type
+ CODE:
+ RETVAL = e->type;
+ e->type = type;
+ OUTPUT:
+ RETVAL
+
+Uint8
ActiveEventGain ( e )
SDL_Event *e
CODE: