From: Tobias Leich Date: Sun, 8 Nov 2009 19:50:53 +0000 (+0100) Subject: keysym.xs X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=12bee888cf1af8e911b33cabf7cad256fe8bbe66;p=sdlgit%2FSDL_perl.git keysym.xs --- diff --git a/src/Core/objects/keysym.xs b/src/Core/objects/keysym.xs new file mode 100644 index 0000000..6452ad0 --- /dev/null +++ b/src/Core/objects/keysym.xs @@ -0,0 +1,97 @@ +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#ifndef aTHX_ +#define aTHX_ +#endif + +#include + +MODULE = SDL::keysym PACKAGE = SDL::keysym PREFIX = keysym_ + +=for documentation + +SDL_keysym -- keysym structure + + typedef struct{ + Uint8 scancode; + SDLKey sym; + SDLMod mod; + Uint16 unicode; + } SDL_keysym; + + +=cut + +SDL_keysym * +keysym_new ( CLASS ) + char* CLASS + CODE: + RETVAL = safemalloc(sizeof(SDL_keysym)); + OUTPUT: + RETVAL + +Uint8 +keysym_scancode ( keysym, ... ) + SDL_keysym *keysym + CODE: + if( items > 1 ) + { + keysym->scancode = SvIV( ST(1) ); + } + + RETVAL = keysym->scancode; + OUTPUT: + RETVAL + +SDLKey * +keysym_sym ( keysym, ... ) + SDL_keysym *keysym + PREINIT: + char* CLASS = "SDL::Key"; + CODE: + if( items > 1 ) + { + SDLKey *kp = (SDLKey * )SvPV( ST(1), PL_na) ; + keysym->sym = *kp; + } + + RETVAL = &(keysym->sym); + OUTPUT: + RETVAL + +SDLMod * +keysym_mod ( keysym, ... ) + SDL_keysym *keysym + PREINIT: + char* CLASS = "SDL::Mod"; + CODE: + if( items > 1 ) + { + SDLMod *mp = (SDLMod * )SvPV( ST(1), PL_na) ; + keysym->mod = *mp; + } + + RETVAL = &(keysym->mod); + OUTPUT: + RETVAL + +Uint16 +keysym_unicode ( keysym, ... ) + SDL_keysym *keysym + CODE: + if( items > 1 ) + { + keysym->unicode = SvIV( ST(1) ); + } + + RETVAL = keysym->unicode; + OUTPUT: + RETVAL + +void +keysym_DESTROY(self) + SDL_keysym *self + CODE: + safefree( (char *)self );