I am trying to convert to Java some code that uses SDL. I am using sdljava bindings.
sdljava uses SWIG as a bridge between the C data types of C and Java. To get the equivalent SDL_GetKeyState(), sdljava provides a method SWIG_SDLEvent.SDL_GetKeyState()that returns something called SWIGTYPE_p_unsigned_char.
Of course, Java does not have a type unsigned char, and I do not know that the compiler believes that this type of SWIG is actually Java. Normal use SDL_GetKeyState()in C / C ++ would be something like:
Uint8 *ks = SDL_GetKeyState(NULL);
if ( ks[SDLK_UP] ) { }
... where are the SDL caching values, such as the SDLK_UP index, into the array.
However, the following Java code:
SWIGTYPE_p_unsigned_char ks = SWIG_SDLEvent.SDL_GetKeyState(null);
if ( ks[SDLKeyValues.SDLK_UP] != 0) { }
results in a compiler error: "The type of the expression must be an array type, but it is allowed for SWIGTYPE_p_unsigned_char."
, SWIG_SDLEvent.SDL_GetKeyState(), , , ?