Permalink
Browse files

Implemented get_key_state

  • Loading branch information...
1 parent 4a4c0cb commit 0b79e0ec53890f25bc403e246bbdd86d51119b39 @kthakore kthakore committed Nov 12, 2009
Showing with 31 additions and 5 deletions.
  1. +27 −2 src/Core/Events.xs
  2. +3 −3 t/core_events.t
  3. +1 −0 typemap
View
@@ -9,6 +9,7 @@
#include <SDL.h>
#include <SDL_events.h>
+
/* Static Memory for event filter call back */
static SV * eventfiltersv;
@@ -110,5 +111,29 @@ void
events_set_event_filter(callback)
SV* callback
CODE:
- eventfiltersv = callback;
- SDL_SetEventFilter( (SDL_EventFilter*)eventfilter_cb);
+ eventfiltersv = callback;
+ SDL_SetEventFilter( (SDL_EventFilter*)eventfilter_cb);
+
+
+AV *
+events_get_key_state()
+ PREINIT:
+ int value;
+ CODE:
+
+ Uint8* KeyArray = SDL_GetKeyState(&value);
+ RETVAL = newAV();
+ int i;
+ for( i = 0; i <value; i++)
+ {
+ SV* scalar = newSViv( KeyArray[i] );
+ av_push( RETVAL, scalar);
+
+ }
+ sv_2mortal(RETVAL);
+
+ OUTPUT:
+ RETVAL
+
+
+
View
@@ -15,7 +15,7 @@ push_event
poll_event
wait_event
set_event_filter
-
+get_key_state
/;
my @done_event =qw/
@@ -107,7 +107,8 @@ is($num_peep_events >= 0, 1, '[peep_events] Size of event queue is ' . $num_pee
my $callback = sub { print shift->type; return 1; };
SDL::Events::set_event_filter( $callback );
pass '[set_event_filter] takes a callback';
-
+my $array = SDL::Events::get_key_state();
+isa_ok( $array, 'ARRAY', '[get_key_state] returned and array');
SDL::quit();
SKIP:
@@ -143,7 +144,6 @@ pass 'Ok now set_event_filter works';
my @left = qw/
eventstate
-getkeystate
getmodstate
setmodstate
getkeyname
View
@@ -91,6 +91,7 @@ Sound_AudioInfo * T_PTR
SDL_RWops* T_PTR
SDL_svg_context* T_PTR
int T_IV
+intArray T_ARRAY
OUTPUT

0 comments on commit 0b79e0e

Please sign in to comment.