mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2025-02-17 17:41:28 +00:00
Support external keyboards
This commit is contained in:
parent
3f669e34cd
commit
a2843fcc6b
2 changed files with 19 additions and 1 deletions
|
@ -39,6 +39,14 @@ JNIEXPORT void JNICALL Java_com_drbeef_ioq3quest_MainActivity_nativeFocusChanged
|
|||
g_HasFocus = focus;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_drbeef_ioq3quest_MainActivity_nativeKey(JNIEnv *env, jclass clazz, jint keycode, jint action)
|
||||
{
|
||||
if ((action == 0) || (action == 1))
|
||||
{
|
||||
Com_QueueEvent( 0, SE_CHAR, keycode, action == 0, 0, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||
{
|
||||
g_JavaVM = vm;
|
||||
|
@ -125,4 +133,4 @@ int main(int argc, char* argv[]) {
|
|||
VR_Destroy(engine);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import android.os.Bundle;
|
|||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
@ -72,6 +73,14 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
//ASCII characters directly passed into the engine
|
||||
nativeKey(event.getKeyCode(), event.getAction());
|
||||
//special keys using SDL
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Activity only if the permission has been granted.
|
||||
*/
|
||||
|
@ -244,6 +253,7 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback
|
|||
|
||||
public static native void nativeCreate(MainActivity thisObject);
|
||||
public static native void nativeFocusChanged(boolean focus);
|
||||
public static native void nativeKey(int keycode, int action);
|
||||
|
||||
static {
|
||||
System.loadLibrary("main");
|
||||
|
|
Loading…
Reference in a new issue