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.197 by root, Sun Jul 15 21:08:40 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"
659 664
660char * 665char *
661SDL_GetKeyName (int sym) 666SDL_GetKeyName (int sym)
662 667
663void 668void
664SDL_PollEvent () 669poll_events ()
665 PPCODE: 670 PPCODE:
666{ 671{
667 SDL_Event ev; 672 SDL_Event ev;
668 673
669 while (SDL_PollEvent (&ev)) 674 SDL_PumpEvents ();
675 while (SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_ALLEVENTS) > 0)
670 { 676 {
671 HV *hv = newHV (); 677 HV *hv = newHV ();
672 hv_store (hv, "type", 4, newSViv (ev.type), 0); 678 hv_store (hv, "type", 4, newSViv (ev.type), 0);
673 679
674 switch (ev.type) 680 switch (ev.type)
686 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); 692 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0);
687 hv_store (hv, "state", 5, newSViv (ev.active.state), 0); 693 hv_store (hv, "state", 5, newSViv (ev.active.state), 0);
688 break; 694 break;
689 695
690 case SDL_MOUSEMOTION: 696 case SDL_MOUSEMOTION:
697 {
698 int state = ev.motion.state;
699 int x = ev.motion.x;
700 int y = ev.motion.y;
701 int xrel = ev.motion.xrel;
702 int yrel = ev.motion.yrel;
703
704 /* do simplistic event compression */
705 while (SDL_PeepEvents (&ev, 1, SDL_PEEKEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)) > 0
706 && state == ev.motion.state)
707 {
708 xrel += ev.motion.xrel;
709 yrel += ev.motion.yrel;
710 x = ev.motion.x;
711 y = ev.motion.y;
712 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION));
713 }
714
691 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); 715 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0);
692
693 hv_store (hv, "state", 5, newSViv (ev.motion.state), 0); 716 hv_store (hv, "state", 5, newSViv (state), 0);
694 hv_store (hv, "x", 1, newSViv (ev.motion.x), 0); 717 hv_store (hv, "x", 1, newSViv (x), 0);
695 hv_store (hv, "y", 1, newSViv (ev.motion.y), 0); 718 hv_store (hv, "y", 1, newSViv (y), 0);
696 hv_store (hv, "xrel", 4, newSViv (ev.motion.xrel), 0); 719 hv_store (hv, "xrel", 4, newSViv (xrel), 0);
697 hv_store (hv, "yrel", 4, newSViv (ev.motion.yrel), 0); 720 hv_store (hv, "yrel", 4, newSViv (yrel), 0);
721 }
698 break; 722 break;
699 723
700 case SDL_MOUSEBUTTONDOWN: 724 case SDL_MOUSEBUTTONDOWN:
701 case SDL_MOUSEBUTTONUP: 725 case SDL_MOUSEBUTTONUP:
702 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); 726 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0);
882 ExitThread (retval); // unclean, please beam me up 906 ExitThread (retval); // unclean, please beam me up
883#else 907#else
884 _exit (retval); 908 _exit (retval);
885#endif 909#endif
886 910
911void
912debug ()
913 CODE:
914{
915#if DEBUG
916 VALGRIND_DO_LEAK_CHECK;
917#endif
918}
919
887MODULE = CFPlus PACKAGE = CFPlus::Font 920MODULE = CFPlus PACKAGE = CFPlus::Font
888 921
889CFPlus::Font 922CFPlus::Font
890new_from_file (SV *class, char *path, int id = 0) 923new_from_file (SV *class, char *path, int id = 0)
891 CODE: 924 CODE:
2126 CODE: 2159 CODE:
2127 RETVAL = Mix_VolumeMusic (volume); 2160 RETVAL = Mix_VolumeMusic (volume);
2128 OUTPUT: 2161 OUTPUT:
2129 RETVAL 2162 RETVAL
2130 2163
2164int
2165fade_out (int ms)
2166 CODE:
2167 RETVAL = Mix_FadeOutMusic (ms);
2168 OUTPUT:
2169 RETVAL
2170
2131CFPlus::MixMusic 2171CFPlus::MixMusic
2132new_from_file (SV *class, char *path) 2172new_from_file (SV *class, char *path)
2133 CODE: 2173 CODE:
2134 RETVAL = Mix_LoadMUS (path); 2174 RETVAL = Mix_LoadMUS (path);
2135 OUTPUT: 2175 OUTPUT:
2142 2182
2143int 2183int
2144play (CFPlus::MixMusic self, int loops = -1) 2184play (CFPlus::MixMusic self, int loops = -1)
2145 CODE: 2185 CODE:
2146 RETVAL = Mix_PlayMusic (self, loops); 2186 RETVAL = Mix_PlayMusic (self, loops);
2187 OUTPUT:
2188 RETVAL
2189
2190int
2191fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position)
2192 CODE:
2193 RETVAL = Mix_FadeInMusicPos (self, loops, ms, position);
2147 OUTPUT: 2194 OUTPUT:
2148 RETVAL 2195 RETVAL
2149 2196
2150MODULE = CFPlus PACKAGE = CFPlus::OpenGL 2197MODULE = CFPlus PACKAGE = CFPlus::OpenGL
2151 2198

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines