rename wiiuse_io_* to wiiuse_os_*

This commit is contained in:
Lysann Schlegel
2012-11-10 13:28:44 +01:00
parent f1c7a7712b
commit 6f6ba68ed6
11 changed files with 83 additions and 82 deletions

View File

@@ -10,13 +10,13 @@ set(SOURCES
wiiboard.c
classic.h
definitions.h
definitions_os.h
dynamics.h
events.h
guitar_hero_3.h
motion_plus.h
motion_plus.c
io.h
io_platform.h
ir.h
nunchuk.h
os.h
@@ -27,15 +27,15 @@ set(API
wiiuse.h)
if(WIN32)
list(APPEND SOURCES io_win.c)
list(APPEND SOURCES os_win.c)
set(CMAKE_DEBUG_POSTFIX _debug)
elseif(APPLE)
list(APPEND SOURCES io_mac.m)
list(APPEND SOURCES os_mac.m)
# make sure we use the gcc for Objective-C files as well so that the
# sysroot and deployment target arguments are correctly passed to the compiler
SET_SOURCE_FILES_PROPERTIES(io_mac.m PROPERTIES LANGUAGE C)
SET_SOURCE_FILES_PROPERTIES(os_mac.m PROPERTIES LANGUAGE C)
else()
list(APPEND SOURCES io_nix.c)
list(APPEND SOURCES os_nix.c)
endif()
if(MSVC)

View File

@@ -36,7 +36,7 @@
/* this is wiiuse - used to distinguish from third party programs using wiiuse.h */
#include <stdio.h>
#include "os.h"
#include "definitions_os.h"
/** @addtogroup internal_general */
/** @{ */

View File

@@ -26,37 +26,26 @@
*
*/
/**
* @file
* @brief Handles device I/O.
* @brief Operating system related definitions.
*
* This file is an attempt to separate operating system
* dependent functions and choose what should be used
* at compile time.
*/
#ifndef IO_PLATFORM_H_INCLUDED
#define IO_PLATFORM_H_INCLUDED
#ifndef DEFINITIONS_OS_H_INCLUDED
#define DEFINITIONS_OS_H_INCLUDED
#include "wiiuse_internal.h"
#ifdef __cplusplus
extern "C" {
#ifdef _MSC_VER
#include <float.h>
/* windows with visual c */
#define isnan(x) (_isnan(x))
#define isinf(x) (!_finite(x))
/* disable warnings I don't care about */
/*#pragma warning(disable:4273) */ /* inconsistent dll linkage */
#endif
/** @defgroup internal_io Internal: Platform-specific Device I/O */
/** @{ */
void wiiuse_init_platform_fields(struct wiimote_t* wm);
void wiiuse_cleanup_platform_fields(struct wiimote_t* wm);
int wiiuse_io_find(struct wiimote_t** wm, int max_wiimotes, int timeout);
int wiiuse_io_connect(struct wiimote_t** wm, int wiimotes);
void wiiuse_io_disconnect(struct wiimote_t* wm);
int wiiuse_io_read(struct wiimote_t* wm);
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len);
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* IO_PLATFORM_H_INCLUDED */
#endif /* DEFINITIONS_OS_H_INCLUDED */

View File

@@ -44,7 +44,7 @@
#include "nunchuk.h" /* for nunchuk_disconnected, etc */
#include "wiiboard.h" /* for wii_board_disconnected, etc */
#include "motion_plus.h" /* for motion_plus_disconnected, etc */
#include "io.h" /* for wiiuse_io_read on Windows, etc */
#include "io.h" /* for wiiuse_os_read, etc */
#ifndef WIIUSE_WIN32
#include <sys/time.h> /* for timeval */
@@ -178,7 +178,7 @@ int wiiuse_poll(struct wiimote_t** wm, int wiimotes) {
for (i = 0; i < wiimotes; ++i) {
wm[i]->event = WIIUSE_NONE;
if (wiiuse_io_read(wm[i])) {
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);

View File

@@ -34,6 +34,8 @@
#include "io.h"
#include "ir.h" /* for wiiuse_set_ir_mode */
#include "os.h" /* for wiiuse_os_* */
#include <stdlib.h> /* for free, malloc */
/**
@@ -46,7 +48,7 @@
* @return The number of wiimotes found.
*
* @see wiiuse_connect()
* @see wiiuse_io_find()
* @see wiiuse_os_find()
*
* This function will only look for wiimote devices. \n
* When a device is found the address in the structures will be set. \n
@@ -54,12 +56,12 @@
* devices.
*
* This function only delegates to the platform-specific implementation
* wiiuse_io_find.
* wiiuse_os_find.
*
* This function is declared in wiiuse.h
*/
int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
return wiiuse_io_find(wm, max_wiimotes, timeout);
return wiiuse_os_find(wm, max_wiimotes, timeout);
}
/**
@@ -72,19 +74,19 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
*
* @see wiiuse_find()
* @see wiiuse_disconnect()
* @see wiiuse_io_connect()
* @see wiiuse_os_connect()
*
* Connect to a number of wiimotes when the address is already set
* in the wiimote_t structures. These addresses are normally set
* by the wiiuse_find() function, but can also be set manually.
*
* This function only delegates to the platform-specific implementation
* wiiuse_io_connect.
* wiiuse_os_connect.
*
* This function is declared in wiiuse.h
*/
int wiiuse_connect(struct wiimote_t** wm, int wiimotes) {
return wiiuse_io_connect(wm, wiimotes);
return wiiuse_os_connect(wm, wiimotes);
}
/**
@@ -93,17 +95,17 @@ int wiiuse_connect(struct wiimote_t** wm, int wiimotes) {
* @param wm Pointer to a wiimote_t structure.
*
* @see wiiuse_connect()
* @see wiiuse_io_disconnect()
* @see wiiuse_os_disconnect()
*
* Note that this will not free the wiimote structure.
*
* This function only delegates to the platform-specific implementation
* wiiuse_io_disconnect.
* wiiuse_os_disconnect.
*
* This function is declared in wiiuse.h
*/
void wiiuse_disconnect(struct wiimote_t* wm) {
wiiuse_io_disconnect(wm);
wiiuse_os_disconnect(wm);
}

View File

@@ -36,8 +36,6 @@
#include "wiiuse_internal.h"
#include "io_platform.h" // declare functions implemented per platform
#ifdef __cplusplus
extern "C" {
#endif

View File

@@ -26,26 +26,37 @@
*
*/
/**
* @file
* @brief Operating system related definitions.
*
* This file is an attempt to separate operating system
* dependent functions and choose what should be used
* at compile time.
* @brief Handles device I/O.
*/
#ifndef OS_H_INCLUDED
#define OS_H_INCLUDED
#ifndef PLATFORM_H_INCLUDED
#define PLATFORM_H_INCLUDED
#ifdef _MSC_VER
#include <float.h>
/* windows with visual c */
#define isnan(x) (_isnan(x))
#define isinf(x) (!_finite(x))
/* disable warnings I don't care about */
/*#pragma warning(disable:4273) */ /* inconsistent dll linkage */
#include "wiiuse_internal.h"
#ifdef __cplusplus
extern "C" {
#endif
#endif /* OS_H_INCLUDED */
/** @defgroup internal_io Internal: Platform-specific Device I/O */
/** @{ */
void wiiuse_init_platform_fields(struct wiimote_t* wm);
void wiiuse_cleanup_platform_fields(struct wiimote_t* wm);
int wiiuse_os_find(struct wiimote_t** wm, int max_wiimotes, int timeout);
int wiiuse_os_connect(struct wiimote_t** wm, int wiimotes);
void wiiuse_os_disconnect(struct wiimote_t* wm);
int wiiuse_os_read(struct wiimote_t* wm);
int wiiuse_os_write(struct wiimote_t* wm, byte* buf, int len);
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* PLATFORM_H_INCLUDED */

View File

@@ -50,23 +50,23 @@ void wiiuse_cleanup_platform_fields(struct wiimote_t* wm) {
}
int wiiuse_io_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
int wiiuse_os_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
return 0;
}
int wiiuse_io_connect(struct wiimote_t** wm, int wiimotes) {
int wiiuse_os_connect(struct wiimote_t** wm, int wiimotes) {
return 0;
}
void wiiuse_io_disconnect(struct wiimote_t* wm) {
void wiiuse_os_disconnect(struct wiimote_t* wm) {
}
int wiiuse_io_read(struct wiimote_t* wm) {
int wiiuse_os_read(struct wiimote_t* wm) {
return 0;
}
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
int wiiuse_os_write(struct wiimote_t* wm, byte* buf, int len) {
return 0;
}

View File

@@ -47,9 +47,9 @@
#include <unistd.h> /* for close, write */
#include <errno.h>
static int wiiuse_io_connect_single(struct wiimote_t* wm, char* address);
static int wiiuse_os_connect_single(struct wiimote_t* wm, char* address);
int wiiuse_io_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
int wiiuse_os_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
int device_id;
int device_sock;
inquiry_info scan_info_arr[128];
@@ -118,9 +118,9 @@ int wiiuse_io_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
/**
* @see wiiuse_connect()
* @see wiiuse_io_connect_single()
* @see wiiuse_os_connect_single()
*/
int wiiuse_io_connect(struct wiimote_t** wm, int wiimotes) {
int wiiuse_os_connect(struct wiimote_t** wm, int wiimotes) {
int connected = 0;
int i = 0;
@@ -146,7 +146,7 @@ int wiiuse_io_connect(struct wiimote_t** wm, int wiimotes) {
*
* @return 1 on success, 0 on failure
*/
static int wiiuse_io_connect_single(struct wiimote_t* wm, char* address) {
static int wiiuse_os_connect_single(struct wiimote_t* wm, char* address) {
struct sockaddr_l2 addr;
memset(&addr, 0, sizeof (addr));
@@ -213,7 +213,7 @@ static int wiiuse_io_connect_single(struct wiimote_t* wm, char* address) {
return 1;
}
void wiiuse_io_disconnect(struct wiimote_t* wm) {
void wiiuse_os_disconnect(struct wiimote_t* wm) {
if (!wm || WIIMOTE_IS_CONNECTED(wm))
return;
@@ -229,13 +229,13 @@ void wiiuse_io_disconnect(struct wiimote_t* wm) {
}
int wiiuse_io_read(struct wiimote_t* wm) {
int wiiuse_os_read(struct wiimote_t* wm) {
/* not used */
return 0;
}
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
int wiiuse_os_write(struct wiimote_t* wm, byte* buf, int len) {
return write(wm->out_sock, buf, len);
}

View File

@@ -52,7 +52,7 @@ extern "C" {
# endif
#endif
int wiiuse_io_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
int wiiuse_os_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
GUID device_id;
HANDLE dev;
HDEVINFO device_info;
@@ -146,7 +146,7 @@ int wiiuse_io_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
}
int wiiuse_io_connect(struct wiimote_t** wm, int wiimotes) {
int wiiuse_os_connect(struct wiimote_t** wm, int wiimotes) {
int connected = 0;
int i = 0;
@@ -161,7 +161,7 @@ int wiiuse_io_connect(struct wiimote_t** wm, int wiimotes) {
}
void wiiuse_io_disconnect(struct wiimote_t* wm) {
void wiiuse_os_disconnect(struct wiimote_t* wm) {
if (!wm || WIIMOTE_IS_CONNECTED(wm))
return;
@@ -177,7 +177,7 @@ void wiiuse_io_disconnect(struct wiimote_t* wm) {
}
int wiiuse_io_read(struct wiimote_t* wm) {
int wiiuse_os_read(struct wiimote_t* wm) {
DWORD b, r;
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
@@ -217,7 +217,7 @@ int wiiuse_io_read(struct wiimote_t* wm) {
}
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
int wiiuse_os_write(struct wiimote_t* wm, byte* buf, int len) {
DWORD bytes;
int i;

View File

@@ -37,6 +37,7 @@
#include "wiiuse_internal.h"
#include "io.h" /* for wiiuse_handshake, etc */
#include "os.h" /* for wiiuse_os_* */
#include <stdio.h> /* for printf, FILE */
#include <stdlib.h> /* for malloc, free */
@@ -706,9 +707,9 @@ int wiiuse_send(struct wiimote_t* wm, byte report_type, byte* msg, int len) {
#endif
#ifndef WIIUSE_WIN32
return wiiuse_io_write(wm, buf, len+2);
return wiiuse_os_write(wm, buf, len+2);
#else
return wiiuse_io_write(wm, buf, len+1);
return wiiuse_os_write(wm, buf, len+1);
#endif
}