diff options
Diffstat (limited to 'hw/xfree86/os-support/linux/lnx_jstk.c')
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_jstk.c | 77 |
1 files changed, 44 insertions, 33 deletions
diff --git a/hw/xfree86/os-support/linux/lnx_jstk.c b/hw/xfree86/os-support/linux/lnx_jstk.c index ea308c159..2423bd45e 100644 --- a/hw/xfree86/os-support/linux/lnx_jstk.c +++ b/hw/xfree86/os-support/linux/lnx_jstk.c @@ -1,4 +1,4 @@ -/* $Xorg: lnx_jstk.c,v 1.3 2000/08/17 19:51:23 cpqbld Exp $ */ +/* $XConsortium: lnx_jstk.c /main/7 1996/02/21 17:51:36 kaleb $ */ /* Id: lnx_jstk.c,v 1.1 1995/12/20 14:06:09 lepied Exp */ /* * Copyright 1995 by Frederic Lepied, France. <fred@sugix.frmug.fr.net> @@ -23,19 +23,31 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_jstk.c,v 3.6 1996/12/23 06:50:02 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_jstk.c,v 3.13 1998/07/25 16:56:43 dawes Exp $ */ -static const char rcs_id[] = "$Xorg: lnx_jstk.c,v 1.1 1995/12/20 14:06:09 lepied Exp"; +static const char rcs_id[] = "Id: lnx_jstk.c,v 1.1 1995/12/20 14:06:09 lepied Exp"; #include <sys/types.h> #include <unistd.h> #include <string.h> +#include <errno.h> #define inline __inline__ #include <linux/joystick.h> #include <fcntl.h> #include <sys/ioctl.h> -extern int errno; +#ifdef XFree86LOADER +#include "xf86.h" +#include "xf86_ansic.h" +#endif + +#if !defined(JSIOCGTIMELIMIT) +/* make 2.1.x joystick.h backward compatable */ +#define JSIOCGTIMELIMIT JS_GET_TIMELIMIT +#define JSIOCSTIMELIMIT JS_SET_TIMELIMIT +#define js_status JS_DATA_TYPE +#endif + /*********************************************************************** * @@ -50,33 +62,30 @@ int xf86JoystickOn(char *name, int *timeout, int *centerX, int *centerY) { int fd; - struct JS_DATA_TYPE js; - extern int xf86Verbose; + struct js_status js; #ifdef DEBUG ErrorF("xf86JoystickOn %s\n", name); #endif - if ((fd = open(name, O_RDWR | O_NDELAY)) < 0) + if ((fd = open(name, O_RDWR | O_NDELAY, 0)) < 0) { - ErrorF("Cannot open joystick '%s' (%s)\n", name, - strerror(errno)); + xf86Msg(X_WARNING, "Cannot open joystick '%s' (%s)\n", name, + strerror(errno)); return -1; } if (*timeout == 0) { - if (ioctl (fd, JS_GET_TIMELIMIT, timeout) == -1) { - Error("joystick JS_GET_TIMELIMIT ioctl"); + if (ioctl (fd, JSIOCGTIMELIMIT, timeout) == -1) { + Error("joystick JSIOCGTIMELIMIT ioctl"); } else { - if (xf86Verbose) { - ErrorF("(--) Joystick: timeout value = %d\n", *timeout); - } + xf86Msg(X_CONFIG, "Joystick: timeout value = %d\n", *timeout); } } else { - if (ioctl(fd, JS_SET_TIMELIMIT, timeout) == -1) { - Error("joystick JS_SET_TIMELIMIT ioctl"); + if (ioctl(fd, JSIOCSTIMELIMIT, timeout) == -1) { + Error("joystick JSIOCSTIMELIMIT ioctl"); } } @@ -84,17 +93,13 @@ xf86JoystickOn(char *name, int *timeout, int *centerX, int *centerY) read(fd, &js, JS_RETURN); if (*centerX < 0) { *centerX = js.x; - if (xf86Verbose) { - ErrorF("(--) Joystick: CenterX set to %d\n", *centerX); - } + xf86Msg(X_CONFIG, "Joystick: CenterX set to %d\n", *centerX); } if (*centerY < 0) { *centerY = js.y; - if (xf86Verbose) { - ErrorF("(--) Joystick: CenterY set to %d\n", *centerY); - } + xf86Msg(X_CONFIG, "Joystick: CenterY set to %d\n", *centerY); } - + return fd; } @@ -123,9 +128,7 @@ xf86JoystickInit() */ int -xf86JoystickOff(fd, doclose) -int *fd; -int doclose; +xf86JoystickOff(int *fd, int doclose) { int oldfd; @@ -146,14 +149,10 @@ int doclose; */ int -xf86JoystickGetState(fd, x, y, buttons) -int fd; -int *x; -int *y; -int *buttons; +xf86JoystickGetState(int fd, int *x, int *y, int *buttons) { - struct JS_DATA_TYPE js; - int status; + struct js_status js; + int status; status = read(fd, &js, JS_RETURN); @@ -170,4 +169,16 @@ int *buttons; return 1; } +#ifdef XFree86LOADER +/* + * Entry point for XFree86 Loader + */ +void +linux_jstkModuleInit(pointer *data, INT32 *magic) +{ + *magic = MAGIC_DONE; + *data = NULL; +} +#endif + /* end of lnx_jstk.c */ |