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.269 by root, Sun Jul 20 03:46:02 2008 UTC vs.
Revision 1.276 by root, Sat Aug 30 08:04:01 2008 UTC

39#include <SDL_endian.h> 39#include <SDL_endian.h>
40#include <SDL_image.h> 40#include <SDL_image.h>
41#include <SDL_mixer.h> 41#include <SDL_mixer.h>
42#include <SDL_opengl.h> 42#include <SDL_opengl.h>
43 43
44/* work around os x broken headers */
45#ifdef __MACOSX__
46typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
47#endif
48
44#define PANGO_ENABLE_BACKEND 49#define PANGO_ENABLE_BACKEND
45#define G_DISABLE_CAST_CHECKS 50#define G_DISABLE_CAST_CHECKS
46 51
47#include <glib/gmacros.h> 52#include <glib/gmacros.h>
48 53
85 90
86#define MIN_FONT_HEIGHT 10 91#define MIN_FONT_HEIGHT 10
87 92
88/* mask out modifiers we are not interested in */ 93/* mask out modifiers we are not interested in */
89#define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) 94#define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META)
95
96#define KMOD_LRAM 0x10000 // our extension
90 97
91static AV *texture_av; 98static AV *texture_av;
92 99
93static struct 100static struct
94{ 101{
521 if (!svp || !SvTRUE (*svp)) 528 if (!svp || !SvTRUE (*svp))
522 return 0; 529 return 0;
523 530
524 return 1; 531 return 1;
525} 532}
533
534/* process keyboard modifiers */
535static int
536mod_munge (int mod)
537{
538 mod &= MOD_MASK;
539
540 if (mod & (KMOD_META | KMOD_ALT))
541 mod |= KMOD_LRAM;
542
543 return mod;
544}
545
546static void
547deliantra_main ()
548{
549 char *argv[] = { 0 };
550 call_argv ("::main", G_DISCARD | G_VOID, argv);
551}
552
553#ifdef __MACOSX__
554 /* to due surprising braindamage on the side of SDL design, we
555 * do some mind-boggling hack here: SDL requires a custom main()
556 * on OS X, so... we provide one and call the original main(), which,
557 * due to share dlibrary magic, calls -lSDLmain's main, not perl's main,
558 * and which calls our main (== SDL_main) back.
559 */
560 extern C_LINKAGE int
561 main (int argc, char *argv[])
562 {
563 deliantra_main ();
564 }
565
566 #undef main
567
568 extern C_LINKAGE int main (int argc, char *argv[]);
569
570 static void
571 SDL_braino (void)
572 {
573 char *argv[] = { "deliantra client", 0 };
574 (main) (1, argv);
575 }
576#else
577 static void
578 SDL_braino (void)
579 {
580 deliantra_main ();
581 }
582#endif
526 583
527MODULE = Deliantra::Client PACKAGE = DC 584MODULE = Deliantra::Client PACKAGE = DC
528 585
529PROTOTYPES: ENABLE 586PROTOTYPES: ENABLE
530 587
559 const_iv (SDL_USEREVENT), 616 const_iv (SDL_USEREVENT),
560 617
561 const_iv (SDL_APPINPUTFOCUS), 618 const_iv (SDL_APPINPUTFOCUS),
562 const_iv (SDL_APPMOUSEFOCUS), 619 const_iv (SDL_APPMOUSEFOCUS),
563 const_iv (SDL_APPACTIVE), 620 const_iv (SDL_APPACTIVE),
621
622
623 const_iv (SDLK_UNKNOWN),
624 const_iv (SDLK_FIRST),
625 const_iv (SDLK_BACKSPACE),
626 const_iv (SDLK_TAB),
627 const_iv (SDLK_CLEAR),
628 const_iv (SDLK_RETURN),
629 const_iv (SDLK_PAUSE),
630 const_iv (SDLK_ESCAPE),
631 const_iv (SDLK_SPACE),
632 const_iv (SDLK_EXCLAIM),
633 const_iv (SDLK_QUOTEDBL),
634 const_iv (SDLK_HASH),
635 const_iv (SDLK_DOLLAR),
636 const_iv (SDLK_AMPERSAND),
637 const_iv (SDLK_QUOTE),
638 const_iv (SDLK_LEFTPAREN),
639 const_iv (SDLK_RIGHTPAREN),
640 const_iv (SDLK_ASTERISK),
641 const_iv (SDLK_PLUS),
642 const_iv (SDLK_COMMA),
643 const_iv (SDLK_MINUS),
644 const_iv (SDLK_PERIOD),
645 const_iv (SDLK_SLASH),
646 const_iv (SDLK_0),
647 const_iv (SDLK_1),
648 const_iv (SDLK_2),
649 const_iv (SDLK_3),
650 const_iv (SDLK_4),
651 const_iv (SDLK_5),
652 const_iv (SDLK_6),
653 const_iv (SDLK_7),
654 const_iv (SDLK_8),
655 const_iv (SDLK_9),
656 const_iv (SDLK_COLON),
657 const_iv (SDLK_SEMICOLON),
658 const_iv (SDLK_LESS),
659 const_iv (SDLK_EQUALS),
660 const_iv (SDLK_GREATER),
661 const_iv (SDLK_QUESTION),
662 const_iv (SDLK_AT),
663
664 const_iv (SDLK_LEFTBRACKET),
665 const_iv (SDLK_BACKSLASH),
666 const_iv (SDLK_RIGHTBRACKET),
667 const_iv (SDLK_CARET),
668 const_iv (SDLK_UNDERSCORE),
669 const_iv (SDLK_BACKQUOTE),
670 const_iv (SDLK_DELETE),
564 671
565 const_iv (SDLK_FIRST), 672 const_iv (SDLK_FIRST),
566 const_iv (SDLK_LAST), 673 const_iv (SDLK_LAST),
567 const_iv (SDLK_KP0), 674 const_iv (SDLK_KP0),
568 const_iv (SDLK_KP1), 675 const_iv (SDLK_KP1),
644 const_iv (KMOD_RMETA), 751 const_iv (KMOD_RMETA),
645 const_iv (KMOD_NUM), 752 const_iv (KMOD_NUM),
646 const_iv (KMOD_CAPS), 753 const_iv (KMOD_CAPS),
647 const_iv (KMOD_MODE), 754 const_iv (KMOD_MODE),
648 755
756 const_iv (KMOD_LRAM),
757
649 const_iv (MIX_DEFAULT_FORMAT), 758 const_iv (MIX_DEFAULT_FORMAT),
650 759
651 const_iv (SDL_INIT_TIMER), 760 const_iv (SDL_INIT_TIMER),
652 const_iv (SDL_INIT_AUDIO), 761 const_iv (SDL_INIT_AUDIO),
653 const_iv (SDL_INIT_VIDEO), 762 const_iv (SDL_INIT_VIDEO),
721#endif 830#endif
722} 831}
723 832
724char *SDL_GetError () 833char *SDL_GetError ()
725 834
835void SDL_braino ()
836
726int SDL_Init (U32 flags) 837int SDL_Init (U32 flags)
727 838
728int SDL_InitSubSystem (U32 flags) 839int SDL_InitSubSystem (U32 flags)
729 840
730void SDL_QuitSubSystem (U32 flags) 841void SDL_QuitSubSystem (U32 flags)
838 { 949 {
839 case SDL_KEYDOWN: 950 case SDL_KEYDOWN:
840 case SDL_KEYUP: 951 case SDL_KEYUP:
841 hv_store (hv, "state", 5, newSViv (ev.key.state), 0); 952 hv_store (hv, "state", 5, newSViv (ev.key.state), 0);
842 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); 953 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0);
843 hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod & MOD_MASK), 0); 954 hv_store (hv, "mod", 3, newSViv (mod_munge (ev.key.keysym.mod)), 0);
844 hv_store (hv, "cmod", 4, newSViv (SDL_GetModState () & MOD_MASK), 0); /* current mode */ 955 hv_store (hv, "cmod", 4, newSViv (mod_munge (SDL_GetModState ())), 0); /* current mode */
845 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); 956 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0);
846 break; 957 break;
847 958
848 case SDL_ACTIVEEVENT: 959 case SDL_ACTIVEEVENT:
849 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); 960 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0);
867 x = ev.motion.x; 978 x = ev.motion.x;
868 y = ev.motion.y; 979 y = ev.motion.y;
869 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); 980 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION));
870 } 981 }
871 982
872 hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); 983 hv_store (hv, "mod", 3, newSViv (mod_munge (SDL_GetModState ())), 0);
873 hv_store (hv, "state", 5, newSViv (state), 0); 984 hv_store (hv, "state", 5, newSViv (state), 0);
874 hv_store (hv, "x", 1, newSViv (x), 0); 985 hv_store (hv, "x", 1, newSViv (x), 0);
875 hv_store (hv, "y", 1, newSViv (y), 0); 986 hv_store (hv, "y", 1, newSViv (y), 0);
876 hv_store (hv, "xrel", 4, newSViv (xrel), 0); 987 hv_store (hv, "xrel", 4, newSViv (xrel), 0);
877 hv_store (hv, "yrel", 4, newSViv (yrel), 0); 988 hv_store (hv, "yrel", 4, newSViv (yrel), 0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines