Skip to content
This repository
Browse code

Got Event working. Events at 25%. Poll_event and Push_event done

  • Loading branch information...
commit 263e588c28792db6eafa23c5cb1c477fc45c06f3 1 parent ba74511
Kartik Thakore kthakore authored
2  src/Core/Events.xs
@@ -46,7 +46,7 @@ events_poll_event( event )
46 46 SDL_Event *event
47 47 CODE:
48 48 RETVAL = -1;
49   - if ( &event != NULL )
  49 + if ( event != NULL )
50 50 RETVAL = SDL_PollEvent(event);
51 51 OUTPUT:
52 52 RETVAL
26 src/Core/objects/Event.xs
@@ -38,8 +38,7 @@ SDL_Event *
38 38 event_new (CLASS)
39 39 char *CLASS
40 40 CODE:
41   - SDL_Event *empty_event;
42   - RETVAL = empty_event;
  41 + RETVAL = (SDL_Event *) safemalloc(sizeof (SDL_Event));
43 42 OUTPUT:
44 43 RETVAL
45 44
@@ -103,7 +102,7 @@ event_button ( event, ... )
103 102
104 103 SDL_JoyAxisEvent *
105 104 event_jaxis ( event, ... )
106   - SDL_Event *event
  105 + SDL_Event * event
107 106 PREINIT:
108 107 char *CLASS = "SDL::JoyAxisEvent";
109 108 CODE:
@@ -115,7 +114,7 @@ event_jaxis ( event, ... )
115 114
116 115 SDL_JoyBallEvent *
117 116 event_jball ( event, ... )
118   - SDL_Event *event
  117 + SDL_Event * event
119 118 PREINIT:
120 119 char *CLASS = "SDL::JoyBallEvent";
121 120 CODE:
@@ -127,7 +126,7 @@ event_jball ( event, ... )
127 126
128 127 SDL_JoyHatEvent *
129 128 event_jhat ( event, ... )
130   - SDL_Event *event
  129 + SDL_Event * event
131 130 PREINIT:
132 131 char *CLASS = "SDL::JoyHatEvent";
133 132 CODE:
@@ -139,7 +138,7 @@ event_jhat ( event, ... )
139 138
140 139 SDL_JoyButtonEvent *
141 140 event_jbutton ( event, ... )
142   - SDL_Event *event
  141 + SDL_Event * event
143 142 PREINIT:
144 143 char *CLASS = "SDL::JoyButtonEvent";
145 144 CODE:
@@ -151,7 +150,7 @@ event_jbutton ( event, ... )
151 150
152 151 SDL_ResizeEvent *
153 152 event_resize ( event, ... )
154   - SDL_Event *event
  153 + SDL_Event * event
155 154 PREINIT:
156 155 char *CLASS = "SDL::ResizeEvent";
157 156 CODE:
@@ -163,7 +162,7 @@ event_resize ( event, ... )
163 162
164 163 SDL_ExposeEvent *
165 164 event_expose ( event, ... )
166   - SDL_Event *event
  165 + SDL_Event * event
167 166 PREINIT:
168 167 char *CLASS = "SDL::ExposeEvent";
169 168 CODE:
@@ -175,7 +174,7 @@ event_expose ( event, ... )
175 174
176 175 SDL_QuitEvent *
177 176 event_quit ( event, ... )
178   - SDL_Event *event
  177 + SDL_Event * event
179 178 PREINIT:
180 179 char *CLASS = "SDL::QuitEvent";
181 180 CODE:
@@ -187,7 +186,7 @@ event_quit ( event, ... )
187 186
188 187 SDL_UserEvent *
189 188 event_user ( event, ... )
190   - SDL_Event *event
  189 + SDL_Event * event
191 190 PREINIT:
192 191 char *CLASS = "SDL::UserEvent";
193 192 CODE:
@@ -199,7 +198,7 @@ event_user ( event, ... )
199 198
200 199 SDL_SysWMEvent *
201 200 event_syswm ( event, ... )
202   - SDL_Event *event
  201 + SDL_Event * event
203 202 PREINIT:
204 203 char *CLASS = "SDL::SysWMEvent";
205 204 CODE:
@@ -209,3 +208,8 @@ event_syswm ( event, ... )
209 208 OUTPUT:
210 209 RETVAL
211 210
  211 +void
  212 +event_DESTROY(self)
  213 + SDL_Event *self
  214 + CODE:
  215 + safefree( (char *)self );
205 src/SDL.xs
@@ -646,211 +646,6 @@ CDTrack ( cd, number )
646 646 OUTPUT:
647 647 RETVAL
648 648
649   -void
650   -PumpEvents ()
651   - CODE:
652   - SDL_PumpEvents();
653   -
654   -int
655   -PushEvent( e )
656   - SDL_Event *e
657   - CODE:
658   - RETVAL = SDL_PushEvent( e );
659   - OUTPUT:
660   - RETVAL
661   -
662   -SDL_Event *
663   -NewEvent ()
664   - CODE:
665   - RETVAL = (SDL_Event *) safemalloc (sizeof(SDL_Event));
666   - OUTPUT:
667   - RETVAL
668   -
669   -void
670   -FreeEvent ( e )
671   - SDL_Event *e
672   - CODE:
673   - safefree(e);
674   -
675   -int
676   -PollEvent ( e )
677   - SDL_Event *e
678   - CODE:
679   - RETVAL = SDL_PollEvent(e);
680   - OUTPUT:
681   - RETVAL
682   -
683   -int
684   -WaitEvent ( e )
685   - SDL_Event *e
686   - CODE:
687   - RETVAL = SDL_WaitEvent(e);
688   - OUTPUT:
689   - RETVAL
690   -
691   -Uint8
692   -EventState ( type, state )
693   - Uint8 type
694   - int state
695   - CODE:
696   - RETVAL = SDL_EventState(type,state);
697   - OUTPUT:
698   - RETVAL
699   -
700   -Uint8
701   -EventType ( e )
702   - SDL_Event *e
703   - CODE:
704   - RETVAL = e->type;
705   - OUTPUT:
706   - RETVAL
707   -
708   -Uint8
709   -SetEventType ( e, type )
710   - SDL_Event *e
711   - Uint8 type
712   - CODE:
713   - RETVAL = e->type;
714   - e->type = type;
715   - OUTPUT:
716   - RETVAL
717   -
718   -Uint8
719   -ActiveEventGain ( e )
720   - SDL_Event *e
721   - CODE:
722   - RETVAL = e->active.gain;
723   - OUTPUT:
724   - RETVAL
725   -
726   -Uint8
727   -ActiveEventState ( e )
728   - SDL_Event *e
729   - CODE:
730   - RETVAL = e->active.state;
731   - OUTPUT:
732   - RETVAL
733   -
734   -Uint8
735   -KeyEventState( e )
736   - SDL_Event *e
737   - CODE:
738   - RETVAL = e->key.state;
739   - OUTPUT:
740   - RETVAL
741   -
742   -int
743   -KeyEventSym ( e )
744   - SDL_Event *e
745   - CODE:
746   - RETVAL = e->key.keysym.sym;
747   - OUTPUT:
748   - RETVAL
749   -
750   -int
751   -KeyEventMod ( e )
752   - SDL_Event *e
753   - CODE:
754   - RETVAL = e->key.keysym.mod;
755   - OUTPUT:
756   - RETVAL
757   -
758   -Uint16
759   -KeyEventUnicode ( e )
760   - SDL_Event *e
761   - CODE:
762   - RETVAL = e->key.keysym.unicode;
763   - OUTPUT:
764   - RETVAL
765   -
766   -Uint8
767   -key_scancode ( e )
768   - SDL_Event *e
769   - CODE:
770   - RETVAL = e->key.keysym.scancode;
771   - OUTPUT:
772   - RETVAL
773   -
774   -Uint8
775   -MouseMotionState ( e )
776   - SDL_Event *e
777   - CODE:
778   - RETVAL = e->motion.state;
779   - OUTPUT:
780   - RETVAL
781   -
782   -Uint16
783   -MouseMotionX ( e )
784   - SDL_Event *e
785   - CODE:
786   - RETVAL = e->motion.x;
787   - OUTPUT:
788   - RETVAL
789   -
790   -Uint16
791   -MouseMotionY ( e )
792   - SDL_Event *e
793   - CODE:
794   - RETVAL = e->motion.y;
795   - OUTPUT:
796   - RETVAL
797   -
798   -Sint16
799   -MouseMotionXrel( e )
800   - SDL_Event *e
801   - CODE:
802   - RETVAL = e->motion.xrel;
803   - OUTPUT:
804   - RETVAL
805   -
806   -Sint16
807   -MouseMotionYrel ( e )
808   - SDL_Event *e
809   - CODE:
810   - RETVAL = e->motion.yrel;
811   - OUTPUT:
812   - RETVAL
813   -
814   -Uint8
815   -button_state ( e )
816   - SDL_Event *e
817   - CODE:
818   - RETVAL = e->button.state;
819   - OUTPUT:
820   - RETVAL
821   -
822   -Uint8
823   -button ( e )
824   - SDL_Event *e
825   - CODE:
826   - RETVAL = e->button.button;
827   - OUTPUT:
828   - RETVAL
829   -
830   -Uint16
831   -button_x ( e )
832   - SDL_Event *e
833   - CODE:
834   - RETVAL = e->button.x;
835   - OUTPUT:
836   - RETVAL
837   -
838   -Uint16
839   -button_y ( e )
840   - SDL_Event *e
841   - CODE:
842   - RETVAL = e->button.y;
843   - OUTPUT:
844   - RETVAL
845   -
846   -SDL_SysWMmsg *
847   -SysWMEventMsg ( e )
848   - SDL_Event *e
849   - CODE:
850   - RETVAL = e->syswm.msg;
851   - OUTPUT:
852   - RETVAL
853   -
854 649 int
855 650 EnableUnicode ( enable )
856 651 int enable
19 t/core_events.t
@@ -17,13 +17,16 @@ use SDL::ResizeEvent;
17 17 use SDL::SysWMEvent;
18 18 use SDL::UserEvent;
19 19 use SDL::Video;
  20 +use Devel::Peek;
20 21 use Test::More;
21 22
22   -plan ( tests => 66 );
  23 +plan ( tests => 69 );
23 24
24 25 my @done =qw/
25 26 pump_events
26 27 peep_events
  28 +push_event
  29 +poll_event
27 30 /;
28 31
29 32 my @done_event =qw/
@@ -98,7 +101,7 @@ my $wrevent = SDL::ResizeEvent->new();
98 101 my $wmevent = SDL::SysWMEvent->new();
99 102 my $uevent = SDL::UserEvent->new();
100 103
101   -#isa_ok( $event, 'SDL::Event', '[SDL::Event::new] is creating an Event');
  104 +isa_ok( $event, 'SDL::Event', '[SDL::Event::new] is creating an Event');
102 105 isa_ok( $aevent, 'SDL::ActiveEvent', '[SDL::ActiveEvent::new] is creating an ActiveEvent');
103 106 isa_ok( $weevent, 'SDL::ExposeEvent', '[SDL::ExposeEvent::new] is creating an ExposeEvent');
104 107 isa_ok( $jaevent, 'SDL::JoyAxisEvent', '[SDL::JoyAxisEvent::new] is creating an JoyAxisEvent');
@@ -130,11 +133,19 @@ is($wrevent->type, SDL_VIDEORESIZE, '[SDL::ResizeEvent->type] returns correctly'
130 133 is($wmevent->type, SDL_SYSWMEVENT, '[SDL::SysWMEvent->type] returns correctly');
131 134 is($uevent->type, SDL_USEREVENT, '[SDL::UserEvent->type] returns correctly');
132 135
  136 +my $num_peep_events = SDL::Events::peep_events($event, 127, SDL_PEEKEVENT, SDL_ALLEVENTS);
  137 +is($num_peep_events >= 0, 1, '[peep_events] Size of event queue is ' . $num_peep_events);
  138 +
  139 +
  140 +SDL::Events::push_event($aevent); pass '[push_event] ran';
  141 +
  142 +SDL::Events::poll_event($event);
  143 +
  144 +is( $event->type, $aevent->type, '[poll_event] Got the right event back out') ;
  145 +
133 146 $uevent->code(200);
134 147 is( $uevent->code, 200, '[SDL::UserEvent->code] is set correctly');
135 148
136   -my $num_peep_events = SDL::Events::peep_events($event, 127, SDL_PEEKEVENT, SDL_ALLEVENTS);
137   -is($num_peep_events >= 0, 1, '[peep_events] Size of event queue is ' . $num_peep_events);
138 149
139 150 TODO:
140 151 {
2  typemap
@@ -16,7 +16,7 @@ Sint16 T_IV
16 16 Sint16 * T_PTR
17 17 Sint32 T_IV
18 18 Sint32 * T_PTR
19   -SDL_Event * T_PTR
  19 +SDL_Event * O_OBJECT
20 20 SDL_ActiveEvent * O_OBJECT
21 21 SDL_KeyboardEvent * O_OBJECT
22 22 SDL_TextInputEvent * O_OBJECT

0 comments on commit 263e588

Please sign in to comment.
Something went wrong with that request. Please try again.