From 90c9041976723a669b02deffa75853a85c0343cb Mon Sep 17 00:00:00 2001 From: Olaf Matthes Date: Sun, 3 Dec 2006 18:17:36 +0000 Subject: added some #defines and #ifdefs in order for code to compile in Windows svn path=/trunk/externals/io/hidio/; revision=6604 --- hidio.c | 24 +++++++++++++++--------- hidio.h | 15 ++++++++++++--- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/hidio.c b/hidio.c index a06e9ba..8562b0c 100644 --- a/hidio.c +++ b/hidio.c @@ -2,6 +2,7 @@ /* */ /* interface to native HID (Human Interface Devices) API */ /* Written by Hans-Christoph Steiner */ +/* Max/MSP port by Olaf Matthes */ /* */ /* Copyright (c) 2004-2006 Hans-Christoph Steiner */ /* */ @@ -22,12 +23,16 @@ /* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* */ /* --------------------------------------------------------------------------*/ - + +#ifdef _WINDOWS +/* any Windows specific includes go in here */ +#else #include -#include -#include -#include -#include +#include +#endif +#include +#include +#include #include "hidio.h" @@ -83,14 +88,15 @@ static void hidio_open(t_hidio *x, t_symbol *s, int argc, t_atom *argv); void debug_print(t_int message_debug_level, const char *fmt, ...) { if(message_debug_level <= global_debug_level) - { + { char buf[MAXPDSTRING]; va_list ap; //t_int arg[8]; va_start(ap, fmt); vsnprintf(buf, MAXPDSTRING-1, fmt, ap); post(buf); - va_end(ap); + va_end(ap); + } } @@ -384,8 +390,8 @@ t_int hidio_close(t_hidio *x) */ static void hidio_open(t_hidio *x, t_symbol *s, int argc, t_atom *argv) { + short device_number; debug_print(LOG_DEBUG,"hid_%s",s->s_name); - short device_number; pthread_mutex_lock(&x->x_mutex); device_number = get_device_number_from_arguments(argc, argv); @@ -830,7 +836,7 @@ int main() hidio_class = c; finder_addclass("Devices", "hidio"); - post("hidio: © 2006 by Olaf Matthes"); + post("hidio: © 2006 by Hans-Christoph Steiner & Olaf Matthes"); /* pre-generate often used symbols */ ps_open = gensym("open"); diff --git a/hidio.h b/hidio.h index eab0cf0..793de81 100644 --- a/hidio.h +++ b/hidio.h @@ -1,9 +1,18 @@ #ifndef _HIDIO_H #define _HIDIO_H -#include +#include +#ifdef _WINDOWS +#include "pthread.h" /* needs pthread library */ +#define LOG_DEBUG 7 +#define LOG_INFO 6 +#define LOG_WARNING 4 +#define vsnprintf _vsnprintf +#pragma warning (disable: 4305 4244 4761) +#else #include -#include +#include +#endif #ifdef __linux__ #include @@ -35,7 +44,7 @@ typedef void t_clock; #define HIDIO_MAJOR_VERSION 0 #define HIDIO_MINOR_VERSION 0 -/* static char *version = "$Revision: 1.4 $"; */ +/* static char *version = "$Revision: 1.5 $"; */ /*------------------------------------------------------------------------------ * GLOBAL DEFINES -- cgit v1.2.1