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.275 by root, Thu Aug 28 00:53:53 2008 UTC vs.
Revision 1.276 by root, Sat Aug 30 08:04:01 2008 UTC

90 90
91#define MIN_FONT_HEIGHT 10 91#define MIN_FONT_HEIGHT 10
92 92
93/* mask out modifiers we are not interested in */ 93/* mask out modifiers we are not interested in */
94#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
95 97
96static AV *texture_av; 98static AV *texture_av;
97 99
98static struct 100static struct
99{ 101{
525 svp = hv_fetch (self, "can_events", sizeof ("can_events") - 1, 0); 527 svp = hv_fetch (self, "can_events", sizeof ("can_events") - 1, 0);
526 if (!svp || !SvTRUE (*svp)) 528 if (!svp || !SvTRUE (*svp))
527 return 0; 529 return 0;
528 530
529 return 1; 531 return 1;
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;
530} 544}
531 545
532static void 546static void
533deliantra_main () 547deliantra_main ()
534{ 548{
737 const_iv (KMOD_RMETA), 751 const_iv (KMOD_RMETA),
738 const_iv (KMOD_NUM), 752 const_iv (KMOD_NUM),
739 const_iv (KMOD_CAPS), 753 const_iv (KMOD_CAPS),
740 const_iv (KMOD_MODE), 754 const_iv (KMOD_MODE),
741 755
756 const_iv (KMOD_LRAM),
757
742 const_iv (MIX_DEFAULT_FORMAT), 758 const_iv (MIX_DEFAULT_FORMAT),
743 759
744 const_iv (SDL_INIT_TIMER), 760 const_iv (SDL_INIT_TIMER),
745 const_iv (SDL_INIT_AUDIO), 761 const_iv (SDL_INIT_AUDIO),
746 const_iv (SDL_INIT_VIDEO), 762 const_iv (SDL_INIT_VIDEO),
933 { 949 {
934 case SDL_KEYDOWN: 950 case SDL_KEYDOWN:
935 case SDL_KEYUP: 951 case SDL_KEYUP:
936 hv_store (hv, "state", 5, newSViv (ev.key.state), 0); 952 hv_store (hv, "state", 5, newSViv (ev.key.state), 0);
937 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); 953 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0);
938 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);
939 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 */
940 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); 956 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0);
941 break; 957 break;
942 958
943 case SDL_ACTIVEEVENT: 959 case SDL_ACTIVEEVENT:
944 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); 960 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0);
962 x = ev.motion.x; 978 x = ev.motion.x;
963 y = ev.motion.y; 979 y = ev.motion.y;
964 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); 980 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION));
965 } 981 }
966 982
967 hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); 983 hv_store (hv, "mod", 3, newSViv (mod_munge (SDL_GetModState ())), 0);
968 hv_store (hv, "state", 5, newSViv (state), 0); 984 hv_store (hv, "state", 5, newSViv (state), 0);
969 hv_store (hv, "x", 1, newSViv (x), 0); 985 hv_store (hv, "x", 1, newSViv (x), 0);
970 hv_store (hv, "y", 1, newSViv (y), 0); 986 hv_store (hv, "y", 1, newSViv (y), 0);
971 hv_store (hv, "xrel", 4, newSViv (xrel), 0); 987 hv_store (hv, "xrel", 4, newSViv (xrel), 0);
972 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