[sdljava-users] How to get to array from what SDL_GetKeyState() returns
Status: Beta
Brought to you by:
ivan_ganza
From: Mark Z. <ski...@gm...> - 2009-10-06 18:58:33
|
I'm having trouble figuring out how to use the SWIG pointer types that some sdljava methods return. To get the equivalent of C SDL_GetKeyState() call, I'm calling SWIG_SDLEvent.SDL_GetKeyState(), which returns a SWIGTYPE_p_unsigned_char. I've used SDL in C/C++ programs, where I'd normally use SDL_GetKeyState() in code like this: Uint8 *ks = SDL_GetKeyState(NULL); if ( ks[SDLK_UP] ) { /* handle Up key */ } ... where the SDL keystate values like SDLK_UP index into an array. However, the following Java code: SWIGTYPE_p_unsigned_char ks = SWIG_SDLEvent.SDL_GetKeyState(null); if ( ks[SDLKeyValues.SDLK_UP] != 0) { /* handle Up key */ } results in the compiler error, "The type of the expression must be an array type, but it resolved to SWIGTYPE_p_unsigned_char." What I want to know is, after calling SWIG_SDLEvent.SDL_GetKeyState(), how do you use what it returns to inspect the state of the individual keys? |