From 732d359c182794df20e78b4e00db4c5bf123dfec Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 8 Dec 2006 06:33:26 +0000 Subject: - laid out new event labeling scheme based more on USB HID rather than Linux input.h. It works on my devices on my Mac OS X. I probably broke Linux support. The scheme is in a new file, hidio_types.c - all event symbols except the vendor-defined usage are generated in hidio_setup(). The symbols for vendor-defined usages are generated when the device's element list is built. - changed macros to work cleanly when compiled on Windows using MinGW gcc - fixed up help file to better represent the state of things (still could be much better) svn path=/trunk/externals/io/hidio/; revision=6718 --- hidio.h | 83 +++++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 31 deletions(-) (limited to 'hidio.h') diff --git a/hidio.h b/hidio.h index 4bb6f18..1b63aba 100644 --- a/hidio.h +++ b/hidio.h @@ -2,21 +2,21 @@ #define _HIDIO_H #include -#ifdef _WINDOWS +#ifdef _WIN32 #include "pthread.h" /* needs pthread library */ #define LOG_DEBUG 7 #define LOG_INFO 6 #define LOG_WARNING 4 -#define LOG_ERR 3 +#define LOG_ERR 3 #define vsnprintf _vsnprintf #else #include #include -#endif +#endif /* _WIN32 */ #ifdef _MSC_VER /* this only applies to Microsoft compilers */ #pragma warning (disable: 4305 4244 4761) -#endif +#endif /* _MSC_VER */ #ifdef __linux__ #include @@ -24,7 +24,7 @@ #ifdef PD #include -#else +#else /* Max */ #include "ext.h" #include "ext_obex.h" #include "commonsyms.h" @@ -37,26 +37,20 @@ typedef void t_clock; #define MAXPDSTRING 512 #define pd_error(x, b) error(b) #define SETSYMBOL SETSYM -#endif - -/* - * this is automatically generated from linux/input.h by - * make-arrays-from-input.h.pl to be the cross-platform event types and codes - */ -#include "input_arrays.h" +#endif /* PD */ #define HIDIO_MAJOR_VERSION 0 #define HIDIO_MINOR_VERSION 0 -/* static char *version = "$Revision: 1.8 $"; */ - -/*------------------------------------------------------------------------------ - * MACRO DEFINES - */ - -#ifndef CLIP -#define CLIP(a, lo, hi) ( (a)>(lo)?( (a)<(hi)?(a):(hi) ):(lo) ) -#endif +/* static char *version = "$Revision: 1.9 $"; */ + +/*------------------------------------------------------------------------------ + * MACRO DEFINES + */ + +#ifndef CLIP +#define CLIP(a, lo, hi) ( (a)>(lo)?( (a)<(hi)?(a):(hi) ):(lo) ) +#endif /* NOT CLIP */ /*------------------------------------------------------------------------------ * GLOBAL DEFINES @@ -96,13 +90,13 @@ typedef struct _hidio t_object x_obj; #ifndef PD void *x_obex; -#endif -#ifdef _WINDOWS - HANDLE x_fd; -#endif +#endif /* PD */ +#ifdef _WIN32 + HANDLE x_fd; +#endif /* _WIN32 */ #ifdef __linux__ - t_int x_fd; -#endif + t_int x_fd; +#endif /* __linux */ void *x_ff_device; short x_device_number; short x_instance; @@ -117,7 +111,7 @@ typedef struct _hidio pthread_mutex_t x_mutex; pthread_cond_t x_requestcondition; pthread_cond_t x_answercondition; - pthread_t x_thread; + pthread_t x_thread; t_int x_priority; } t_hidio; @@ -146,9 +140,9 @@ typedef struct _hid_element __u16 linux_code; #endif /* __linux__ */ #ifdef _WIN32 - /* this stores the UsagePage and UsageID */ + /* this stores the UsagePage and UsageID */ unsigned short usage_page; - unsigned short usage_id; + unsigned short usage_id; #endif /* _WIN32 */ #ifdef __APPLE__ void *pHIDElement; // pRecElement on Mac OS X @@ -212,8 +206,35 @@ t_int hidio_ff_stopall(t_hidio *x); t_int hidio_ff_fftest (t_hidio *x, t_float value); void hidio_ff_print(t_hidio *x); +/*============================================================================== + * event symbols array sizes + *============================================================================== + */ + +#define ABSOLUTE_ARRAY_MAX 16 +#define BUTTON_ARRAY_MAX 128 +#define KEY_ARRAY_MAX 256 +#define LED_ARRAY_MAX 77 +#define PID_ARRAY_MAX 256 +#define RELATIVE_ARRAY_MAX 16 + + +/*============================================================================== + * symbol pointers for pre-generated event symbols + *============================================================================== + */ + +extern t_symbol *ps_absolute, *ps_button, *ps_key, *ps_led, *ps_pid, *ps_relative; +extern t_symbol *absolute_symbols[ABSOLUTE_ARRAY_MAX]; +extern t_symbol *button_symbols[BUTTON_ARRAY_MAX]; +extern t_symbol *key_symbols[KEY_ARRAY_MAX]; +extern t_symbol *led_symbols[LED_ARRAY_MAX]; +extern t_symbol *pid_symbols[PID_ARRAY_MAX]; +extern t_symbol *relative_symbols[RELATIVE_ARRAY_MAX]; +void generate_event_symbols(); +void generate_type_symbols(); -#endif /* #ifndef _HIDIO_H */ +#endif /* NOT _HIDIO_H */ -- cgit v1.2.1