mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 06:41:58 +00:00
Support external keyboards
This commit is contained in:
parent
6d9951dd95
commit
8bb0124fe6
2 changed files with 19 additions and 1 deletions
|
@ -36,6 +36,14 @@ JNIEXPORT void JNICALL Java_com_drbeef_ioq3quest_MainActivity_nativeFocusChanged
|
||||||
g_HasFocus = focus;
|
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)
|
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||||
{
|
{
|
||||||
g_JavaVM = vm;
|
g_JavaVM = vm;
|
||||||
|
@ -121,4 +129,4 @@ int main(int argc, char* argv[]) {
|
||||||
VR_Destroy(engine);
|
VR_Destroy(engine);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -8,6 +8,7 @@ import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
@ -72,6 +73,14 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback
|
||||||
super.onDestroy();
|
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.
|
* Initializes the Activity only if the permission has been granted.
|
||||||
*/
|
*/
|
||||||
|
@ -246,6 +255,7 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback
|
||||||
|
|
||||||
public static native void nativeCreate(MainActivity thisObject);
|
public static native void nativeCreate(MainActivity thisObject);
|
||||||
public static native void nativeFocusChanged(boolean focus);
|
public static native void nativeFocusChanged(boolean focus);
|
||||||
|
public static native void nativeKey(int keycode, int action);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("main");
|
System.loadLibrary("main");
|
||||||
|
|
Loading…
Reference in a new issue