aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJean-Marc Zucconi <jmz@FreeBSD.org>1995-02-22 23:34:58 +0000
committerJean-Marc Zucconi <jmz@FreeBSD.org>1995-02-22 23:34:58 +0000
commit95344a43ed98e0e3530f64ab9122228a3624d7b2 (patch)
tree159d7620e33456cefc4017f1011b42604b72ba0b /sys
parentf75dd5183215816c9a2f43e04bba35e96a636f9a (diff)
downloadsrc-95344a43ed98e0e3530f64ab9122228a3624d7b2.tar.gz
src-95344a43ed98e0e3530f64ab9122228a3624d7b2.zip
Put the joystick status in a struct {int x, y, b1, b2;} rather than in a
dummy array of 4 integers. Declare the struct in the header file and update the man page.
Notes
Notes: svn path=/head/; revision=6644
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/joy/joy.c12
-rw-r--r--sys/i386/include/joystick.h7
-rw-r--r--sys/i386/isa/joy.c12
-rw-r--r--sys/isa/joy.c12
-rw-r--r--sys/sys/joystick.h7
5 files changed, 32 insertions, 18 deletions
diff --git a/sys/dev/joy/joy.c b/sys/dev/joy/joy.c
index aacd92e67338..77ef121941ed 100644
--- a/sys/dev/joy/joy.c
+++ b/sys/dev/joy/joy.c
@@ -129,7 +129,7 @@ joyread (dev_t dev, struct uio *uio, int flag)
int port = joy[unit].port;
int i, t0, t1;
int state = 0, x = 0, y = 0;
- int c[4];
+ struct joystick c;
disable_intr ();
outb (port, 0xff);
@@ -151,12 +151,12 @@ joyread (dev_t dev, struct uio *uio, int flag)
break;
}
enable_intr ();
- c[0] = x ? joy[unit].x_off[joypart(dev)] + ticks2usec(t0-x) : 0x80000000;
- c[1] = y ? joy[unit].y_off[joypart(dev)] + ticks2usec(t0-y) : 0x80000000;
+ c.x = x ? joy[unit].x_off[joypart(dev)] + ticks2usec(t0-x) : 0x80000000;
+ c.y = y ? joy[unit].y_off[joypart(dev)] + ticks2usec(t0-y) : 0x80000000;
state >>= 4;
- c[2] = ~state & 1;
- c[3] = ~(state >> 1) & 1;
- return uiomove (c, 4*sizeof(int), uio);
+ c.b1 = ~state & 1;
+ c.b2 = ~(state >> 1) & 1;
+ return uiomove (&c, sizeof(struct joystick), uio);
}
int joyioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
{
diff --git a/sys/i386/include/joystick.h b/sys/i386/include/joystick.h
index 2ba31a665707..d070ac050714 100644
--- a/sys/i386/include/joystick.h
+++ b/sys/i386/include/joystick.h
@@ -4,6 +4,13 @@
#include <sys/types.h>
#include <sys/ioctl.h>
+struct joystick {
+ int x;
+ int y;
+ int b1;
+ int b2;
+};
+
#define JOY_SETTIMEOUT _IOW('J', 1, int) /* set timeout */
#define JOY_GETTIMEOUT _IOR('J', 2, int) /* get timeout */
#define JOY_SET_X_OFFSET _IOW('J', 3, int) /* set offset on X-axis */
diff --git a/sys/i386/isa/joy.c b/sys/i386/isa/joy.c
index aacd92e67338..77ef121941ed 100644
--- a/sys/i386/isa/joy.c
+++ b/sys/i386/isa/joy.c
@@ -129,7 +129,7 @@ joyread (dev_t dev, struct uio *uio, int flag)
int port = joy[unit].port;
int i, t0, t1;
int state = 0, x = 0, y = 0;
- int c[4];
+ struct joystick c;
disable_intr ();
outb (port, 0xff);
@@ -151,12 +151,12 @@ joyread (dev_t dev, struct uio *uio, int flag)
break;
}
enable_intr ();
- c[0] = x ? joy[unit].x_off[joypart(dev)] + ticks2usec(t0-x) : 0x80000000;
- c[1] = y ? joy[unit].y_off[joypart(dev)] + ticks2usec(t0-y) : 0x80000000;
+ c.x = x ? joy[unit].x_off[joypart(dev)] + ticks2usec(t0-x) : 0x80000000;
+ c.y = y ? joy[unit].y_off[joypart(dev)] + ticks2usec(t0-y) : 0x80000000;
state >>= 4;
- c[2] = ~state & 1;
- c[3] = ~(state >> 1) & 1;
- return uiomove (c, 4*sizeof(int), uio);
+ c.b1 = ~state & 1;
+ c.b2 = ~(state >> 1) & 1;
+ return uiomove (&c, sizeof(struct joystick), uio);
}
int joyioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
{
diff --git a/sys/isa/joy.c b/sys/isa/joy.c
index aacd92e67338..77ef121941ed 100644
--- a/sys/isa/joy.c
+++ b/sys/isa/joy.c
@@ -129,7 +129,7 @@ joyread (dev_t dev, struct uio *uio, int flag)
int port = joy[unit].port;
int i, t0, t1;
int state = 0, x = 0, y = 0;
- int c[4];
+ struct joystick c;
disable_intr ();
outb (port, 0xff);
@@ -151,12 +151,12 @@ joyread (dev_t dev, struct uio *uio, int flag)
break;
}
enable_intr ();
- c[0] = x ? joy[unit].x_off[joypart(dev)] + ticks2usec(t0-x) : 0x80000000;
- c[1] = y ? joy[unit].y_off[joypart(dev)] + ticks2usec(t0-y) : 0x80000000;
+ c.x = x ? joy[unit].x_off[joypart(dev)] + ticks2usec(t0-x) : 0x80000000;
+ c.y = y ? joy[unit].y_off[joypart(dev)] + ticks2usec(t0-y) : 0x80000000;
state >>= 4;
- c[2] = ~state & 1;
- c[3] = ~(state >> 1) & 1;
- return uiomove (c, 4*sizeof(int), uio);
+ c.b1 = ~state & 1;
+ c.b2 = ~(state >> 1) & 1;
+ return uiomove (&c, sizeof(struct joystick), uio);
}
int joyioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
{
diff --git a/sys/sys/joystick.h b/sys/sys/joystick.h
index 2ba31a665707..d070ac050714 100644
--- a/sys/sys/joystick.h
+++ b/sys/sys/joystick.h
@@ -4,6 +4,13 @@
#include <sys/types.h>
#include <sys/ioctl.h>
+struct joystick {
+ int x;
+ int y;
+ int b1;
+ int b2;
+};
+
#define JOY_SETTIMEOUT _IOW('J', 1, int) /* set timeout */
#define JOY_GETTIMEOUT _IOR('J', 2, int) /* get timeout */
#define JOY_SET_X_OFFSET _IOW('J', 3, int) /* set offset on X-axis */