make wiimote_poll a platform-specific function, move implementations to os_*.c/os_mac.m
This commit is contained in:
26
src/os_win.c
26
src/os_win.c
@@ -33,6 +33,8 @@
|
||||
|
||||
|
||||
#include "io.h"
|
||||
#include "events.h"
|
||||
#include "os.h"
|
||||
|
||||
#ifdef WIIUSE_WIN32
|
||||
#include <stdlib.h>
|
||||
@@ -177,6 +179,30 @@ void wiiuse_os_disconnect(struct wiimote_t* wm) {
|
||||
}
|
||||
|
||||
|
||||
int wiiuse_os_poll(struct wiimote_t** wm, int wiimotes) {
|
||||
int i;
|
||||
int evnt = 0;
|
||||
|
||||
if (!wm) return 0;
|
||||
|
||||
for (i = 0; i < wiimotes; ++i) {
|
||||
wm[i]->event = WIIUSE_NONE;
|
||||
|
||||
if (wiiuse_os_read(wm[i])) {
|
||||
/* propagate the event */
|
||||
propagate_event(wm[i], wm[i]->event_buf[0], wm[i]->event_buf+1);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
return evnt;
|
||||
}
|
||||
|
||||
int wiiuse_os_read(struct wiimote_t* wm) {
|
||||
DWORD b, r;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user