Calibratie in WiiuseJ gerepareerd.
This commit is contained in:
BIN
lib/wiiuse.lib
BIN
lib/wiiuse.lib
Binary file not shown.
BIN
msvc/WiiUseJ.suo
BIN
msvc/WiiUseJ.suo
Binary file not shown.
@@ -88,12 +88,9 @@
|
|||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\wiiusej_Speaker.h" />
|
|
||||||
<ClInclude Include="..\wiiusej_WiiUseApi.h" />
|
<ClInclude Include="..\wiiusej_WiiUseApi.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\wiiusej_Calibration.c" />
|
|
||||||
<ClCompile Include="..\wiiusej_Speaker.c" />
|
|
||||||
<ClCompile Include="..\wiiusej_WiiUseApi.c" />
|
<ClCompile Include="..\wiiusej_WiiUseApi.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|||||||
@@ -18,19 +18,10 @@
|
|||||||
<ClInclude Include="..\wiiusej_WiiUseApi.h">
|
<ClInclude Include="..\wiiusej_WiiUseApi.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\wiiusej_Speaker.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\wiiusej_WiiUseApi.c">
|
<ClCompile Include="..\wiiusej_WiiUseApi.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\wiiusej_Speaker.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\wiiusej_Calibration.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
@@ -401,7 +401,6 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_windowsSetBluetoothStack
|
|||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
|
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
|
||||||
(JNIEnv *env, jobject obj, jobject gath) {
|
(JNIEnv *env, jobject obj, jobject gath) {
|
||||||
|
|
||||||
/* Variables Declarations */
|
/* Variables Declarations */
|
||||||
int i, a;
|
int i, a;
|
||||||
short leds = 0;
|
short leds = 0;
|
||||||
@@ -410,6 +409,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
|
|||||||
struct nunchuk_t* nc;
|
struct nunchuk_t* nc;
|
||||||
struct guitar_hero_3_t* gh;
|
struct guitar_hero_3_t* gh;
|
||||||
struct classic_ctrl_t* cl;
|
struct classic_ctrl_t* cl;
|
||||||
|
|
||||||
//printf("avant poll, nbMaxwiimotes : %i \n",nbMaxWiimotes);
|
//printf("avant poll, nbMaxwiimotes : %i \n",nbMaxWiimotes);
|
||||||
if (wiiuse_poll(wiimotes, 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);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user