mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-03 19:42:45 +01:00
Fix a mess up on my part, causing a bunch of unknown events in Linux with the Wiimote. Dolphin sends out packets without the start 0x52 byte. WiiUse checks for this and adds it automatically. Wiimote is still having some problems, trying to figure it out
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3536 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
cbff6dfde3
commit
1f590b8900
36
Externals/WiiUseSrc/Src/events.c
vendored
36
Externals/WiiUseSrc/Src/events.c
vendored
@ -84,29 +84,31 @@ static int state_changed(struct wiimote_t* wm);
|
|||||||
int wiiuse_poll(struct wiimote_t** wm, int wiimotes) {
|
int wiiuse_poll(struct wiimote_t** wm, int wiimotes) {
|
||||||
int evnt = 0;
|
int evnt = 0;
|
||||||
|
|
||||||
#ifndef WIN32
|
#if defined(__APPLE__)
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!wm)
|
int i;
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (i = 0; i < wiimotes; ++i) {
|
if (!wm)
|
||||||
wm[i]->event = WIIUSE_NONE;
|
return 0;
|
||||||
|
|
||||||
if (wiiuse_io_read(wm[i])) {
|
for (i = 0; i < wiimotes; ++i) {
|
||||||
/* propagate the event */
|
wm[i]->event = WIIUSE_NONE;
|
||||||
propagate_event(wm[i], wm[i]->event_buf[1], wm[i]->event_buf+2);
|
|
||||||
evnt += (wm[i]->event != WIIUSE_NONE);
|
if (wiiuse_io_read(wm[i])) {
|
||||||
|
/* propagate the event */
|
||||||
|
propagate_event(wm[i], wm[i]->event_buf[1], wm[i]->event_buf+2);
|
||||||
|
evnt += (wm[i]->event != WIIUSE_NONE);
|
||||||
|
|
||||||
|
/* clear out the event buffer */
|
||||||
|
memset(wm[i]->event_buf, 0, sizeof(wm[i]->event_buf));
|
||||||
|
} else {
|
||||||
|
idle_cycle(wm[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* clear out the event buffer */
|
|
||||||
memset(wm[i]->event_buf, 0, sizeof(wm[i]->event_buf));
|
|
||||||
} else {
|
|
||||||
idle_cycle(wm[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
/*
|
/*
|
||||||
* Windows
|
* Windows, Unix
|
||||||
*/
|
*/
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
113
Externals/WiiUseSrc/Src/io_nix.c
vendored
113
Externals/WiiUseSrc/Src/io_nix.c
vendored
@ -231,9 +231,9 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address) {
|
|||||||
WIIUSE_INFO("Connected to wiimote [id %i].", wm->unid);
|
WIIUSE_INFO("Connected to wiimote [id %i].", wm->unid);
|
||||||
/* do the handshake */
|
/* do the handshake */
|
||||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
|
||||||
wiiuse_handshake(wm, NULL, 0);
|
|
||||||
|
|
||||||
wiiuse_set_report_type(wm);
|
wiiuse_set_report_type(wm);
|
||||||
|
wiiuse_handshake(wm, NULL, 0);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -263,71 +263,78 @@ void wiiuse_disconnect(struct wiimote_t* wm) {
|
|||||||
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) {
|
||||||
|
struct timeval tv;
|
||||||
|
fd_set fds;
|
||||||
|
int r;
|
||||||
|
int i;
|
||||||
if (!wm)
|
if (!wm)
|
||||||
{
|
return 0;
|
||||||
WIIUSE_INFO("Wiimote is Null0x%x\n", wm);
|
|
||||||
|
/* block select() for 1/2000th of a second */
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = 500;
|
||||||
|
|
||||||
|
FD_ZERO(&fds);
|
||||||
|
/* only poll it if it is connected */
|
||||||
|
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED)) {
|
||||||
|
FD_SET(wm->in_sock, &fds);
|
||||||
|
//highest_fd = wm[i]->in_sock;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* nothing to poll */
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (select(wm->in_sock + 1, &fds, NULL, NULL, &tv) == -1) {
|
||||||
|
WIIUSE_ERROR("Unable to select() the wiimote interrupt socket(s).");
|
||||||
|
perror("Error Details");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timeval tv;
|
/* if this wiimote is not connected, skip it */
|
||||||
fd_set fds;
|
if (!WIIMOTE_IS_CONNECTED(wm))
|
||||||
int r;
|
return 0;
|
||||||
int i;
|
|
||||||
if (!wm) return 0;
|
|
||||||
|
|
||||||
/* block select() for 1/2000th of a second */
|
if (FD_ISSET(wm->in_sock, &fds))
|
||||||
tv.tv_sec = 0;
|
{
|
||||||
tv.tv_usec = 500;
|
/* read the pending message into the buffer */
|
||||||
|
r = read(wm->in_sock, wm->event_buf, sizeof(wm->event_buf));
|
||||||
FD_ZERO(&fds);
|
if (r == -1) {
|
||||||
/* only poll it if it is connected */
|
/* error reading data */
|
||||||
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED)) {
|
WIIUSE_ERROR("Receiving wiimote data (id %i).", wm->unid);
|
||||||
FD_SET(wm->in_sock, &fds);
|
|
||||||
//highest_fd = wm[i]->in_sock;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* nothing to poll */
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (select(wm->in_sock + 1, &fds, NULL, NULL, &tv) == -1) {
|
|
||||||
WIIUSE_ERROR("Unable to select() the wiimote interrupt socket(s).");
|
|
||||||
perror("Error Details");
|
perror("Error Details");
|
||||||
|
|
||||||
|
if (errno == ENOTCONN) {
|
||||||
|
/* this can happen if the bluetooth dongle is disconnected */
|
||||||
|
WIIUSE_ERROR("Bluetooth appears to be disconnected. Wiimote unid %i will be disconnected.", wm->unid);
|
||||||
|
wiiuse_disconnect(wm);
|
||||||
|
wm->event = WIIUSE_UNEXPECTED_DISCONNECT;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (!r) {
|
||||||
/* if this wiimote is not connected, skip it */
|
/* remote disconnect */
|
||||||
if (!WIIMOTE_IS_CONNECTED(wm))
|
wiiuse_disconnected(wm);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (FD_ISSET(wm->in_sock, &fds))
|
|
||||||
{
|
|
||||||
/* 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 */
|
|
||||||
WIIUSE_ERROR("Receiving wiimote data (id %i).", wm->unid);
|
|
||||||
perror("Error Details");
|
|
||||||
|
|
||||||
if (errno == ENOTCONN) {
|
|
||||||
/* this can happen if the bluetooth dongle is disconnected */
|
|
||||||
WIIUSE_ERROR("Bluetooth appears to be disconnected. Wiimote unid %i will be disconnected.", wm->unid);
|
|
||||||
wiiuse_disconnect(wm);
|
|
||||||
wm->event = WIIUSE_UNEXPECTED_DISCONNECT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!r) {
|
|
||||||
/* remote disconnect */
|
|
||||||
wiiuse_disconnected(wm);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 1;
|
memcpy(wm->event_buf, &wm->event_buf[1], sizeof(wm->event_buf) - 1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
|
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len)
|
||||||
|
{
|
||||||
|
if(buf[0] != (WM_SET_REPORT | WM_BT_OUTPUT))
|
||||||
|
{
|
||||||
|
// Linux and OSX need this, Windows strips it out
|
||||||
|
// Only packets from Dolphin don't have the start
|
||||||
|
// Wiiuse uses ifdefs to add the first byte without you ever knowing it
|
||||||
|
// Should find out a nice way of doing this, getting windows to stop stripping the packets would be nice
|
||||||
|
memcpy(buf + 1, buf, len - 1);
|
||||||
|
buf[0] = (WM_SET_REPORT | WM_BT_OUTPUT);
|
||||||
|
}
|
||||||
return write(wm->out_sock, buf, len);
|
return write(wm->out_sock, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,10 +148,6 @@ void ReadData()
|
|||||||
if (wiiuse_io_read(m_pWiiMote))
|
if (wiiuse_io_read(m_pWiiMote))
|
||||||
{
|
{
|
||||||
const byte* pBuffer = m_pWiiMote->event_buf;
|
const byte* pBuffer = m_pWiiMote->event_buf;
|
||||||
#ifndef _WIN32
|
|
||||||
// The Linux packets are starting out one spot before the Windows one. This should really be handled in the wiiuse library
|
|
||||||
pBuffer++;
|
|
||||||
#endif
|
|
||||||
// Check if we have a channel (connection) if so save the data...
|
// Check if we have a channel (connection) if so save the data...
|
||||||
if (m_channelID > 0)
|
if (m_channelID > 0)
|
||||||
{
|
{
|
||||||
|
@ -164,10 +164,6 @@ void ReadData()
|
|||||||
if (wiiuse_io_read(m_pWiiMote))
|
if (wiiuse_io_read(m_pWiiMote))
|
||||||
{
|
{
|
||||||
const byte* pBuffer = m_pWiiMote->event_buf;
|
const byte* pBuffer = m_pWiiMote->event_buf;
|
||||||
#ifndef _WIN32
|
|
||||||
// The Linux packets are starting out one spot before the Windows one. This should really be handled in the wiiuse library
|
|
||||||
pBuffer++;
|
|
||||||
#endif
|
|
||||||
// Check if we have a channel (connection) if so save the data...
|
// Check if we have a channel (connection) if so save the data...
|
||||||
if (m_channelID > 0)
|
if (m_channelID > 0)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user