diff --git a/vice/configure.ac b/vice/configure.ac index db83ead8c4e..39ba31e3180 100755 --- a/vice/configure.ac +++ b/vice/configure.ac @@ -140,9 +140,6 @@ VICE_ARG_ENABLE_LIST(experimental-devices, [ --enable-experimental-devices dnl Needed for WIC64 VICE_ARG_WITH_LIST(libcurl, [ --without-libcurl disable libcurl support [[default=no]]]) -dnl Linux evdev joysticks -VICE_ARG_WITH_LIST(evdev, [ --without-evdev disable Linux evdev joystick driver [[default=no]]]) - dnl dnl UI options dnl @@ -2062,22 +2059,14 @@ dnl ----- Joystick support ----- JOY_LIBS= AM_CONDITIONAL(HAVE_LINUX_EVDEV, false) if test x"$is_unix_x11" = "xyes" -a x"$enable_sdl1ui" != "xyes" -a x"$enable_sdl2ui" != "xyes" -a x"$enable_headlessui" != "xyes"; then - AC_CHECK_HEADER(linux/joystick.h, - [ - AC_CHECK_DECL(JS_VERSION,[ - LINUX_JOYSTICK_SUPPORT="yes"; - AC_DEFINE(LINUX_JOYSTICK,, - [Enable support for Linux style joysticks.]) - JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS joystick_linux.o"; - ],[],[#include ])],) dnl Linux evdev joystick driver - if test x"$with_evdev" != "xno" -a x"$is_unix_linux" = "xyes"; then + if test x"$is_unix_linux" = "xyes"; then PKG_CHECK_MODULES([libevdev], [libevdev], [AC_DEFINE(HAVE_LINUX_EVDEV,,[Enable support for Linux evdev joysticks.]) JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS joystick_linux_evdev.o" HAVE_LINUX_EVDEV_SUPPORT="yes"], - [AC_MSG_ERROR([Linux evdev joystick driver requested (--with-evdev) but the libevdev headers are missing.])]) + [AC_MSG_ERROR([Please install libevdev headers.])]) VICE_CFLAGS="$VICE_CFLAGS $libevdev_CFLAGS" VICE_CXXFLAGS="$VICE_CXXFLAGS $libevdev_CXXFLAGS" LIBS="$LIBS $libevdev_LIBS" @@ -3760,7 +3749,6 @@ echo "Build old x64 emulator : $X64_INCLUDED (--enable/--disable-x64)" echo "Install XDG .desktop files : $USE_DESKTOP_FILES" echo "icotool for Windows found : $ICOTOOL" echo "Experimental devices emulation: $HAVE_EXPERIMENTAL_DEVICES_SUPPORT (--enable-experimental-devices)" -echo "Linux evdev joystick driver : $HAVE_LINUX_EVDEV_SUPPORT (--with-evdev)" echo "" echo "User CPPFLAGS: $CPPFLAGS" diff --git a/vice/doc/building/Linux-GTK3-Howto.txt b/vice/doc/building/Linux-GTK3-Howto.txt index 284861d7fbc..77623015a57 100644 --- a/vice/doc/building/Linux-GTK3-Howto.txt +++ b/vice/doc/building/Linux-GTK3-Howto.txt @@ -8,8 +8,7 @@ your platform (untested). Tested on: Linux Mint 19, 20 Ubuntu 17.10.1, 18.04, 19.04, 20.04.3-LTS 22.04 22.10 23.04 23.10 - Debian 9.0-9.8, 10.0, 10.3, 10.4, 10.5, 10.6, 11.0, 11.1, 11.2 11.3 - 11.4 11.5 11.6 11.7 12.0 + Debian 9.0-9.8, 10.0, 10.3, 10.4, 10.5, 10.6, 11.0-11.7 12.0-12.9 -------------------------------------------------------------------------------- 1. adhoc build from SVN @@ -41,9 +40,7 @@ $ sudo apt-get install libpulse-dev # for Pulse Audio sound support $ sudo apt-get install libasound2-dev # for ALSA sound support $ sudo apt-get install libglew-dev # for OpenGL hardware scaling support $ sudo apt-get install libcurl4-openssl-dev # for WiC64, >= 7.71.0 is required -$ sudo apt-get install libevdev-dev # for Linux evdev joystick driver, - # can be omitted if `--without-evdev` - # was passed to configure +$ sudo apt-get install libevdev-dev # for Linux evdev joystick driver If you plan on building the PDF documentation, you will also need to install whatever package includes "epsf.tex". It was recently in "texlive-plain-generic". diff --git a/vice/src/arch/gtk3/joystickdrv/Makefile.am b/vice/src/arch/gtk3/joystickdrv/Makefile.am index 8e66dfe296d..85f51453420 100644 --- a/vice/src/arch/gtk3/joystickdrv/Makefile.am +++ b/vice/src/arch/gtk3/joystickdrv/Makefile.am @@ -20,16 +20,37 @@ AM_LDFLAGS = @VICE_LDFLAGS@ noinst_LIBRARIES = libjoystickdrv.a -# These sources are always linked -libjoystickdrv_a_SOURCES = \ - joystick_linux.c +if WINDOWS_COMPILE +libjoystickdrv_a_SOURCES = joystick_win32_directinput.c +EXTRA_libjoystickdrv_a_SOURCES = \ + joystick_bsd.c \ + joystick_linux_evdev.c \ + joystick_osx.c +endif + +if MACOS_COMPILE +libjoystickdrv_a_SOURCES = joystick_osx.c +EXTRA_libjoystickdrv_a_SOURCES = \ + joystick_bsd.c \ + joystick_linux_evdev.c \ + joystick_win32_directinput.c +endif -# These sources are conditionally linked +if LINUX_COMPILE +libjoystickdrv_a_SOURCES = joystick_linux_evdev.c EXTRA_libjoystickdrv_a_SOURCES = \ joystick_bsd.c \ + joystick_osx.c \ + joystick_win32_directinput.c +endif + +if BSD_COMPILE +libjoystickdrv_a_SOURCES = joystick_bsd.c +EXTRA_libjoystickdrv_a_SOURCES = \ joystick_linux_evdev.c \ joystick_osx.c \ joystick_win32_directinput.c +endif libjoystickdrv_a_DEPENDENCIES = \ @JOYSTICK_DRIVERS@ diff --git a/vice/src/arch/gtk3/joystickdrv/joystick_linux.c b/vice/src/arch/gtk3/joystickdrv/joystick_linux.c deleted file mode 100644 index 772b5e07a3f..00000000000 --- a/vice/src/arch/gtk3/joystickdrv/joystick_linux.c +++ /dev/null @@ -1,219 +0,0 @@ -/** \file joystick_linux.c - * \brief Linux joystick support - * - * \author Bernhard Kuhn - * \author Ulmer Lionel - * \author Marco van den Heuvel - * \author Daniel Sladic - * \author Krister Walfridsson - * \author Luca Montecchiani (http://i.am/m.luca) - */ - -/* - * This file is part of VICE, the Versatile Commodore Emulator. - * See README for copyright notice. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA. - * - */ - -#include "vice.h" -#include "archdep_defs.h" - -#if defined(LINUX_JOYSTICK) && !defined(HAVE_LINUX_EVDEV) - -#include -#include -#include -#include -#include -#include - -#include "joyport.h" -#include "joystick.h" -#include "log.h" -#include "types.h" -#include "lib.h" - - -/** \brief Number of device nodes to scan */ -#define ANALOG_JOY_NUM 8 - -/** \brief Private, driver-specific data of the device */ -typedef struct linux_joystick_priv_s { - int fd; /**< file descriptor of the joystick device node */ -} linux_joystick_priv_t; - - -/** \brief Linux joystick log */ -static log_t joystick_linux_log = LOG_DEFAULT; - - -/** \brief Callback for the joystick system to poll a joystick device - * - * \param[in] joyport joystick device index - * \param[in] priv driver-specific data - */ -static void linux_joystick_poll(int joyport, void *priv) -{ - linux_joystick_priv_t *joypriv = priv; - struct js_event event; - - /* Read all queued events. */ - while (read(joypriv->fd, &event, sizeof event) == sizeof event) { - joystick_axis_value_t direction; - - switch (event.type & ~JS_EVENT_INIT) { - - case JS_EVENT_BUTTON: - joy_button_event((uint8_t)joyport, event.number, (int16_t)event.value); - break; - - case JS_EVENT_AXIS: - if (event.value > 16384) { - direction = JOY_AXIS_POSITIVE; - } else if (event.value < -16384) { - direction = JOY_AXIS_NEGATIVE; - } else { - direction = JOY_AXIS_MIDDLE; - } - joy_axis_event((uint8_t)joyport, event.number, (int16_t)direction); - break; - - default: - break; - } - } -} - -/** \brief Callback for the joystick system to close a joystick device - * - * \param[in] priv driver-specific data - */ -static void linux_joystick_close(void *priv) -{ - linux_joystick_priv_t *joypriv = priv; - - close(joypriv->fd); - lib_free(joypriv); -} - - -/** \brief Object used to register driver for devices - * - * The address of this object is used in the joystick code, it isn't copied, - * so we cannot move this into `linux_joystick_init()` to use for registration. - */ -static joystick_driver_t driver = { - .poll = linux_joystick_poll, - .close = linux_joystick_close -}; - - -/** \brief Initialize linux joysticks - * - * Scan joystick device nodes for valid devices and register them with the - * joystick system. - */ -void linux_joystick_init(void) -{ - int i; - - if (joystick_linux_log == LOG_DEFAULT) { - joystick_linux_log = log_open("Joystick"); - } - log_message(joystick_linux_log, "Linux joystick interface initialization..."); - - /* open analog device files */ - for (i = 0; i < ANALOG_JOY_NUM; i++) { - char dev[256]; - int fd; - - memset(dev, 0, sizeof dev); - snprintf(dev, sizeof dev - 1u, "/dev/js%d", i); - fd = open(dev, O_RDONLY); - if (fd < 0) { - snprintf(dev, sizeof dev - 1u, "/dev/input/js%d", i); - fd = open(dev, O_RDONLY); - } - - if (fd >= 0) { - struct JS_DATA_TYPE js; - linux_joystick_priv_t *priv; - char name[256]; - uint8_t axes; - uint8_t buttons; - int ver = 0; - - /* read joystick data */ - if (read(fd, &js, sizeof js) < 0) { - close(fd); - continue; - } - - /* check if the runtime drive is at least 1.0 and thus supports - * events: */ - if (ioctl(fd, JSIOCGVERSION, &ver) != 0) { - log_message(joystick_linux_log, - "%s unknown type", dev); - log_message(joystick_linux_log, - "Built in driver version: %d.%d.%d", - JS_VERSION >> 16, (JS_VERSION >> 8) & 0xff, JS_VERSION & 0xff); - log_message(joystick_linux_log, - "Kernel driver version : 0.8 ??"); - log_message(joystick_linux_log, - "Please update your Joystick driver!"); - close(fd); - return; - } - - /* get number of axis, number of buttons and name of device */ - memset(name, 0, sizeof name); - ioctl(fd, JSIOCGAXES, &axes); - ioctl(fd, JSIOCGBUTTONS, &buttons); - ioctl(fd, JSIOCGNAME(sizeof name - 1u), name); - - log_message(joystick_linux_log, - "%s is %s", dev, name); - log_message(joystick_linux_log, - "Built in driver version: %d.%d.%d", - JS_VERSION >> 16, (JS_VERSION >> 8) & 0xff, JS_VERSION & 0xff); - log_message(joystick_linux_log, - "Kernel driver version : %d.%d.%d", - ver >> 16, (ver >> 8) & 0xff, ver & 0xff); - - /* check geometry */ - if ((axes == 0) || (buttons == 0)) { - log_message(joystick_linux_log, - "Joystick with invalid geometry found -- ignoring."); - close(fd); - continue; - } - - /* set file descriptor to non-blocking */ - fcntl(fd, F_SETFL, O_NONBLOCK); - - /* register device with the joystick system */ - priv = lib_malloc(sizeof *priv); - priv->fd = fd; - register_joystick_driver(&driver, name, priv, axes, buttons, 0); - } else { - log_warning(joystick_linux_log, "Cannot open joystick device `%s'.", dev); - } - } -} - -# endif /* LINUX_JOYSTICK && !HAVE_LINUX_EVDEV */ diff --git a/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c b/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c index d6cbb22f616..9996b98a5a8 100644 --- a/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c +++ b/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c @@ -34,8 +34,6 @@ #include "vice.h" -#if defined(HAVE_LINUX_EVDEV) - #include #include #include @@ -480,5 +478,3 @@ void linux_joystick_evdev_init(void) } free(namelist); } - -#endif /* ifdef HAVE_LINUX_EVDEV */