Use range from evdev device for gamepad input

This commit is contained in:
Iwan Timmer
2014-01-28 01:34:45 +01:00
parent b0378ff7fa
commit dc97bc9cf0
6 changed files with 115 additions and 6 deletions

4
jni/nv_io/build.sh Executable file
View 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
View 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;
}