I'm trying to convert to Java some code that uses SDL. I'm using the sdljava bindings.
sdljava uses SWIG as the bridge between the C datatypes and Java. To get the equivalent of SDL_GetKeyState()
, sdljava provides the method SWIG_SDLEvent.SDL_GetKeyState()
, which returns something called a SWIGTYPE_p_unsigned_char
.
Of course, Java has no unsigned char
type, and I don't know what the compiler thinks this SWIG type actually represents to Java. Normal use of SDL_GetKeyState()
in C/C++ would be something like:
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?