added infos on IR event

motion sensing event (raw acceleration)
and support for more wiiuse functions

git-svn-id: http://wiiusej.googlecode.com/svn/trunk@74 ae48ae66-6a45-0410-b38e-211266189506
This commit is contained in:
guilhem.duche
2008-03-08 01:05:35 +00:00
parent 5946dabcc5
commit f6b653eab9
3 changed files with 144 additions and 34 deletions

View File

@@ -220,7 +220,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAccelThreshold
* @param id id of the wiimote concerned * @param id id of the wiimote concerned
* @param value alpha smoothing value * @param value alpha smoothing value
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSmoothAlpha JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAlphaSmoothing
(JNIEnv *env, jobject obj, jint id, jfloat val) { (JNIEnv *env, jobject obj, jint id, jfloat val) {
wiiuse_set_smooth_alpha(wiimotes[id-1], val); wiiuse_set_smooth_alpha(wiimotes[id-1], val);
} }
@@ -273,6 +273,55 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous
wiiuse_set_flags(wiimotes[id-1], 0, WIIUSE_CONTINUOUS); wiiuse_set_flags(wiimotes[id-1], 0, WIIUSE_CONTINUOUS);
} }
/**
* Notify wiiuse that your screen has an aspect ratio of 4/3.
* @param id the id of the wiimote concerned
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio43
(JNIEnv *env, jobject obj, jint id) {
wiiuse_set_aspect_ratio(wiimotes[id-1], WIIUSE_ASPECT_4_3);
}
/**
* Notify wiiuse that your screen has an aspect ratio of 16/9.
* @param id the id of the wiimote concerned
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio169
(JNIEnv *env, jobject obj, jint id) {
wiiuse_set_aspect_ratio(wiimotes[id-1], WIIUSE_ASPECT_4_3);
}
/**
* Notify wiiuse that the sensor bar is above your screen.
* @param id the id of the wiimote concerned
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarAboveScreen
(JNIEnv *env, jobject obj, jint id) {
wiiuse_set_ir_position(wiimotes[id-1], WIIUSE_IR_ABOVE);
}
/**
* Notify wiiuse that the sensor bar is below your screen.
* @param id the id of the wiimote concerned
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarBelowScreen
(JNIEnv *env, jobject obj, jint id) {
wiiuse_set_ir_position(wiimotes[id-1], WIIUSE_IR_BELOW);
}
/**
* Set virtual screen resolution. It is used to automatically
* compute the position of a cursor on this virtual screen
* using the sensor bar. These results come in the IREvent.
* @param id the id of the wiimote concerned
* @param x x resolution.
* @param y y resolution.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setVirtualScreenResolution
(JNIEnv *env, jobject obj, jint id, jint x, jint y) {
wiiuse_set_ir_vres(wiimotes[id-1], x, y);
}
/** /**
* Get status from the wiimotes and send it through call backs. * Get status from the wiimotes and send it through call backs.
* *
@@ -319,8 +368,21 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
*/ */
if (WIIUSE_USING_IR(wiimotes[i])) { if (WIIUSE_USING_IR(wiimotes[i])) {
int a = 0; int a = 0;
mid = (*env)->GetMethodID(env, cls, "prepareIRevent",
"(IIIIIIIIISS)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid,
wiimotes[i]->ir.x, wiimotes[i]->ir.y, wiimotes[i]->ir.z,
wiimotes[i]->ir.ax, wiimotes[i]->ir.ay,
wiimotes[i]->ir.vres[0], wiimotes[i]->ir.vres[1],
wiimotes[i]->ir.offset[0], wiimotes[i]->ir.offset[1],
wiimotes[i]->ir.pos, wiimotes[i]->ir.aspect);
mid = (*env)->GetMethodID(env, cls, "addIRPointToPreparedWiiMoteEvent", mid = (*env)->GetMethodID(env, cls, "addIRPointToPreparedWiiMoteEvent",
"(II)V"); "(IISSS)V");
if (mid == 0) { if (mid == 0) {
return; return;
} }
@@ -329,7 +391,9 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
/* check if the source is visible */ /* check if the source is visible */
if (wiimotes[i]->ir.dot[a].visible) { if (wiimotes[i]->ir.dot[a].visible) {
(*env)->CallVoidMethod(env, gath, mid, (*env)->CallVoidMethod(env, gath, mid,
wiimotes[i]->ir.dot[a].rx, wiimotes[i]->ir.dot[a].ry); wiimotes[i]->ir.dot[a].x, wiimotes[i]->ir.dot[a].y,
wiimotes[i]->ir.dot[a].rx, wiimotes[i]->ir.dot[a].ry,
wiimotes[i]->ir.dot[a].size);
} }
} }
} }
@@ -338,13 +402,14 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
if (WIIUSE_USING_ACC(wiimotes[i])) { if (WIIUSE_USING_ACC(wiimotes[i])) {
/* set orientation and gravity force */ /* set orientation and gravity force */
mid = (*env)->GetMethodID(env, cls, mid = (*env)->GetMethodID(env, cls,
"addMotionSensingValues", "(FFFFFF)V"); "addMotionSensingValues", "(FFFFFFSSS)V");
if (mid == 0) { if (mid == 0) {
return; return;
} }
(*env)->CallVoidMethod(env, gath, mid, (*env)->CallVoidMethod(env, gath, mid,
wiimotes[i]->orient.roll, wiimotes[i]->orient.pitch, wiimotes[i]->orient.yaw, wiimotes[i]->orient.roll, wiimotes[i]->orient.pitch, wiimotes[i]->orient.yaw,
wiimotes[i]->gforce.x, wiimotes[i]->gforce.y, wiimotes[i]->gforce.z); wiimotes[i]->gforce.x, wiimotes[i]->gforce.y, wiimotes[i]->gforce.z,
wiimotes[i]->accel.x, wiimotes[i]->accel.y, wiimotes[i]->accel.z);
} }
/* add generic event to java object used to gather events in c environment */ /* add generic event to java object used to gather events in c environment */

