Made wiiuse_io_read work under Linux. still no Wiimote working under linux though, which Im not quite sure why. the mode seems to get set most of the time. Maybe mine is blocking?

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2755 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2009-03-26 03:07:12 +00:00
parent 46d89443a9
commit d7038fea17

View file

@ -33,6 +33,12 @@
#ifndef WIN32 #ifndef WIN32
#include <sys/time.h>
#include <errno.h>
#include <sys/types.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@ -253,12 +259,45 @@ void wiiuse_disconnect(struct wiimote_t* wm) {
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_CONNECTED); WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE); WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
} }
int wiiuse_io_read(struct wiimote_t* wm) { int wiiuse_io_read(struct wiimote_t* wm) {
/* not used */ if (!wm)
{
printf("Wiimote is Null0x%x\n", wm);
return 0; return 0;
} }
/*
* *nix
*/
int r;
int i;
/* read the pending message into the buffer */
r = read(wm->in_sock, wm->event_buf, sizeof(wm->event_buf));
if (r == -1)
{
/* error reading data */
printf("Receiving wiimote data (id %i).", wm->unid);
perror("Error Details");
if (errno == ENOTCONN) {
/* this can happen if the bluetooth dongle is disconnected */
printf("Bluetooth appears to be disconnected. Wiimote unid %i will be disconnected.", wm->unid);
wiiuse_disconnect(wm);
wm->event = WIIUSE_UNEXPECTED_DISCONNECT;
}
return 0;
}
//printf("Size %d, first 4 0x%02X%02X%02X%02X\n",r, wm->event_buf[0],wm->event_buf[1], wm->event_buf[2],wm->event_buf[3]);
if (!r) {
/* remote disconnect */
printf("Wiimote Disconnect\n");
wiiuse_disconnected(wm);
return 0;
}
return 1;
}
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) { int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {