mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-22 16:16:39 +00:00
Use range from evdev device for gamepad input
This commit is contained in:
4
jni/nv_io/build.sh
Executable file
4
jni/nv_io/build.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
rm *.o libnv_io.so
|
||||
gcc -I $JAVA_HOME/include -I $JAVA_HOME/include/linux -fPIC -L. -c *.c
|
||||
gcc -shared -Wl,-soname,libnv_io.so -Wl,--no-undefined -o libnv_io.so *.o -L.
|
||||
rm *.o
|
||||
24
jni/nv_io/nv_io_jni.c
Normal file
24
jni/nv_io/nv_io_jni.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <fcntl.h>
|
||||
#include <jni.h>
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_limelight_input_IO_ioctl(
|
||||
JNIEnv *env, jobject this, // JNI parameters
|
||||
jstring filename, jbyteArray buffer, jint request)
|
||||
{
|
||||
const char* jni_filename = (*env)->GetStringUTFChars(env, filename, NULL);
|
||||
unsigned char* jni_buffer = (*env)->GetByteArrayElements(env, buffer, NULL);
|
||||
|
||||
jboolean retval;
|
||||
int fd;
|
||||
if ((fd = open(jni_filename, O_RDONLY)) < 0) {
|
||||
retval = 0;
|
||||
} else {
|
||||
ioctl(fd, request, jni_buffer);
|
||||
close(fd);
|
||||
retval = 1;
|
||||
}
|
||||
|
||||
(*env)->ReleaseByteArrayElements(env, buffer, jni_buffer, 0);
|
||||
return retval;
|
||||
}
|
||||
Reference in New Issue
Block a user