mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-24 13:01:02 +00:00
Merge pull request #92 from lvonasek/feature_remote_keyboard
Support for BT/OTG keyboards
This commit is contained in:
commit
79befe4d38
2 changed files with 23 additions and 1 deletions
|
@ -36,6 +36,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)
|
||||
{
|
||||
Com_QueueEvent( 0, SE_CHAR, keycode, qtrue, 0, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||
{
|
||||
g_JavaVM = vm;
|
||||
|
|
|
@ -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;
|
||||
|
@ -35,6 +36,7 @@ import static android.system.Os.setenv;
|
|||
|
||||
public class MainActivity extends SDLActivity // implements KeyEvent.Callback
|
||||
{
|
||||
private static final String SUPPORTED_ASCII = "qwertyuiop[]asdfghjkl;'\\<zxcvbnm,./QWERTYUIOP{}ASDFGHJKL:\"|>ZXCVBNM<>?`1234567890-=~!@#$%^&*()_+";
|
||||
private int permissionCount = 0;
|
||||
private static final int READ_EXTERNAL_STORAGE_PERMISSION_ID = 1;
|
||||
private static final int WRITE_EXTERNAL_STORAGE_PERMISSION_ID = 2;
|
||||
|
@ -72,6 +74,17 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
//ASCII characters directly passed into the engine
|
||||
if (SUPPORTED_ASCII.indexOf(event.getUnicodeChar()) >= 0) {
|
||||
nativeKey(event.getUnicodeChar(), event.getAction());
|
||||
return true;
|
||||
}
|
||||
//special keys using SDL
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Activity only if the permission has been granted.
|
||||
*/
|
||||
|
@ -246,6 +259,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