Added Some fixes
[sdlgit/SDL_perl.git] / src / SDL.xs
index 568e05f..f04ad58 100644 (file)
@@ -3,7 +3,7 @@
 // SDL Perl by David J. Goehrig <dgoehrig@cpan.org>
 //
 // Copyright (C) 2000,2001,2002,2003,2004 David J. Goehrig 
-//
+// Copyright (C) 2009 Kartik Thakore
 // This software is under the GNU Library General Public License (LGPL)
 // see the file COPYING for terms of use
 
@@ -71,6 +71,32 @@ static int sdl_perl_use_smpeg_audio = 0;
 
 #include "defines.h"
 
+#ifdef MACOSX
+#include <CoreServices/CoreServices.h>
+void CPSEnableForegroundOperation(ProcessSerialNumber* psn);
+void NSApplicationLoad();
+void SDL_macosx_init(void) {
+    Boolean sameProc;
+    ProcessSerialNumber myProc, frProc;
+    if (GetFrontProcess(&frProc) == noErr)
+        if (GetCurrentProcess(&myProc) == noErr)
+            if (SameProcess(&frProc, &myProc, &sameProc) == noErr && sameProc == 0) {
+                /*
+                NSLog(@"creating bad autorelease pool");
+                [[NSAutoreleasePool alloc] init];
+                */
+                NSApplicationLoad();
+                CPSEnableForegroundOperation(&myProc);
+            }
+}
+void SDL_macosx_quit(void) {
+}
+#endif // MACOSX
+
+
+
+
+
 Uint32 
 sdl_perl_timer_callback ( Uint32 interval, void* param )
 {
@@ -501,6 +527,19 @@ FreeEvent ( e )
        CODE:
                safefree(e);
 
+
+int
+PeepEvents( e, numevents, action, mask)
+       SDL_Event *e
+       int numevents
+       SDL_eventaction action
+       Uint32 mask
+       CODE:
+               RETVAL = (int)SDL_PeepEvents( e, numevents, action, mask);
+       OUTPUT:
+               RETVAL
+
+
 int
 PollEvent ( e )
        SDL_Event *e
@@ -1182,6 +1221,20 @@ ColorB ( color, ... )
                RETVAL
 
 void
+ColorRGB ( color, ... )
+       SDL_Color *color
+       PPCODE:
+               if (items > 1 ) {
+                       color->r = SvIV(ST(1)); 
+                       color->g = SvIV(ST(2)); 
+                       color->b = SvIV(ST(3)); 
+               }
+               mXPUSHi( color->r );
+               mXPUSHi( color->g );
+               mXPUSHi( color->b );
+               XSRETURN(3);
+
+void
 FreeColor ( color )
        SDL_Color *color
        CODE:
@@ -2297,7 +2350,7 @@ JoyAxisEventValue ( e )
         OUTPUT:
                 RETVAL
 
-Uint8
+Sint16
 JoyButtonEventWhich ( e )
         SDL_Event *e
         CODE:
@@ -2441,7 +2494,7 @@ NetFreeIPaddress ( ip )
        CODE:
                safefree(ip);
 
-char*
+const char*
 NetResolveIP ( address )
        IPaddress *address
        CODE:
@@ -3902,7 +3955,7 @@ OUTPUT:
      RETVAL
 
 int
-GFXFilledpieColor ( dst, x, y, rad, start, end, color )
+GFXFilledPieColor ( dst, x, y, rad, start, end, color )
     SDL_Surface* dst;
     Sint16 x;
     Sint16 y;
@@ -3911,12 +3964,12 @@ GFXFilledpieColor ( dst, x, y, rad, start, end, color )
     Sint16 end;
     Uint32 color;
 CODE:
-     RETVAL = filledpieColor( dst, x, y, rad, start, end, color );
+     RETVAL = filledPieColor( dst, x, y, rad, start, end, color );
 OUTPUT:
      RETVAL
 
 int
-GFXFilledpieRGBA ( dst, x, y, rad, start, end, r, g, b, a )
+GFXFilledPieRGBA ( dst, x, y, rad, start, end, r, g, b, a )
     SDL_Surface* dst;
     Sint16 x;
     Sint16 y;
@@ -3928,7 +3981,7 @@ GFXFilledpieRGBA ( dst, x, y, rad, start, end, r, g, b, a )
     Uint8 b;
     Uint8 a;
 CODE:
-     RETVAL = filledpieRGBA( dst, x, y, rad, start, end, r, g, b, a );
+     RETVAL = filledPieRGBA( dst, x, y, rad, start, end, r, g, b, a );
 OUTPUT:
      RETVAL