--- uae/src/od-linux/joystick.c 2018/04/24 16:40:31 1.1 +++ uae/src/od-linux/joystick.c 2018/04/24 16:43:01 1.1.1.2 @@ -1,9 +1,11 @@ /* * UAE - The Un*x Amiga Emulator * - * Joystick emulation for Linux + * Joystick emulation for Linux and BSD. They share too much code to + * split this file. * * Copyright 1997 Bernd Schmidt + * Copyright 1998 Krister Walfridsson */ #include "sysconfig.h" @@ -15,28 +17,43 @@ #include "custom.h" #include "joystick.h" -int nr_joysticks; +#ifdef HAVE_MACHINE_SOUNDCARD_H -static int js0, js1; +/* The BSD way. */ + +# include +typedef struct joystick uae_joystick_t + +#define JS_DEVNAME_PREFIX "joy" + +#else + +/* The Linux way. */ /* There are too many different versions of . Rather * than trying to work correctly with all of them, we duplicate the * necessary definitions here. */ -struct JS_DATA_TYPE +typedef struct { int buttons; int x; int y; -}; +} uae_joystick_t; -static struct JS_DATA_TYPE jscal; +#define JS_DEVNAME_PREFIX "js" + +#endif + +int nr_joysticks; + +static int js0, js1; void read_joystick(int nr, unsigned int *dir, int *button) { - static int minx = MAXINT, maxx = MININT, - miny = MAXINT, maxy = MININT; + static int minx = INT_MAX, maxx = INT_MIN; + static int miny = INT_MAX, maxy = INT_MIN; int left = 0, right = 0, top = 0, bot = 0; - struct JS_DATA_TYPE buffer; + uae_joystick_t buffer; int len; int fd = nr == 0 ? js0 : js1; @@ -74,13 +91,13 @@ void init_joystick(void) { nr_joysticks = 0; js0 = -1; js1 = -1; - js0 = open("/dev/js0", O_RDONLY); + js0 = open("/dev/" JS_DEVNAME_PREFIX "0", O_RDONLY); if (js0 < 0) { write_log ("No joysticks found\n"); return; } nr_joysticks = 1; - js1 = open("/dev/js1", O_RDONLY); + js1 = open("/dev/" JS_DEVNAME_PREFIX "1", O_RDONLY); if (js1 < 0) { write_log ("Found one joystick\n"); return;