Add a wiiuse_millisleep function.

This commit is contained in:
Ryan Pavlik
2011-09-06 13:37:44 -05:00
parent 3e9f9a8f7e
commit 9cc64c51b1
3 changed files with 59 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ set(SOURCES
ir.h
nunchuk.h
os.h
util.c
wiiuse_internal.h
wiiboard.h)
set(API

49
src/util.c Normal file
View File

@@ -0,0 +1,49 @@
/*
* wiiuse
*
* Copyright 2011 Iowa State University Virtual Reality Applications Center
*
* This file is part of wiiuse.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Provides platform-specific utility functions.
*/
#include "wiiuse_internal.h"
#ifdef WIIUSE_WIN32
#include <windows.h>
void wiiuse_millisleep(int durationMilliseconds) {
Sleep(durationMilliseconds);
}
#else /* not win32 - assuming posix */
#include <unistd.h> // for usleep
void wiiuse_millisleep(int durationMilliseconds) {
usleep(durationMilliseconds * 1000);
}
#endif /* ifdef WIIUSE_WIN32 */

View File

@@ -248,6 +248,15 @@ extern "C" {
#endif
/* not part of the api */
/** @brief Cross-platform call to sleep for at least the specified number
* of milliseconds.
*
* Use instead of Sleep(), usleep(), or similar functions.
* Defined in util.c
*/
void wiiuse_millisleep(int durationMilliseconds);
int wiiuse_set_report_type(struct wiimote_t* wm);
void wiiuse_send_next_pending_read_request(struct wiimote_t* wm);
int wiiuse_send(struct wiimote_t* wm, byte report_type, byte* msg, int len);