View File

@@ -11,7 +11,7 @@ Java_wiiusej_WiiUseApi_deactivateMotionSensing
Java_wiiusej_WiiUseApi_setLeds Java_wiiusej_WiiUseApi_setLeds
Java_wiiusej_WiiUseApi_setOrientThreshold Java_wiiusej_WiiUseApi_setOrientThreshold
Java_wiiusej_WiiUseApi_setAccelThreshold Java_wiiusej_WiiUseApi_setAccelThreshold
Java_wiiusej_WiiUseApi_setSmoothAlpha Java_wiiusej_WiiUseApi_setAlphaSmoothing
Java_wiiusej_WiiUseApi_reSync Java_wiiusej_WiiUseApi_reSync
Java_wiiusej_WiiUseApi_activateSmoothing Java_wiiusej_WiiUseApi_activateSmoothing
Java_wiiusej_WiiUseApi_deactivateSmoothing Java_wiiusej_WiiUseApi_deactivateSmoothing
@@ -20,3 +20,8 @@ Java_wiiusej_WiiUseApi_deactivateContinuous
Java_wiiusej_WiiUseApi_deactivateMotionSensing Java_wiiusej_WiiUseApi_deactivateMotionSensing
Java_wiiusej_WiiUseApi_getStatus Java_wiiusej_WiiUseApi_getStatus
Java_wiiusej_WiiUseApi_specialPoll Java_wiiusej_WiiUseApi_specialPoll
Java_wiiusej_WiiUseApi_setScreenRatio43
Java_wiiusej_WiiUseApi_setScreenRatio169
Java_wiiusej_WiiUseApi_setSensorBarAboveScreen
Java_wiiusej_WiiUseApi_setSensorBarBelowScreen
Java_wiiusej_WiiUseApi_setVirtualScreenResolution

View File

@@ -151,6 +151,46 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateContinuous
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setScreenRatio43
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio43
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setScreenRatio169
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio169
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setSensorBarAboveScreen
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarAboveScreen
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setSensorBarBelowScreen
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarBelowScreen
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setVirtualScreenResolution
* Signature: (III)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setVirtualScreenResolution
(JNIEnv *, jobject, jint, jint, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: getStatus * Method: getStatus