--- deliantra/Deliantra-Client/Client.xs 2006/04/19 00:47:34 1.50 +++ deliantra/Deliantra-Client/Client.xs 2006/04/19 20:46:44 1.51 @@ -243,11 +243,171 @@ BOOT: { - fontmap = pango_ft2_font_map_new (); - pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)fontmap, substitute_func, 0, 0); - context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); + HV *stash = gv_stashpv ("CFClient", 1); + static const struct { + const char *name; + IV iv; + } *civ, const_iv[] = { +# define const_iv(name) { # name, (IV)name } + const_iv (SDL_ACTIVEEVENT), + const_iv (SDL_KEYDOWN), + const_iv (SDL_KEYUP), + const_iv (SDL_MOUSEMOTION), + const_iv (SDL_MOUSEBUTTONDOWN), + const_iv (SDL_MOUSEBUTTONUP), + const_iv (SDL_JOYAXISMOTION), + const_iv (SDL_JOYBALLMOTION), + const_iv (SDL_JOYHATMOTION), + const_iv (SDL_JOYBUTTONDOWN), + const_iv (SDL_JOYBUTTONUP), + const_iv (SDL_QUIT), + const_iv (SDL_SYSWMEVENT), + const_iv (SDL_EVENT_RESERVEDA), + const_iv (SDL_EVENT_RESERVEDB), + const_iv (SDL_VIDEORESIZE), + const_iv (SDL_VIDEOEXPOSE), + const_iv (SDL_USEREVENT), + const_iv (SDLK_KP0), + const_iv (SDLK_KP1), + const_iv (SDLK_KP2), + const_iv (SDLK_KP3), + const_iv (SDLK_KP4), + const_iv (SDLK_KP5), + const_iv (SDLK_KP6), + const_iv (SDLK_KP7), + const_iv (SDLK_KP8), + const_iv (SDLK_KP9), + const_iv (SDLK_KP_PERIOD), + const_iv (SDLK_KP_DIVIDE), + const_iv (SDLK_KP_MULTIPLY), + const_iv (SDLK_KP_MINUS), + const_iv (SDLK_KP_PLUS), + const_iv (SDLK_KP_ENTER), + const_iv (SDLK_KP_EQUALS), + const_iv (SDLK_UP), + const_iv (SDLK_DOWN), + const_iv (SDLK_RIGHT), + const_iv (SDLK_LEFT), + const_iv (SDLK_INSERT), + const_iv (SDLK_HOME), + const_iv (SDLK_END), + const_iv (SDLK_PAGEUP), + const_iv (SDLK_PAGEDOWN), + const_iv (SDLK_F1), + const_iv (SDLK_F2), + const_iv (SDLK_F3), + const_iv (SDLK_F4), + const_iv (SDLK_F5), + const_iv (SDLK_F6), + const_iv (SDLK_F7), + const_iv (SDLK_F8), + const_iv (SDLK_F9), + const_iv (SDLK_F10), + const_iv (SDLK_F11), + const_iv (SDLK_F12), + const_iv (SDLK_F13), + const_iv (SDLK_F14), + const_iv (SDLK_F15), + const_iv (SDLK_NUMLOCK), + const_iv (SDLK_CAPSLOCK), + const_iv (SDLK_SCROLLOCK), + const_iv (SDLK_RSHIFT), + const_iv (SDLK_LSHIFT), + const_iv (SDLK_RCTRL), + const_iv (SDLK_LCTRL), + const_iv (SDLK_RALT), + const_iv (SDLK_LALT), + const_iv (SDLK_RMETA), + const_iv (SDLK_LMETA), + const_iv (SDLK_LSUPER), + const_iv (SDLK_RSUPER), + const_iv (SDLK_MODE), + const_iv (SDLK_COMPOSE), + const_iv (SDLK_HELP), + const_iv (SDLK_PRINT), + const_iv (SDLK_SYSREQ), + const_iv (SDLK_BREAK), + const_iv (SDLK_MENU), + const_iv (SDLK_POWER), + const_iv (SDLK_EURO), + const_iv (SDLK_UNDO), + const_iv (KMOD_NONE), + const_iv (KMOD_LSHIFT), + const_iv (KMOD_RSHIFT), + const_iv (KMOD_LCTRL), + const_iv (KMOD_RCTRL), + const_iv (KMOD_LALT), + const_iv (KMOD_RALT), + const_iv (KMOD_LMETA), + const_iv (KMOD_RMETA), + const_iv (KMOD_NUM), + const_iv (KMOD_CAPS), + const_iv (KMOD_MODE), + const_iv (KMOD_CTRL), + const_iv (KMOD_SHIFT), + const_iv (KMOD_ALT), + const_iv (KMOD_META) +# undef const_iv + }; + + for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) + newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); + + fontmap = pango_ft2_font_map_new (); + pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)fontmap, substitute_func, 0, 0); + context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); +} + +int +SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO) + +void +SDL_Quit () + +void +SDL_ListModes () + PPCODE: +{ + SDL_Rect **m; + + SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 5); + SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 5); + SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5); + SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE, 1); + + SDL_GL_SetAttribute (SDL_GL_ACCUM_RED_SIZE, 0); + SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); + SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); + SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); + + SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute (SDL_GL_BUFFER_SIZE, 15); + SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 0); + + m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); + + if (m && m != (SDL_Rect **)-1) + while (*m) + { + AV *av = newAV (); + av_push (av, newSViv ((*m)->w)); + av_push (av, newSViv ((*m)->h)); + XPUSHs (sv_2mortal (newRV_noinc ((SV *)av))); + + ++m; + } } +int +SDL_SetVideoMode (int w, int h, int fullscreen) + CODE: + RETVAL = !!SDL_SetVideoMode ( + w, h, 0, SDL_OPENGL | (fullscreen ? SDL_FULLSCREEN : 0) + ); + SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); + OUTPUT: + RETVAL + void lowdelay (int fd, int val = 1) CODE: