ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.192 by root, Fri Apr 27 21:27:51 2007 UTC vs.
Revision 1.198 by root, Sun Jul 15 21:42:02 2007 UTC

4# include <malloc.h> 4# include <malloc.h>
5# include <windows.h> 5# include <windows.h>
6# include <wininet.h> 6# include <wininet.h>
7# pragma warning(disable:4244) 7# pragma warning(disable:4244)
8# pragma warning(disable:4761) 8# pragma warning(disable:4761)
9#endif
10
11//#define DEBUG 1
12#if DEBUG
13# include <valgrind/memcheck.h>
9#endif 14#endif
10 15
11#include "EXTERN.h" 16#include "EXTERN.h"
12#include "perl.h" 17#include "perl.h"
13#include "XSUB.h" 18#include "XSUB.h"
658SDL_GL_SwapBuffers () 663SDL_GL_SwapBuffers ()
659 664
660char * 665char *
661SDL_GetKeyName (int sym) 666SDL_GetKeyName (int sym)
662 667
668int
669SDL_GetAppState ()
670
663void 671void
664SDL_PollEvent () 672poll_events ()
665 PPCODE: 673 PPCODE:
666{ 674{
667 SDL_Event ev; 675 SDL_Event ev;
668 676
669 while (SDL_PollEvent (&ev)) 677 SDL_PumpEvents ();
678 while (SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_ALLEVENTS) > 0)
670 { 679 {
671 HV *hv = newHV (); 680 HV *hv = newHV ();
672 hv_store (hv, "type", 4, newSViv (ev.type), 0); 681 hv_store (hv, "type", 4, newSViv (ev.type), 0);
673 682
674 switch (ev.type) 683 switch (ev.type)
686 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); 695 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0);
687 hv_store (hv, "state", 5, newSViv (ev.active.state), 0); 696 hv_store (hv, "state", 5, newSViv (ev.active.state), 0);
688 break; 697 break;
689 698
690 case SDL_MOUSEMOTION: 699 case SDL_MOUSEMOTION:
700 {
701 int state = ev.motion.state;
702 int x = ev.motion.x;
703 int y = ev.motion.y;
704 int xrel = ev.motion.xrel;
705 int yrel = ev.motion.yrel;
706
707 /* do simplistic event compression */
708 while (SDL_PeepEvents (&ev, 1, SDL_PEEKEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)) > 0
709 && state == ev.motion.state)
710 {
711 xrel += ev.motion.xrel;
712 yrel += ev.motion.yrel;
713 x = ev.motion.x;
714 y = ev.motion.y;
715 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION));
716 }
717
691 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); 718 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0);
692
693 hv_store (hv, "state", 5, newSViv (ev.motion.state), 0); 719 hv_store (hv, "state", 5, newSViv (state), 0);
694 hv_store (hv, "x", 1, newSViv (ev.motion.x), 0); 720 hv_store (hv, "x", 1, newSViv (x), 0);
695 hv_store (hv, "y", 1, newSViv (ev.motion.y), 0); 721 hv_store (hv, "y", 1, newSViv (y), 0);
696 hv_store (hv, "xrel", 4, newSViv (ev.motion.xrel), 0); 722 hv_store (hv, "xrel", 4, newSViv (xrel), 0);
697 hv_store (hv, "yrel", 4, newSViv (ev.motion.yrel), 0); 723 hv_store (hv, "yrel", 4, newSViv (yrel), 0);
724 }
698 break; 725 break;
699 726
700 case SDL_MOUSEBUTTONDOWN: 727 case SDL_MOUSEBUTTONDOWN:
701 case SDL_MOUSEBUTTONUP: 728 case SDL_MOUSEBUTTONUP:
702 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); 729 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0);
882 ExitThread (retval); // unclean, please beam me up 909 ExitThread (retval); // unclean, please beam me up
883#else 910#else
884 _exit (retval); 911 _exit (retval);
885#endif 912#endif
886 913
914void
915debug ()
916 CODE:
917{
918#if DEBUG
919 VALGRIND_DO_LEAK_CHECK;
920#endif
921}
922
887MODULE = CFPlus PACKAGE = CFPlus::Font 923MODULE = CFPlus PACKAGE = CFPlus::Font
888 924
889CFPlus::Font 925CFPlus::Font
890new_from_file (SV *class, char *path, int id = 0) 926new_from_file (SV *class, char *path, int id = 0)
891 CODE: 927 CODE:
2126 CODE: 2162 CODE:
2127 RETVAL = Mix_VolumeMusic (volume); 2163 RETVAL = Mix_VolumeMusic (volume);
2128 OUTPUT: 2164 OUTPUT:
2129 RETVAL 2165 RETVAL
2130 2166
2167int
2168fade_out (int ms)
2169 CODE:
2170 RETVAL = Mix_FadeOutMusic (ms);
2171 OUTPUT:
2172 RETVAL
2173
2131CFPlus::MixMusic 2174CFPlus::MixMusic
2132new_from_file (SV *class, char *path) 2175new_from_file (SV *class, char *path)
2133 CODE: 2176 CODE:
2134 RETVAL = Mix_LoadMUS (path); 2177 RETVAL = Mix_LoadMUS (path);
2135 OUTPUT: 2178 OUTPUT:
2142 2185
2143int 2186int
2144play (CFPlus::MixMusic self, int loops = -1) 2187play (CFPlus::MixMusic self, int loops = -1)
2145 CODE: 2188 CODE:
2146 RETVAL = Mix_PlayMusic (self, loops); 2189 RETVAL = Mix_PlayMusic (self, loops);
2190 OUTPUT:
2191 RETVAL
2192
2193int
2194fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position)
2195 CODE:
2196 RETVAL = Mix_FadeInMusicPos (self, loops, ms, position);
2147 OUTPUT: 2197 OUTPUT:
2148 RETVAL 2198 RETVAL
2149 2199
2150MODULE = CFPlus PACKAGE = CFPlus::OpenGL 2200MODULE = CFPlus PACKAGE = CFPlus::OpenGL
2151 2201

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines