rename wiiuse_io_* to wiiuse_os_*
This commit is contained in:
@@ -10,13 +10,13 @@ set(SOURCES
|
|||||||
wiiboard.c
|
wiiboard.c
|
||||||
classic.h
|
classic.h
|
||||||
definitions.h
|
definitions.h
|
||||||
|
definitions_os.h
|
||||||
dynamics.h
|
dynamics.h
|
||||||
events.h
|
events.h
|
||||||
guitar_hero_3.h
|
guitar_hero_3.h
|
||||||
motion_plus.h
|
motion_plus.h
|
||||||
motion_plus.c
|
motion_plus.c
|
||||||
io.h
|
io.h
|
||||||
io_platform.h
|
|
||||||
ir.h
|
ir.h
|
||||||
nunchuk.h
|
nunchuk.h
|
||||||
os.h
|
os.h
|
||||||
@@ -27,15 +27,15 @@ set(API
|
|||||||
wiiuse.h)
|
wiiuse.h)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND SOURCES io_win.c)
|
list(APPEND SOURCES os_win.c)
|
||||||
set(CMAKE_DEBUG_POSTFIX _debug)
|
set(CMAKE_DEBUG_POSTFIX _debug)
|
||||||
elseif(APPLE)
|
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
|
# 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
|
# 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()
|
else()
|
||||||
list(APPEND SOURCES io_nix.c)
|
list(APPEND SOURCES os_nix.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
/* this is wiiuse - used to distinguish from third party programs using wiiuse.h */
|
/* this is wiiuse - used to distinguish from third party programs using wiiuse.h */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "os.h"
|
#include "definitions_os.h"
|
||||||
/** @addtogroup internal_general */
|
/** @addtogroup internal_general */
|
||||||
/** @{ */
|
/** @{ */
|
||||||
|
|
||||||
|
|||||||
@@ -26,37 +26,26 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @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
|
#ifndef DEFINITIONS_OS_H_INCLUDED
|
||||||
#define IO_PLATFORM_H_INCLUDED
|
#define DEFINITIONS_OS_H_INCLUDED
|
||||||
|
|
||||||
#include "wiiuse_internal.h"
|
#ifdef _MSC_VER
|
||||||
|
#include <float.h>
|
||||||
#ifdef __cplusplus
|
/* windows with visual c */
|
||||||
extern "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
|
#endif
|
||||||
|
|
||||||
|
#endif /* DEFINITIONS_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_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 */
|
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
#include "nunchuk.h" /* for nunchuk_disconnected, etc */
|
#include "nunchuk.h" /* for nunchuk_disconnected, etc */
|
||||||
#include "wiiboard.h" /* for wii_board_disconnected, etc */
|
#include "wiiboard.h" /* for wii_board_disconnected, etc */
|
||||||
#include "motion_plus.h" /* for motion_plus_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
|
#ifndef WIIUSE_WIN32
|
||||||
#include <sys/time.h> /* for timeval */
|
#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) {
|
for (i = 0; i < wiimotes; ++i) {
|
||||||
wm[i]->event = WIIUSE_NONE;
|
wm[i]->event = WIIUSE_NONE;
|
||||||
|
|
||||||
if (wiiuse_io_read(wm[i])) {
|
if (wiiuse_os_read(wm[i])) {
|
||||||
/* propagate the event */
|
/* propagate the event */
|
||||||
propagate_event(wm[i], wm[i]->event_buf[0], wm[i]->event_buf+1);
|
propagate_event(wm[i], wm[i]->event_buf[0], wm[i]->event_buf+1);
|
||||||
evnt += (wm[i]->event != WIIUSE_NONE);
|
evnt += (wm[i]->event != WIIUSE_NONE);
|
||||||
|
|||||||
20
src/io.c
20
src/io.c
@@ -34,6 +34,8 @@
|
|||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "ir.h" /* for wiiuse_set_ir_mode */
|
#include "ir.h" /* for wiiuse_set_ir_mode */
|
||||||
|
|
||||||
|
#include "os.h" /* for wiiuse_os_* */
|
||||||
|
|
||||||
#include <stdlib.h> /* for free, malloc */
|
#include <stdlib.h> /* for free, malloc */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,7 +48,7 @@
|
|||||||
* @return The number of wiimotes found.
|
* @return The number of wiimotes found.
|
||||||
*
|
*
|
||||||
* @see wiiuse_connect()
|
* @see wiiuse_connect()
|
||||||
* @see wiiuse_io_find()
|
* @see wiiuse_os_find()
|
||||||
*
|
*
|
||||||
* This function will only look for wiimote devices. \n
|
* This function will only look for wiimote devices. \n
|
||||||
* When a device is found the address in the structures will be set. \n
|
* When a device is found the address in the structures will be set. \n
|
||||||
@@ -54,12 +56,12 @@
|
|||||||
* devices.
|
* devices.
|
||||||
*
|
*
|
||||||
* This function only delegates to the platform-specific implementation
|
* This function only delegates to the platform-specific implementation
|
||||||
* wiiuse_io_find.
|
* wiiuse_os_find.
|
||||||
*
|
*
|
||||||
* This function is declared in wiiuse.h
|
* This function is declared in wiiuse.h
|
||||||
*/
|
*/
|
||||||
int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
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_find()
|
||||||
* @see wiiuse_disconnect()
|
* @see wiiuse_disconnect()
|
||||||
* @see wiiuse_io_connect()
|
* @see wiiuse_os_connect()
|
||||||
*
|
*
|
||||||
* Connect to a number of wiimotes when the address is already set
|
* Connect to a number of wiimotes when the address is already set
|
||||||
* in the wiimote_t structures. These addresses are normally set
|
* in the wiimote_t structures. These addresses are normally set
|
||||||
* by the wiiuse_find() function, but can also be set manually.
|
* by the wiiuse_find() function, but can also be set manually.
|
||||||
*
|
*
|
||||||
* This function only delegates to the platform-specific implementation
|
* This function only delegates to the platform-specific implementation
|
||||||
* wiiuse_io_connect.
|
* wiiuse_os_connect.
|
||||||
*
|
*
|
||||||
* This function is declared in wiiuse.h
|
* This function is declared in wiiuse.h
|
||||||
*/
|
*/
|
||||||
int wiiuse_connect(struct wiimote_t** wm, int wiimotes) {
|
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.
|
* @param wm Pointer to a wiimote_t structure.
|
||||||
*
|
*
|
||||||
* @see wiiuse_connect()
|
* @see wiiuse_connect()
|
||||||
* @see wiiuse_io_disconnect()
|
* @see wiiuse_os_disconnect()
|
||||||
*
|
*
|
||||||
* Note that this will not free the wiimote structure.
|
* Note that this will not free the wiimote structure.
|
||||||
*
|
*
|
||||||
* This function only delegates to the platform-specific implementation
|
* This function only delegates to the platform-specific implementation
|
||||||
* wiiuse_io_disconnect.
|
* wiiuse_os_disconnect.
|
||||||
*
|
*
|
||||||
* This function is declared in wiiuse.h
|
* This function is declared in wiiuse.h
|
||||||
*/
|
*/
|
||||||
void wiiuse_disconnect(struct wiimote_t* wm) {
|
void wiiuse_disconnect(struct wiimote_t* wm) {
|
||||||
wiiuse_io_disconnect(wm);
|
wiiuse_os_disconnect(wm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
src/io.h
2
src/io.h
@@ -36,8 +36,6 @@
|
|||||||
|
|
||||||
#include "wiiuse_internal.h"
|
#include "wiiuse_internal.h"
|
||||||
|
|
||||||
#include "io_platform.h" // declare functions implemented per platform
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
43
src/os.h
43
src/os.h
@@ -26,26 +26,37 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* @brief Operating system related definitions.
|
* @brief Handles device I/O.
|
||||||
*
|
|
||||||
* This file is an attempt to separate operating system
|
|
||||||
* dependent functions and choose what should be used
|
|
||||||
* at compile time.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OS_H_INCLUDED
|
#ifndef PLATFORM_H_INCLUDED
|
||||||
#define OS_H_INCLUDED
|
#define PLATFORM_H_INCLUDED
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#include "wiiuse_internal.h"
|
||||||
#include <float.h>
|
|
||||||
/* windows with visual c */
|
#ifdef __cplusplus
|
||||||
#define isnan(x) (_isnan(x))
|
extern "C" {
|
||||||
#define isinf(x) (!_finite(x))
|
|
||||||
/* disable warnings I don't care about */
|
|
||||||
/*#pragma warning(disable:4273) */ /* inconsistent dll linkage */
|
|
||||||
#endif
|
#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 */
|
||||||
|
|||||||
@@ -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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wiiuse_io_connect(struct wiimote_t** wm, int wiimotes) {
|
int wiiuse_os_connect(struct wiimote_t** wm, int wiimotes) {
|
||||||
return 0;
|
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;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,9 +47,9 @@
|
|||||||
#include <unistd.h> /* for close, write */
|
#include <unistd.h> /* for close, write */
|
||||||
#include <errno.h>
|
#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_id;
|
||||||
int device_sock;
|
int device_sock;
|
||||||
inquiry_info scan_info_arr[128];
|
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_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 connected = 0;
|
||||||
int i = 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
|
* @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;
|
struct sockaddr_l2 addr;
|
||||||
memset(&addr, 0, sizeof (addr));
|
memset(&addr, 0, sizeof (addr));
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ static int wiiuse_io_connect_single(struct wiimote_t* wm, char* address) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wiiuse_io_disconnect(struct wiimote_t* wm) {
|
void wiiuse_os_disconnect(struct wiimote_t* wm) {
|
||||||
if (!wm || WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || WIIMOTE_IS_CONNECTED(wm))
|
||||||
return;
|
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 */
|
/* not used */
|
||||||
return 0;
|
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);
|
return write(wm->out_sock, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ extern "C" {
|
|||||||
# endif
|
# endif
|
||||||
#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;
|
GUID device_id;
|
||||||
HANDLE dev;
|
HANDLE dev;
|
||||||
HDEVINFO device_info;
|
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 connected = 0;
|
||||||
int i = 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))
|
if (!wm || WIIMOTE_IS_CONNECTED(wm))
|
||||||
return;
|
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;
|
DWORD b, r;
|
||||||
|
|
||||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
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;
|
DWORD bytes;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
#include "wiiuse_internal.h"
|
#include "wiiuse_internal.h"
|
||||||
#include "io.h" /* for wiiuse_handshake, etc */
|
#include "io.h" /* for wiiuse_handshake, etc */
|
||||||
|
#include "os.h" /* for wiiuse_os_* */
|
||||||
|
|
||||||
#include <stdio.h> /* for printf, FILE */
|
#include <stdio.h> /* for printf, FILE */
|
||||||
#include <stdlib.h> /* for malloc, free */
|
#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
|
#endif
|
||||||
|
|
||||||
#ifndef WIIUSE_WIN32
|
#ifndef WIIUSE_WIN32
|
||||||
return wiiuse_io_write(wm, buf, len+2);
|
return wiiuse_os_write(wm, buf, len+2);
|
||||||
#else
|
#else
|
||||||
return wiiuse_io_write(wm, buf, len+1);
|
return wiiuse_os_write(wm, buf, len+1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user