aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2004-10-23 03:40:39 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2004-10-23 03:40:39 +0000
commita31c391dc384912d8eb511feb62a12aae0ce7005 (patch)
tree8323dbe6985690233d2642aea4682d573bdb9e6f
parent9554c20806f8da1482790543f2ec5a3c91b363d0 (diff)
got everything running under GNU/Linux again, time to switch back to MacOS X
svn path=/trunk/externals/hcs/hid/; revision=2144
-rw-r--r--Makefile2
-rw-r--r--doc/hid-help.pd75
-rw-r--r--hid.c22
-rw-r--r--hid.h26
-rw-r--r--hid_linux.c12
-rwxr-xr-xmake-arrays-from-input.h.pl1
6 files changed, 90 insertions, 48 deletions
diff --git a/Makefile b/Makefile
index 9c5bfe5..b26ec6a 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,7 @@ INCLUDE = -I./ -I../../../pd/src -I./HID\ Utilities\ Source
$(CC) $(LDFLAGS) -o $*.pd_darwin *.o
.o.pd_linux:
- ld $(LDFLAGS) -o $*.pd_linux $*.o -lc -lm
+ ld $(LDFLAGS) -o $*.pd_linux *.o -lc -lm
strip --strip-unneeded $*.pd_linux
# rm $*.o
diff --git a/doc/hid-help.pd b/doc/hid-help.pd
index 984036f..45326ab 100644
--- a/doc/hid-help.pd
+++ b/doc/hid-help.pd
@@ -1,25 +1,24 @@
#N canvas 124 73 911 579 10;
-#X msg 382 241 ev_rel rel_x 5 1.09824e+09;
+#X msg 382 241 ev_rel rel_y 2 1.0985e+09;
#X obj 382 220 prepend set;
#X obj 144 386 route rel_x rel_y;
#X floatatom 144 406 5 0 0 0 - - -;
#X floatatom 201 406 5 0 0 0 - - -;
-#X obj 222 255 print;
#X msg 148 77 start;
#X msg 167 96 stop;
#X obj 240 184 hid /dev/input/event0;
#X floatatom 486 360 12 0 0 1 time - -;
#X obj 393 340 unpack s s f f;
-#X msg 264 81 open /dev/input/event1;
-#X msg 256 58 open /dev/input/event0;
-#X msg 280 103 open /dev/input/event2;
-#X msg 292 124 open /dev/input/event3;
-#X msg 304 144 open /dev/input/event4;
+#X msg 248 57 open /dev/input/event1;
+#X msg 240 34 open /dev/input/event0;
+#X msg 264 79 open /dev/input/event2;
+#X msg 276 100 open /dev/input/event3;
+#X msg 288 120 open /dev/input/event4;
#X obj 85 321 route ev_key ev_rel ev_abs;
#X floatatom 203 367 7 0 0 0 - - -;
#X floatatom 261 367 7 0 0 0 - - -;
#X obj 203 346 route abs_x abs_y;
-#X obj 86 81 tgl 35 0 empty empty empty 0 -6 0 8 -24198 -1 -1 0 1;
+#X obj 86 81 tgl 35 0 empty empty empty 0 -6 0 8 -24198 -1 -1 1 1;
#X floatatom 455 377 12 0 0 1 value - -;
#X symbolatom 423 394 10 0 0 1 eventcode - -;
#X symbolatom 393 413 15 0 0 1 eventtype - -;
@@ -46,31 +45,41 @@
#X obj 742 353 ev_ff_status-list;
#X text 710 85 Event Types:;
#X text 710 136 Event Codes:;
+#X msg 304 146 delay 2;
+#X obj 200 278 print INPUT_EVENT;
+#X obj 200 257 spigot;
+#X obj 237 239 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X msg 373 147 delay 200;
#X connect 1 0 0 0;
#X connect 2 0 3 0;
#X connect 2 1 4 0;
-#X connect 6 0 8 0;
-#X connect 7 0 8 0;
-#X connect 8 0 5 0;
-#X connect 8 0 1 0;
-#X connect 8 0 10 0;
-#X connect 8 0 16 0;
-#X connect 8 0 28 0;
-#X connect 10 0 23 0;
-#X connect 10 1 22 0;
-#X connect 10 2 21 0;
-#X connect 10 3 9 0;
-#X connect 11 0 8 0;
-#X connect 12 0 8 0;
-#X connect 13 0 8 0;
-#X connect 14 0 8 0;
-#X connect 15 0 8 0;
-#X connect 16 0 26 0;
-#X connect 16 1 2 0;
-#X connect 16 2 19 0;
-#X connect 19 0 17 0;
-#X connect 19 1 18 0;
-#X connect 20 0 8 0;
-#X connect 26 0 24 0;
-#X connect 26 1 25 0;
-#X connect 26 2 27 0;
+#X connect 5 0 7 0;
+#X connect 6 0 7 0;
+#X connect 7 0 1 0;
+#X connect 7 0 9 0;
+#X connect 7 0 15 0;
+#X connect 7 0 27 0;
+#X connect 7 0 46 0;
+#X connect 9 0 22 0;
+#X connect 9 1 21 0;
+#X connect 9 2 20 0;
+#X connect 9 3 8 0;
+#X connect 10 0 7 0;
+#X connect 11 0 7 0;
+#X connect 12 0 7 0;
+#X connect 13 0 7 0;
+#X connect 14 0 7 0;
+#X connect 15 0 25 0;
+#X connect 15 1 2 0;
+#X connect 15 2 18 0;
+#X connect 18 0 16 0;
+#X connect 18 1 17 0;
+#X connect 19 0 7 0;
+#X connect 25 0 23 0;
+#X connect 25 1 24 0;
+#X connect 25 2 26 0;
+#X connect 44 0 7 0;
+#X connect 46 0 45 0;
+#X connect 47 0 46 1;
+#X connect 48 0 7 0;
diff --git a/hid.c b/hid.c
index c1d47a7..f5dde12 100644
--- a/hid.c
+++ b/hid.c
@@ -26,9 +26,20 @@
#include "hid.h"
#include "input_arrays.h"
+
+/* this should be removed once things are ported to hid_linux.c */
#include "../linuxhid.h"
/*------------------------------------------------------------------------------
+ * LOCAL DEFINES
+ */
+
+#define DEBUG(x)
+//#define DEBUG(x) x
+
+#define DEFAULT_DELAY 300
+
+/*------------------------------------------------------------------------------
* IMPLEMENTATION
*/
@@ -56,6 +67,7 @@ void hid_stop(t_hid* x)
hid_devicelist_refresh(x);
}
+
static t_int hid_close(t_hid *x)
{
DEBUG(post("hid_close"););
@@ -70,6 +82,7 @@ static t_int hid_close(t_hid *x)
return 1;
}
+
static t_int hid_open(t_hid *x, t_symbol *s)
{
DEBUG(post("hid_open"););
@@ -78,7 +91,7 @@ static t_int hid_open(t_hid *x, t_symbol *s)
char *eventTypeName = "";
/* counts for various event types */
t_int synCount,keyCount,relCount,absCount,mscCount,ledCount,sndCount,repCount,ffCount,pwrCount,ff_statusCount;
-#ifdef __gnu_linux__
+#ifdef __linux__
struct input_event hid_input_event;
unsigned long bitmask[EV_MAX][NBITS(KEY_MAX)];
#endif
@@ -92,7 +105,7 @@ static t_int hid_open(t_hid *x, t_symbol *s)
if (s != &s_)
x->x_devname = s;
-#ifdef __gnu_linux__
+#ifdef __linux__
/* open device */
if (x->x_devname)
{
@@ -204,11 +217,12 @@ static t_int hid_open(t_hid *x, t_symbol *s)
post("As I write cross-platform versions, the interface might have to change.");
post("WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING");
post("================================= [hid] =================================\n");
-#endif /* #ifdef __gnu_linux__ */
+#endif /* #ifdef __linux__ */
- return 1;
+ return 1; /* why is this return 1? */
}
+
static t_int hid_read(t_hid *x,int fd)
{
t_atom event_data[5]; /* this should probably be 4, not 5 */
diff --git a/hid.h b/hid.h
index b9d1316..f6993f5 100644
--- a/hid.h
+++ b/hid.h
@@ -5,7 +5,7 @@
#include "hid.h"
-static char *version = "$Revision: 1.2 $";
+static char *version = "$Revision: 1.3 $";
/*------------------------------------------------------------------------------
* CLASS DEF
@@ -28,19 +28,33 @@ typedef struct _hid
/*------------------------------------------------------------------------------
- * FUNCTION PROTOTYPES FOR APPLE HID MANAGER
+ * GLOBALS
*/
+
+char *deviceList[64];
+char *typeList[256];
+char *codeList[256];
+
+/*------------------------------------------------------------------------------
+ * FUNCTION PROTOTYPES FOR DIFFERENT PLATFORMS
+ */
+
+#ifdef __linux__
+void releaseDevices(void);
+void buildDeviceList(void);
+void buildTypeList(void);
+
+#endif
+
+
#ifdef __APPLE__
-void releaseHIDDevices (void);
+void releaseHIDDevices(void);
int prHIDBuildElementList(void);
int prHIDBuildDeviceList(void);
int prHIDGetValue(void);
void PushQueueEvents_RawValue(void);
void PushQueueEvents_CalibratedValue(void);
-//static pascal void IdleTimer(EventLoopTimerRef inTimer, void* userData);
int prHIDReleaseDeviceList(void);
-//static EventLoopTimerUPP GetTimerUPP(void);
-//void callback(void * target, IOReturn result, void * refcon, void * sender);
int prHIDRunEventLoop(void);
int prHIDQueueDevice(void);
int prHIDQueueElement(void);
diff --git a/hid_linux.c b/hid_linux.c
index 94a400b..7f9261e 100644
--- a/hid_linux.c
+++ b/hid_linux.c
@@ -1,15 +1,13 @@
#ifdef __linux__
+
#include <linux/input.h>
+#include <sys/ioctl.h>
#define DEBUG(x)
//#define DEBUG(x) x
-
-
-
-
/*------------------------------------------------------------------------------
* from evtest.c from the ff-utils package
*/
@@ -23,5 +21,11 @@
+/* The application reading the device is supposed to queue all events up to */
+/* the SYN_REPORT event, and then process them, so that a mouse pointer */
+/* will move diagonally instead of following the sides of a rectangle, */
+/* which would be very annoying. */
+
#endif /* #ifdef __linux__ */
+
diff --git a/make-arrays-from-input.h.pl b/make-arrays-from-input.h.pl
index 13e69d9..4030b01 100755
--- a/make-arrays-from-input.h.pl
+++ b/make-arrays-from-input.h.pl
@@ -181,6 +181,7 @@ print(HEADER "char *ev_pwr[1];\n");
printArray("ev_ff_status",@FF_STATUS);
# print array of arrays
+print(HEADER "char **event_names[",$#EV+1,"];\n\n");
print(ARRAYS "char **event_names[",$#EV+1,"] = {");
for($i = 0; $i < $#EV; $i++)
{