added more event constants and their tests
Tobias Leich [Sun, 8 Nov 2009 16:30:09 +0000 (17:30 +0100)]
lib/SDL/Constants.pm
t/core_events.t

index 5e61223..f6146e0 100644 (file)
@@ -259,16 +259,29 @@ our @EXPORT=qw(
        SDL_INIT_VIDEO
        SDL_IYUV_OVERLAY
        SDL_JOYAXISMOTION
+       SDL_JOYAXISMOTIONMASK
        SDL_JOYBALLMOTION
+       SDL_JOYBALLMOTIONMASK
        SDL_JOYBUTTONDOWN
+       SDL_JOYBUTTONDOWNMASK
        SDL_JOYBUTTONUP
+       SDL_JOYBUTTONUPMASK
+       SDL_JOYEVENTMASK
        SDL_JOYHATMOTION
+       SDL_JOYHATMOTIONMASK
        SDL_KEYDOWN
+       SDL_KEYDOWNMASK
        SDL_KEYUP
+       SDL_KEYUPMASK
+       SDL_KEYEVENTMASK
        SDL_MIX_MAXVOLUME
        SDL_MOUSEBUTTONDOWN
+       SDL_MOUSEBUTTONDOWNMASK
        SDL_MOUSEBUTTONUP
+       SDL_MOUSEBUTTONUPMASK
+       SDL_MOUSEEVENTMASK
        SDL_MOUSEMOTION
+       SDL_MOUSEMOTIONMASK
        SDL_NOEVENT
        SDL_NUMEVENTS
        SDL_OPENGL
@@ -278,6 +291,7 @@ our @EXPORT=qw(
        SDL_PRESSED
        SDL_QUERY
        SDL_QUIT
+       SDL_QUITMASK
        SDL_RELEASED
        SDL_EVENT_RESERVEDA
        SDL_EVENT_RESERVEDB
@@ -294,10 +308,13 @@ our @EXPORT=qw(
        SDL_SRCCOLORKEY
        SDL_SWSURFACE
        SDL_SYSWMEVENT
+       SDL_SYSWMEVENTMASK
        SDL_USEREVENT
        SDL_UYVY_OVERLAY
        SDL_VIDEOEXPOSE
+       SDL_VIDEOEXPOSEMASK
        SDL_VIDEORESIZE
+       SDL_VIDEORESIZEMASK
        SDL_YUY2_OVERLAY
        SDL_YV12_OVERLAY
        SDL_YVYU_OVERLAY
@@ -579,19 +596,32 @@ use constant {
     SDL_IYUV_OVERLAY => 1448433993,
     
     SDL_JOYAXISMOTION       => 7,
+    SDL_JOYAXISMOTIONMASK   => 1 << 7,
     SDL_JOYBALLMOTION       => 8,
+    SDL_JOYBALLMOTIONMASK   => 1 << 8,
     SDL_JOYBUTTONDOWN       => 10,
+    SDL_JOYBUTTONDOWNMASK   => 1 << 10,
     SDL_JOYBUTTONUP         => 11,
+    SDL_JOYBUTTONUPMASK     => 1 << 11,
+       SDL_JOYEVENTMASK        => (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11),
     SDL_JOYHATMOTION        => 9,
+    SDL_JOYHATMOTIONMASK    => 1 << 9,
     
     SDL_KEYDOWN             => 2,
+    SDL_KEYDOWNMASK         => 1 << 2,
     SDL_KEYUP               => 3,
+    SDL_KEYUPMASK           => 1 << 3,
+       SDL_KEYEVENTMASK        => (1 << 2) | (1 << 3),
     
     SDL_MIX_MAXVOLUME => 128,
     
     SDL_MOUSEBUTTONDOWN     => 5,
+    SDL_MOUSEBUTTONDOWNMASK => 1 << 5,
     SDL_MOUSEBUTTONUP       => 6,
+    SDL_MOUSEBUTTONUPMASK   => 1 << 6,
     SDL_MOUSEMOTION         => 4,
+    SDL_MOUSEMOTIONMASK     => 1 << 4,
+       SDL_MOUSEEVENTMASK      => (1 << 4) | (1 << 5) | (1 << 6),
        
     SDL_NOEVENT             => 0,
        SDL_NUMEVENTS           => 32,
@@ -605,6 +635,7 @@ use constant {
        
     SDL_QUERY => -1,
     SDL_QUIT                => 12,
+    SDL_QUITMASK            => 1 << 12,
        
     SDL_RELEASED => 0,
     SDL_RESIZABLE => 16,
@@ -615,12 +646,15 @@ use constant {
     SDL_SRCCOLORKEY => 4096,
     SDL_SWSURFACE => 0,
     SDL_SYSWMEVENT          => 13,
+    SDL_SYSWMEVENTMASK      => 1 << 13,
        
        SDL_USEREVENT           => 24,
     SDL_UYVY_OVERLAY        => 1498831189,
        
     SDL_VIDEOEXPOSE         => 17,
+    SDL_VIDEOEXPOSEMASK     => 1 << 17,
     SDL_VIDEORESIZE         => 16,
+    SDL_VIDEORESIZEMASK     => 1 << 16,
        
     SDL_YUY2_OVERLAY => 844715353,
     SDL_YV12_OVERLAY => 842094169,
index e7d2553..f182d11 100644 (file)
@@ -19,7 +19,7 @@ use SDL::UserEvent;
 use SDL::Video;
 use Test::More;
 
-plan ( tests => 90 );
+plan ( tests => 108 );
 
 my @done =qw/
 pump_events 
@@ -139,8 +139,34 @@ is(SDL_USEREVENT,       24, 'Constant SDL_USEREVENT');
 is(SDL_NUMEVENTS,       32, 'Constant SDL_NUMEVENTS');
 
 # checking eventmasks
-is(SDL_ACTIVEEVENTMASK,  SDL_EVENTMASK(SDL_ACTIVEEVENT), 'Constant SDL_ACTIVEVENTMASK');
-
+is(SDL_ACTIVEEVENTMASK,     SDL_EVENTMASK(SDL_ACTIVEEVENT),     'Constant SDL_ACTIVEVENTMASK');
+is(SDL_KEYDOWNMASK,         SDL_EVENTMASK(SDL_KEYDOWN),         'Constant SDL_KEYDOWNMASK');
+is(SDL_KEYUPMASK,           SDL_EVENTMASK(SDL_KEYUP),           'Constant SDL_KEYUPMASK');
+is(SDL_KEYEVENTMASK,        SDL_EVENTMASK(SDL_KEYDOWN)|
+                            SDL_EVENTMASK(SDL_KEYUP),           'Constant SDL_KEYEVENTMASK');
+is(SDL_MOUSEMOTIONMASK,     SDL_EVENTMASK(SDL_MOUSEMOTION),     'Constant SDL_MOUSEMOTIONMASK');
+is(SDL_MOUSEBUTTONDOWNMASK, SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN), 'Constant SDL_MOUSEBUTTONDOWNMASK');
+is(SDL_MOUSEBUTTONUPMASK,   SDL_EVENTMASK(SDL_MOUSEBUTTONUP),   'Constant SDL_MOUSEBUTTONUPMASK');
+is(SDL_MOUSEEVENTMASK,      SDL_EVENTMASK(SDL_MOUSEMOTION)|
+                            SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)|
+                            SDL_EVENTMASK(SDL_MOUSEBUTTONUP),   'Constant SDL_MOUSEEVENTMASK');
+is(SDL_JOYAXISMOTIONMASK,   SDL_EVENTMASK(SDL_JOYAXISMOTION),   'Constant SDL_JOYAXISMOTIONMASK');
+is(SDL_JOYBALLMOTIONMASK,   SDL_EVENTMASK(SDL_JOYBALLMOTION),   'Constant SDL_JOYBALLMOTIONMASK');
+is(SDL_JOYHATMOTIONMASK,    SDL_EVENTMASK(SDL_JOYHATMOTION),    'Constant SDL_JOYHATMOTIONMASK');
+is(SDL_JOYBUTTONDOWNMASK,   SDL_EVENTMASK(SDL_JOYBUTTONDOWN),   'Constant SDL_JOYBUTTONDOWNMASK');
+is(SDL_JOYBUTTONUPMASK,     SDL_EVENTMASK(SDL_JOYBUTTONUP),     'Constant SDL_JOYBUTTONUPMASK');
+is(SDL_JOYEVENTMASK,        SDL_EVENTMASK(SDL_JOYAXISMOTION)|
+                            SDL_EVENTMASK(SDL_JOYBALLMOTION)|
+                            SDL_EVENTMASK(SDL_JOYHATMOTION)|
+                            SDL_EVENTMASK(SDL_JOYBUTTONDOWN)|
+                            SDL_EVENTMASK(SDL_JOYBUTTONUP),     'Constant SDL_JOYEVENTMASK');
+is(SDL_VIDEORESIZEMASK,     SDL_EVENTMASK(SDL_VIDEORESIZE),     'Constant SDL_VIDEORESIZEMASK');
+is(SDL_VIDEOEXPOSEMASK,     SDL_EVENTMASK(SDL_VIDEOEXPOSE),     'Constant SDL_VIDEOEXPOSEMASK');
+is(SDL_QUITMASK,            SDL_EVENTMASK(SDL_QUIT),            'Constant SDL_QUITMASK');
+is(SDL_SYSWMEVENTMASK,      SDL_EVENTMASK(SDL_SYSWMEVENT),      'Constant SDL_SYSWMEVENTMASK');
+is(SDL_ALLEVENTS,           0xFFFFFFFF,                         'Constant SDL_SYSWMEVENTMASK');
+
+# checking the ->type of an event
 #is($event->type,   SDL_EVENT, '[SDL::Event->type] returns correctly');
 is($aevent->type,  SDL_ACTIVEEVENT, '[SDL::ActiveEvent->type] returns correctly'); 
 is($weevent->type, SDL_VIDEOEXPOSE, '[SDL::ExposeEvent->type] returns correctly');