From 6f6ba68ed6d558b64c6db4723d0fa3647d0078e0 Mon Sep 17 00:00:00 2001 From: Lysann Schlegel Date: Sat, 10 Nov 2012 13:28:44 +0100 Subject: [PATCH] rename wiiuse_io_* to wiiuse_os_* --- src/CMakeLists.txt | 10 +++--- src/definitions.h | 2 +- src/{io_platform.h => definitions_os.h} | 43 +++++++++---------------- src/events.c | 4 +-- src/io.c | 20 ++++++------ src/io.h | 2 -- src/os.h | 43 ++++++++++++++++--------- src/{io_mac.m => os_mac.m} | 10 +++--- src/{io_nix.c => os_nix.c} | 16 ++++----- src/{io_win.c => os_win.c} | 10 +++--- src/wiiuse.c | 5 +-- 11 files changed, 83 insertions(+), 82 deletions(-) rename src/{io_platform.h => definitions_os.h} (55%) rename src/{io_mac.m => os_mac.m} (83%) rename src/{io_nix.c => os_nix.c} (93%) rename src/{io_win.c => os_win.c} (95%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aaa9e17..0231444 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/src/definitions.h b/src/definitions.h index f97e81d..527ea00 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -36,7 +36,7 @@ /* this is wiiuse - used to distinguish from third party programs using wiiuse.h */ #include -#include "os.h" +#include "definitions_os.h" /** @addtogroup internal_general */ /** @{ */ diff --git a/src/io_platform.h b/src/definitions_os.h similarity index 55% rename from src/io_platform.h rename to src/definitions_os.h index 167a64c..4ba6e3e 100644 --- a/src/io_platform.h +++ b/src/definitions_os.h @@ -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 + /* 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 */ diff --git a/src/events.c b/src/events.c index 434b453..6378351 100644 --- a/src/events.c +++ b/src/events.c @@ -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 /* 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); diff --git a/src/io.c b/src/io.c index 9871c8f..f43b9d3 100644 --- a/src/io.c +++ b/src/io.c @@ -34,6 +34,8 @@ #include "io.h" #include "ir.h" /* for wiiuse_set_ir_mode */ +#include "os.h" /* for wiiuse_os_* */ + #include /* 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); } diff --git a/src/io.h b/src/io.h index ddf634c..3e8b4ba 100644 --- a/src/io.h +++ b/src/io.h @@ -36,8 +36,6 @@ #include "wiiuse_internal.h" -#include "io_platform.h" // declare functions implemented per platform - #ifdef __cplusplus extern "C" { #endif diff --git a/src/os.h b/src/os.h index 21d9c16..8b0d814 100644 --- a/src/os.h +++ b/src/os.h @@ -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 - /* 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 */ diff --git a/src/io_mac.m b/src/os_mac.m similarity index 83% rename from src/io_mac.m rename to src/os_mac.m index 50d6517..c75740a 100644 --- a/src/io_mac.m +++ b/src/os_mac.m @@ -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; } diff --git a/src/io_nix.c b/src/os_nix.c similarity index 93% rename from src/io_nix.c rename to src/os_nix.c index e10602a..c70bb4d 100644 --- a/src/io_nix.c +++ b/src/os_nix.c @@ -47,9 +47,9 @@ #include /* for close, write */ #include -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); } diff --git a/src/io_win.c b/src/os_win.c similarity index 95% rename from src/io_win.c rename to src/os_win.c index 1892b29..ca1cea6 100644 --- a/src/io_win.c +++ b/src/os_win.c @@ -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; diff --git a/src/wiiuse.c b/src/wiiuse.c index 2b13d29..80dbf10 100644 --- a/src/wiiuse.c +++ b/src/wiiuse.c @@ -37,6 +37,7 @@ #include "wiiuse_internal.h" #include "io.h" /* for wiiuse_handshake, etc */ +#include "os.h" /* for wiiuse_os_* */ #include /* for printf, FILE */ #include /* 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 }