/* * acquire_Glove5DT.cpp * * Created on: 14 Apr 2010 * Author: Michael Lones */ #include #include "acquire_Glove5DT.h" #include #include "fglove.h" fdGlove *glove; unsigned short *gloveData; int numSensors; /* * Class: barnsley_acquire_Glove5DT * Method: fdOpen * Signature: (Ljava/lang/String;)I */ JNIEXPORT jint JNICALL Java_barnsley_acquire_Glove5DT_fdOpen (JNIEnv *env, jclass cls, jstring port) { const char *port_cstr = env->GetStringUTFChars(port, 0); glove = fdOpen(const_cast(port_cstr)); env->ReleaseStringUTFChars(port, port_cstr); if(glove==NULL) return -1; // make data buffer numSensors = fdGetNumSensors(glove); gloveData = new unsigned short[numSensors]; return 0; } /* * Class: barnsley_acquire_Glove5DT * Method: fdClose * Signature: ()I */ JNIEXPORT jint JNICALL Java_barnsley_acquire_Glove5DT_fdClose (JNIEnv *env, jclass cls) { fdClose(glove); } /* * Class: barnsley_acquire_Glove5DT * Method: fdGetNumSensors * Signature: ()I */ JNIEXPORT jint JNICALL Java_barnsley_acquire_Glove5DT_fdGetNumSensors (JNIEnv *env , jclass cls) { return numSensors; } /* * Class: barnsley_acquire_Glove5DT * Method: fdGetSensorRawAll * Signature: ([I)V */ JNIEXPORT void JNICALL Java_barnsley_acquire_Glove5DT_fdGetSensorRawAll (JNIEnv *env, jclass cls, jintArray data) { fdGetSensorRawAll(glove, gloveData); env->SetIntArrayRegion(data, 0, numSensors, (const jint*)gloveData); } /* * Class: barnsley_acquire_Glove5DT * Method: fdNewData * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_barnsley_acquire_Glove5DT_fdNewData (JNIEnv *env, jclass cls) { return fdNewData(glove); }