From fcfafc0ac3391213eacdee400239f2795fba1b69 Mon Sep 17 00:00:00 2001 From: Rik Veenboer Date: Tue, 15 Feb 2011 17:08:56 +0000 Subject: [PATCH] Calibratie in WiiuseJ gerepareerd. --- lib/wiiuse.lib | Bin 10344 -> 10344 bytes msvc/WiiUseJ.suo | Bin 19968 -> 20992 bytes msvc/WiiUseJ.vcxproj | 3 -- msvc/WiiUseJ.vcxproj.filters | 9 ---- wiiusej_Calibration.c | 21 ---------- wiiusej_Speaker.c | 68 ------------------------------ wiiusej_WiiUseApi.c | 79 ++++++++++++++++++++++++++++++++++- 7 files changed, 78 insertions(+), 102 deletions(-) delete mode 100644 wiiusej_Calibration.c delete mode 100644 wiiusej_Speaker.c diff --git a/lib/wiiuse.lib b/lib/wiiuse.lib index 93409c6339e05df5ad1faf58cac35cf661205275..f477ac86df171d6ad980c60ebba510b1b61f2b42 100644 GIT binary patch delta 982 zcmY+Dzi-n}5XTKwAcm@G>)6k!^Ag)h+z1ebp``&KQdJ0+B9DlrQ8z{;#t1R7*3#`& zg!luXT|g?L>p!{xqQAq?!A|z^eD}AX}Pzw*n@%Xzq%gT z$KQ4a_9}mbJ*D8?Y~}R9_Rh!Izo&9s!Pjb~bg=zk?KLcTP4M0Ch2H{?6qme~DE8C^ z;{i|A4aRuzBOjz%!NsnF)P4UZQ#jo0I5q}_mSs)Ay6?iF-{RlD)W~+Jb}hG6@L7|~ zR!v-(nw%3VYm@Bp+{(Dmx17Me+2>v$K3PDr-Jr)Z9wc=cq?(AVeuoKM;8RR}%6c^) z5;fF9aoTxYQ=2s_RvF%(abUU;jVEn1Bx%$jj}MI#Qw48Zl+%EZ9uWz=iNXRgjH;8k zQ`Zp6DqE1A)di$*IOpQx9;PzBgD3H=!XA8#KgUS(IH+Z45(3lV(ToQxp>)6ib0*Xw zF+?3Z^h*K!ZVAHYc(*P2{5E#m@;1<<)}ca|JH>-F+1T<$M_L*wMa3p6!l==dg2hCl u*!fu^&is7-Byy=3wKjj;H!>z|H2F2)6k!^Ag)h+^8T*hlXE5q^b}sMII3g78@fHV}zJkYw7kX zs`vvyT|g?L%w=Hc!URGBIv^MUiGg?5JJ;Eg%jf&!-g`Mr57S&%2A2n`E0Ed#%d3%n z^lc}z*ZCvtDFtumYbW=!oe%SWPZYReIMW z-w?{GT9BUBC8TsXXX5f6rZT>RC-IHa9(;^HCrI-+sAXsp0@LBqoCj;6bie>}Ce$G@ zL=!s!6HqfNeqe2&Y<%2cZ*z$Q#S{f-u#U?7ksPT+~)kLD$ t`B@^){Cxf-a;X@#v3S%sGA3O#`8DIgwm!Zuy7z-cxhvH0|7O_l{|D$r5@i4Y diff --git a/msvc/WiiUseJ.suo b/msvc/WiiUseJ.suo index 1032800f8d61a04d593b70d4a02625513febd4bb..e8c9e85ac2c7b659f5f9f9266c7634c482249371 100644 GIT binary patch delta 447 zcmZpe!`QHdal-^AR&@pj2DQz-OxcW+SaSFlZ2oZ2@a$%_Aa4ywq`}HS_22*h|JMOI>wy@=-Uy^OLD^e? z^i~jiW1u$UCYuIMnW|(4D~1?`QifuNRE8oT83QCU8M1+N@nl7D|H(PdJe+zA84Npf zo3-;dxt(B!SnJ8dIJrtoe)0x0fyoK1f{ZgJGdfpKc5{&uEnp~MX!(_JM^V;*0EqxHka#yO6|`OqDqFfqX+C2HC>88OYc)`JtEh zWEbB(j8kAP6>$9+af@L+7t7?`Gw*tq_nw$s;35L_5ZmMfEAT`0e%!XM T - - - diff --git a/msvc/WiiUseJ.vcxproj.filters b/msvc/WiiUseJ.vcxproj.filters index 380ac77..5bb53f7 100644 --- a/msvc/WiiUseJ.vcxproj.filters +++ b/msvc/WiiUseJ.vcxproj.filters @@ -18,19 +18,10 @@ Header Files - - Header Files - Source Files - - Source Files - - - Source Files - \ No newline at end of file diff --git a/wiiusej_Calibration.c b/wiiusej_Calibration.c deleted file mode 100644 index 2456fee..0000000 --- a/wiiusej_Calibration.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "wiiusej_WiiUseApi.h" -#include "wiiuse.h" - -static wiimote** wiimotes; -static int nbMaxWiimotes; - - -JNIEXPORT jshortArray JNICALL Java_wiiusej_WiiUseApi_getCalibration -(JNIEnv *env, jobject obj, jint id) { - struct wiimote_t* wm = wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id); - const accel_t* accel = &wm->accel_calib; - const vec3b_t* zero = &accel->cal_zero; - const vec3b_t* g = &accel->cal_g; - short calibration[] = { - zero->x, zero->y, zero->z, - g->x, g->y, g->z}; - int size = 6; - jshortArray jShorts = (*env)->NewShortArray(env, size); - (*env)->SetShortArrayRegion(env, jShorts, 0, size, calibration); - return jShorts; -} \ No newline at end of file diff --git a/wiiusej_Speaker.c b/wiiusej_Speaker.c deleted file mode 100644 index c795649..0000000 --- a/wiiusej_Speaker.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "wiiusej_WiiUseApi.h" -#include "speaker.h" -#include "wiiuse.h" - -static wiimote** wiimotes; -static int nbMaxWiimotes; - -/* -void test(struct wiimote_t* wm) { - int i; - byte data[20] = { - 0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3, - 0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3}; - wiiuse_speaker_activate(wm); - for (i = 0; i < 50; ++i) { - wiiuse_speaker_data(wm, data); - } - wiiuse_speaker_deactivate(wm); -}*/ - -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSpeaker -(JNIEnv *env, jobject obj, jint id) { - wiiuse_speaker_activate(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id)); -} - -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSpeaker -(JNIEnv *env, jobject obj, jint id) { - wiiuse_speaker_deactivate(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id)); -} -/* -void testen(struct wiimote_t* wm, unsigned short freq) { - if (freq > 0x0000) { - cfg[2] = freq & 0x00ff; - cfg[3] = (freq & 0xff00) >> 8; - } - printf("unaangepast %d\n", freq); - printf("speaker 0x%02x%02x\n", cfg[2], cfg[3]); - fflush(stdout); - wiiuse_write_data(wm, WM_REG_SPEAKER, cfg, 9); -}*/ - - -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerFrequency -(JNIEnv *env, jobject obj, jint id, jint freq) { - wiiuse_speaker_frequency(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), (unsigned short) freq); - //short a = ((short) freq) & 0xffff; - //printf("jni %d %d\n", freq, a); - //fflush(stdout); - //testen(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), (unsigned short) freq); -} - -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerVolume -(JNIEnv *env, jobject obj, jint id, jshort vol) { - wiiuse_speaker_frequency(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), vol); -} - - -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_streamSpeakerData -(JNIEnv *env, jobject obj, jint id, jshortArray sArray) { - int i = 0; - jshort *jShorts = (*env)->GetShortArrayElements(env, sArray, JNI_FALSE); - byte data[sizeof(jShorts)]; - for (i = 0; i < sizeof(jShorts); ++i) { - data[i] = (byte) jShorts[i]; - } - wiiuse_speaker_data(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), data); - (*env)->ReleaseShortArrayElements(env, sArray, jShorts, JNI_FALSE); -} \ No newline at end of file diff --git a/wiiusej_WiiUseApi.c b/wiiusej_WiiUseApi.c index d5215ae..9c2913e 100644 --- a/wiiusej_WiiUseApi.c +++ b/wiiusej_WiiUseApi.c @@ -401,7 +401,6 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_windowsSetBluetoothStack */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll (JNIEnv *env, jobject obj, jobject gath) { - /* Variables Declarations */ int i, a; short leds = 0; @@ -410,6 +409,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll struct nunchuk_t* nc; struct guitar_hero_3_t* gh; struct classic_ctrl_t* cl; + //printf("avant poll, nbMaxwiimotes : %i \n",nbMaxWiimotes); if (wiiuse_poll(wiimotes, nbMaxWiimotes)) { /* @@ -668,4 +668,81 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll } } } +} + +JNIEXPORT jshortArray JNICALL Java_wiiusej_WiiUseApi_getCalibration +(JNIEnv *env, jobject obj, jint id) { + struct wiimote_t wm = *wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id); + jshort calibration[6] = { + wm.accel_calib.cal_zero.x, + wm.accel_calib.cal_zero.y, + wm.accel_calib.cal_zero.z, + wm.accel_calib.cal_g.x, + wm.accel_calib.cal_g.y, + wm.accel_calib.cal_g.z}; + jshortArray jShorts = (*env)->NewShortArray(env, 6); + (*env)->SetShortArrayRegion(env, jShorts, 0, 6, calibration); + return jShorts; +} + +#include "speaker.h" +/* +void test(struct wiimote_t* wm) { + int i; + byte data[20] = { + 0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3, + 0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3}; + wiiuse_speaker_activate(wm); + for (i = 0; i < 50; ++i) { + wiiuse_speaker_data(wm, data); + } + wiiuse_speaker_deactivate(wm); +}*/ + +JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSpeaker +(JNIEnv *env, jobject obj, jint id) { + wiiuse_speaker_activate(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id)); +} + +JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSpeaker +(JNIEnv *env, jobject obj, jint id) { + wiiuse_speaker_deactivate(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id)); +} +/* +void testen(struct wiimote_t* wm, unsigned short freq) { + if (freq > 0x0000) { + cfg[2] = freq & 0x00ff; + cfg[3] = (freq & 0xff00) >> 8; + } + printf("unaangepast %d\n", freq); + printf("speaker 0x%02x%02x\n", cfg[2], cfg[3]); + fflush(stdout); + wiiuse_write_data(wm, WM_REG_SPEAKER, cfg, 9); +}*/ + + +JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerFrequency +(JNIEnv *env, jobject obj, jint id, jint freq) { + wiiuse_speaker_frequency(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), (unsigned short) freq); + //short a = ((short) freq) & 0xffff; + //printf("jni %d %d\n", freq, a); + //fflush(stdout); + //testen(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), (unsigned short) freq); +} + +JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerVolume +(JNIEnv *env, jobject obj, jint id, jshort vol) { + wiiuse_speaker_frequency(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), vol); +} + +JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_streamSpeakerData +(JNIEnv *env, jobject obj, jint id, jshortArray sArray) { + int i = 0; + jshort *jShorts = (*env)->GetShortArrayElements(env, sArray, JNI_FALSE); + byte data[sizeof(jShorts)]; + for (i = 0; i < sizeof(jShorts); ++i) { + data[i] = (byte) jShorts[i]; + } + wiiuse_speaker_data(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), data); + (*env)->ReleaseShortArrayElements(env, sArray, jShorts, JNI_FALSE); } \ No newline at end of file