Game Development Reference
In-Depth Information
public static void setListener(EventListener l) {
listener = l;
}
/**
* Send a key event to the native layer
*
* @param type : key up down or mouse
* @param sym: ASCII symbol
*/
public static void sendNativeKeyEvent(int type, int sym) {
try {
Natives.keyEvent(type, sym);
} catch (UnsatisfiedLinkError e) {
Log.e(TAG, e.toString());
}
}
// Native Main Doom Loop: @param argv: program arguments
public static native int DoomMain(String[] argv);
/**
* Send a Key Event
* @param type: event type: UP/DOWN
* @param key: ASCII symbol
*/
public static native int keyEvent(int type, int key);
/***********************************************************
* C to Java - Callbacks
***********************************************************/
/**
* This fires on messages from the C layer
*/
private static void OnMessage(String text, int level) {
if (listener != null)
listener.OnMessage(text, level);
}
private static void OnInitGraphics(int w, int h) {
if (listener != null)
listener.OnInitGraphics(w, h);
}
private static void OnImageUpdate(int[] pixels) {
if (listener != null)
listener.OnImageUpdate(pixels);
}
Search WWH ::




Custom Search