Calibratie toegevoegd aan WiiuseJ

This commit is contained in:
2011-02-15 14:59:52 +00:00
parent efd3e980cb
commit 8aaf572de7
13 changed files with 757 additions and 798 deletions

View File

@@ -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, ...)

View File

@@ -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.

File diff suppressed because it is too large Load Diff