Calibratie toegevoegd aan WiiuseJ
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
|
||||
#define WIIMOTE_PI 3.14159265f
|
||||
|
||||
//#define WITH_WIIUSE_DEBUG
|
||||
#define WITH_WIIUSE_DEBUG
|
||||
|
||||
/* Error output macros */
|
||||
#define WIIUSE_ERROR(fmt, ...) fprintf(stderr, "[ERROR] " fmt "\n", ##__VA_ARGS__)
|
||||
@@ -50,16 +50,16 @@
|
||||
/* Information output macros */
|
||||
#define WIIUSE_INFO(fmt, ...) fprintf(stderr, "[INFO] " fmt "\n", ##__VA_ARGS__)
|
||||
|
||||
#ifdef WITH_WIIUSE_DEBUG
|
||||
#ifdef WIN32
|
||||
#define WIIUSE_DEBUG(fmt, ...) do { \
|
||||
char* file = __FILE__; \
|
||||
int i = strlen(file) - 1; \
|
||||
for (; i && (file[i] != '\\'); --i); \
|
||||
fprintf(stderr, "[DEBUG] %s:%i: " fmt "\n", file+i+1, __LINE__, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
#ifdef WITH_WIIUSE_DEBUG
|
||||
#ifdef WIN32
|
||||
#define WIIUSE_DEBUG(fmt, ...) do { \
|
||||
char* file = __FILE__; \
|
||||
int i = strlen(file) - 1; \
|
||||
for (; i && (file[i] != '\\'); --i); \
|
||||
fprintf(stderr, "[DEBUG] %s:%i: " fmt "\n", file+i+1, __LINE__, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
#else
|
||||
#define WIIUSE_DEBUG(fmt, ...) fprintf(stderr, "[DEBUG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__)
|
||||
#define WIIUSE_DEBUG(fmt, ...) fprintf(stderr, "[DEBUG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__)
|
||||
#endif
|
||||
#else
|
||||
#define WIIUSE_DEBUG(fmt, ...)
|
||||
|
||||
@@ -32,14 +32,14 @@
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <hidsdi.h>
|
||||
#include <setupapi.h>
|
||||
|
||||
|
||||
#include "definitions.h"
|
||||
#include "wiiuse_internal.h"
|
||||
#include "io.h"
|
||||
@@ -176,8 +176,8 @@ int wiiuse_io_read(struct wiimote_t* wm) {
|
||||
|
||||
if (!ReadFile(wm->dev_handle, wm->event_buf, sizeof(wm->event_buf), &b, &wm->hid_overlap)) {
|
||||
/* partial read */
|
||||
b = GetLastError();
|
||||
|
||||
b = GetLastError();
|
||||
|
||||
if ((b == ERROR_HANDLE_EOF) || (b == ERROR_DEVICE_NOT_CONNECTED)) {
|
||||
/* remote disconnect */
|
||||
wiiuse_disconnected(wm);
|
||||
@@ -186,11 +186,11 @@ int wiiuse_io_read(struct wiimote_t* wm) {
|
||||
|
||||
r = WaitForSingleObject(wm->hid_overlap.hEvent, wm->timeout);
|
||||
if (r == WAIT_TIMEOUT) {
|
||||
/* timeout - cancel and continue */
|
||||
|
||||
if (*wm->event_buf)
|
||||
WIIUSE_WARNING("Packet ignored. This may indicate a problem (timeout is %i ms).", wm->timeout);
|
||||
|
||||
/* timeout - cancel and continue */
|
||||
|
||||
if (*wm->event_buf)
|
||||
WIIUSE_WARNING("Packet ignored. This may indicate a problem (timeout is %i ms).", wm->timeout);
|
||||
|
||||
CancelIo(wm->dev_handle);
|
||||
ResetEvent(wm->hid_overlap.hEvent);
|
||||
return 0;
|
||||
@@ -203,25 +203,25 @@ int wiiuse_io_read(struct wiimote_t* wm) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ResetEvent(wm->hid_overlap.hEvent);
|
||||
ResetEvent(wm->hid_overlap.hEvent);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
|
||||
DWORD bytes;
|
||||
int i;
|
||||
|
||||
int i;
|
||||
|
||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
|
||||
switch (wm->stack) {
|
||||
case WIIUSE_STACK_UNKNOWN:
|
||||
{
|
||||
/* try to auto-detect the stack type */
|
||||
if (i = WriteFile(wm->dev_handle, buf, 22, &bytes, &wm->hid_overlap)) {
|
||||
/* bluesoleil will always return 1 here, even if it's not connected */
|
||||
wm->stack = WIIUSE_STACK_BLUESOLEIL;
|
||||
wm->stack = WIIUSE_STACK_BLUESOLEIL;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
1406
cpp/wiiuse/wiiuse.c
1406
cpp/wiiuse/wiiuse.c
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -92,6 +92,7 @@
|
||||
<ClInclude Include="..\wiiusej_WiiUseApi.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\wiiusej_Calibration.c" />
|
||||
<ClCompile Include="..\wiiusej_Speaker.c" />
|
||||
<ClCompile Include="..\wiiusej_WiiUseApi.c" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -29,5 +29,8 @@
|
||||
<ClCompile Include="..\wiiusej_Speaker.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\wiiusej_Calibration.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
21
cpp/wiiusej/wiiusej_Calibration.c
Normal file
21
cpp/wiiusej/wiiusej_Calibration.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#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;
|
||||
}
|
||||
@@ -339,7 +339,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setTimeout
|
||||
(JNIEnv *env, jobject obj, jint id, jshort normalTimeout, jshort expansionTimeout) {
|
||||
wiiuse_set_timeout(wiimotes, nbMaxWiimotes, normalTimeout, expansionTimeout);
|
||||
wiiuse_set_timeout(wiimotes, nbMaxWiimotes, (byte) normalTimeout, (byte) expansionTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
EXPORTS
|
||||
Java_wiiusej_WiiUseApi_connect
|
||||
Java_wiiusej_WiiUseApi_find
|
||||
Java_wiiusej_WiiUseApi_init
|
||||
Java_wiiusej_WiiUseApi_closeConnection
|
||||
Java_wiiusej_WiiUseApi_getUnId
|
||||
Java_wiiusej_WiiUseApi_cleanUp
|
||||
Java_wiiusej_WiiUseApi_activateRumble
|
||||
Java_wiiusej_WiiUseApi_deactivateRumble
|
||||
Java_wiiusej_WiiUseApi_activateIRTracking
|
||||
Java_wiiusej_WiiUseApi_deactivateIRTracking
|
||||
Java_wiiusej_WiiUseApi_activateMotionSensing
|
||||
Java_wiiusej_WiiUseApi_deactivateMotionSensing
|
||||
Java_wiiusej_WiiUseApi_setLeds
|
||||
Java_wiiusej_WiiUseApi_setOrientThreshold
|
||||
Java_wiiusej_WiiUseApi_setAccelThreshold
|
||||
Java_wiiusej_WiiUseApi_setAlphaSmoothing
|
||||
Java_wiiusej_WiiUseApi_reSync
|
||||
Java_wiiusej_WiiUseApi_activateSmoothing
|
||||
Java_wiiusej_WiiUseApi_deactivateSmoothing
|
||||
Java_wiiusej_WiiUseApi_activateContinuous
|
||||
Java_wiiusej_WiiUseApi_deactivateContinuous
|
||||
Java_wiiusej_WiiUseApi_setScreenRatio43
|
||||
Java_wiiusej_WiiUseApi_setScreenRatio169
|
||||
Java_wiiusej_WiiUseApi_setSensorBarAboveScreen
|
||||
Java_wiiusej_WiiUseApi_setSensorBarBelowScreen
|
||||
Java_wiiusej_WiiUseApi_setVirtualScreenResolution
|
||||
Java_wiiusej_WiiUseApi_getStatus
|
||||
Java_wiiusej_WiiUseApi_setTimeout
|
||||
Java_wiiusej_WiiUseApi_setIrSensitivity
|
||||
Java_wiiusej_WiiUseApi_setNunchukOrientationThreshold
|
||||
Java_wiiusej_WiiUseApi_setNunchukAccelerationThreshold
|
||||
Java_wiiusej_WiiUseApi_windowsSetBluetoothStack
|
||||
Java_wiiusej_WiiUseApi_specialPoll
|
||||
@@ -273,44 +273,12 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
|
||||
|
||||
/*
|
||||
* Class: wiiusej_WiiUseApi
|
||||
* Method: activateSpeaker
|
||||
* Signature: (I)V
|
||||
* Method: getCalibration
|
||||
* Signature: (I)[S
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSpeaker
|
||||
JNIEXPORT jshortArray JNICALL Java_wiiusej_WiiUseApi_getCalibration
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
/*
|
||||
* Class: wiiusej_WiiUseApi
|
||||
* Method: deactivateSpeaker
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSpeaker
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
/*
|
||||
* Class: wiiusej_WiiUseApi
|
||||
* Method: setSpeakerVolume
|
||||
* Signature: (IS)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerVolume
|
||||
(JNIEnv *, jobject, jint, jshort);
|
||||
|
||||
/*
|
||||
* Class: wiiusej_WiiUseApi
|
||||
* Method: setSpeakerFrequency
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerFrequency
|
||||
(JNIEnv *, jobject, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: wiiusej_WiiUseApi
|
||||
* Method: streamSpeakerData
|
||||
* Signature: (I[S)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_streamSpeakerData
|
||||
(JNIEnv *, jobject, jint, jshortArray);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user