aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linuxevent.c32
-rw-r--r--linuxhid.h3
-rw-r--r--linuxjoystick.c32
-rw-r--r--linuxmouse.c18
4 files changed, 44 insertions, 41 deletions
diff --git a/linuxevent.c b/linuxevent.c
index fcd53a5..1ea0305 100644
--- a/linuxevent.c
+++ b/linuxevent.c
@@ -2,7 +2,7 @@
#define LINUXEVENT_DEVICE "/dev/input/event0"
-static char *version = "$Revision: 1.6 $";
+static char *version = "$Revision: 1.7 $";
/*------------------------------------------------------------------------------
* CLASS DEF
@@ -14,9 +14,9 @@ typedef struct _linuxevent {
t_int x_fd;
t_symbol *x_devname;
t_clock *x_clock;
- int read_ok;
- int started;
- int x_delaytime;
+ int x_read_ok;
+ int x_started;
+ int x_delay;
#ifdef __gnu_linux__
struct input_event x_input_event;
#endif
@@ -33,10 +33,10 @@ typedef struct _linuxevent {
void linuxevent_stop(t_linuxevent* x) {
DEBUG(post("linuxevent_stop"););
- if (x->x_fd >= 0 && x->started) {
+ if (x->x_fd >= 0 && x->x_started) {
clock_unset(x->x_clock);
post("linuxevent: polling stopped");
- x->started = 0;
+ x->x_started = 0;
}
}
@@ -171,8 +171,8 @@ static int linuxevent_read(t_linuxevent *x,int fd) {
}
#endif
- if (x->started) {
- clock_delay(x->x_clock, x->x_delaytime);
+ if (x->x_started) {
+ clock_delay(x->x_clock, x->x_delay);
}
return 1;
@@ -189,19 +189,19 @@ void linuxevent_delay(t_linuxevent* x, t_float f) {
/* if the user sets the delay less than zero, reset to default */
if ( f > 0 ) {
- x->x_delaytime = (int)f;
+ x->x_delay = (int)f;
} else {
- x->x_delaytime = 5;
+ x->x_delay = DEFAULT_DELAY;
}
}
void linuxevent_start(t_linuxevent* x) {
DEBUG(post("linuxevent_start"););
- if (x->x_fd >= 0 && !x->started) {
- clock_delay(x->x_clock, 5);
+ if (x->x_fd >= 0 && !x->x_started) {
+ clock_delay(x->x_clock, DEFAULT_DELAY);
post("linuxevent: polling started");
- x->started = 1;
+ x->x_started = 1;
} else {
post("You need to set a input device (i.e /dev/input/event0)");
}
@@ -233,9 +233,9 @@ static void *linuxevent_new(t_symbol *s) {
/* init vars */
x->x_fd = -1;
- x->read_ok = 1;
- x->started = 0;
- x->x_delaytime = 5;
+ x->x_read_ok = 1;
+ x->x_started = 0;
+ x->x_delay = DEFAULT_DELAY;
x->x_clock = clock_new(x, (t_method)linuxevent_read);
diff --git a/linuxhid.h b/linuxhid.h
index 3226535..52bc815 100644
--- a/linuxhid.h
+++ b/linuxhid.h
@@ -23,6 +23,9 @@
#define DEBUG(x)
//#define DEBUG(x) x
+
+#define DEFAULT_DELAY 5
+
/*------------------------------------------------------------------------------
* from evtest.c from the ff-utils package
*/
diff --git a/linuxjoystick.c b/linuxjoystick.c
index aa80603..0a90535 100644
--- a/linuxjoystick.c
+++ b/linuxjoystick.c
@@ -2,7 +2,7 @@
#define LINUXJOYSTICK_AXES 6
-static char *version = "$Revision: 1.5 $";
+static char *version = "$Revision: 1.6 $";
/*------------------------------------------------------------------------------
* CLASS DEF
@@ -14,9 +14,9 @@ typedef struct _linuxjoystick {
t_int x_fd;
t_symbol *x_devname;
t_clock *x_clock;
- int read_ok;
- int started;
- int x_delaytime;
+ int x_read_ok;
+ int x_started;
+ int x_delay;
#ifdef __gnu_linux__
struct input_event x_input_event;
#endif
@@ -34,10 +34,10 @@ typedef struct _linuxjoystick {
void linuxjoystick_stop(t_linuxjoystick* x) {
DEBUG(post("linuxjoystick_stop"););
- if (x->x_fd >= 0 && x->started) {
+ if (x->x_fd >= 0 && x->x_started) {
clock_unset(x->x_clock);
post("linuxjoystick: polling stopped");
- x->started = 0;
+ x->x_started = 0;
}
}
@@ -268,8 +268,8 @@ static int linuxjoystick_read(t_linuxjoystick *x,int fd) {
}
#endif
- if (x->started) {
- clock_delay(x->x_clock, x->x_delaytime);
+ if (x->x_started) {
+ clock_delay(x->x_clock, x->x_delay);
}
return 1;
@@ -286,9 +286,9 @@ void linuxjoystick_delay(t_linuxjoystick* x, t_float f) {
/* if the user sets the delay less than zero, reset to default */
if ( f > 0 ) {
- x->x_delaytime = (int)f;
+ x->x_delay = (int)f;
} else {
- x->x_delaytime = 5;
+ x->x_delay = DEFAULT_DELAY;
}
}
@@ -296,10 +296,10 @@ void linuxjoystick_start(t_linuxjoystick* x) {
DEBUG(post("linuxjoystick_start"););
#ifdef __linux__
- if (x->x_fd >= 0 && !x->started) {
- clock_delay(x->x_clock, 5);
+ if (x->x_fd >= 0 && !x->x_started) {
+ clock_delay(x->x_clock, DEFAULT_DELAY);
post("linuxjoystick: polling started");
- x->started = 1;
+ x->x_started = 1;
} else {
post("You need to set a input device (i.e /dev/input/event0)");
}
@@ -332,9 +332,9 @@ static void *linuxjoystick_new(t_symbol *s) {
/* init vars */
x->x_fd = -1;
- x->read_ok = 1;
- x->started = 0;
- x->x_delaytime = 5;
+ x->x_read_ok = 1;
+ x->x_started = 0;
+ x->x_delay = DEFAULT_DELAY;
x->x_clock = clock_new(x, (t_method)linuxjoystick_read);
/* create outlets for each axis */
diff --git a/linuxmouse.c b/linuxmouse.c
index 51e3d51..2dd4b56 100644
--- a/linuxmouse.c
+++ b/linuxmouse.c
@@ -3,7 +3,7 @@
#define LINUXMOUSE_DEVICE "/dev/input/event0"
#define LINUXMOUSE_AXES 3
-static char *version = "$Revision: 1.4 $";
+static char *version = "$Revision: 1.5 $";
/*------------------------------------------------------------------------------
* CLASS DEF
@@ -14,8 +14,8 @@ typedef struct _linuxmouse {
t_object x_obj;
t_int x_fd;
t_symbol *x_devname;
- int read_ok;
- int started;
+ int x_read_ok;
+ int x_started;
#ifdef __gnu_linux__
struct input_event x_input_event;
#endif
@@ -35,10 +35,10 @@ void linuxmouse_stop(t_linuxmouse* x) {
DEBUG(post("linuxmouse_stop"););
#ifdef __gnu_linux__
- if (x->x_fd >= 0 && x->started) {
+ if (x->x_fd >= 0 && x->x_started) {
sys_rmpollfn(x->x_fd);
post("[linuxmouse] stopped");
- x->started = 0;
+ x->x_started = 0;
}
#endif
}
@@ -210,10 +210,10 @@ void linuxmouse_start(t_linuxmouse* x) {
DEBUG(post("linuxmouse_start"););
#ifdef __gnu_linux__
- if (x->x_fd >= 0 && !x->started) {
+ if (x->x_fd >= 0 && !x->x_started) {
sys_addpollfn(x->x_fd, (t_fdpollfn)linuxmouse_read, x);
post("[linuxmouse] started");
- x->started = 1;
+ x->x_started = 1;
} else {
post("You need to set a input device (i.e /dev/input/event0)");
}
@@ -244,8 +244,8 @@ static void *linuxmouse_new(t_symbol *s) {
/* init vars */
x->x_fd = -1;
- x->read_ok = 1;
- x->started = 0;
+ x->x_read_ok = 1;
+ x->x_started = 0;
/* create outlets for each axis */
for (i = 0; i < LINUXMOUSE_AXES; i++)