From d25877592679f9024da567d024ecc8cf2c507f0d Mon Sep 17 00:00:00 2001 From: Mike Robinson Date: Sat, 4 Oct 2014 04:18:36 +0100 Subject: [PATCH 1/7] Add parallel port joypad driver --- Makefile | 5 + Makefile.common | 4 +- input/input_common.c | 1 + input/input_common.h | 1 + input/parport_joypad.c | 244 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 253 insertions(+), 2 deletions(-) create mode 100644 input/parport_joypad.c diff --git a/Makefile b/Makefile index 69a20e48d6..6883c37850 100644 --- a/Makefile +++ b/Makefile @@ -121,6 +121,11 @@ $(OBJDIR)/tools/linuxraw_joypad.o: input/linuxraw_joypad.c @$(if $(Q), $(shell echo echo CC $<),) $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $< +$(OBJDIR)/tools/parport_joypad.o: input/parport_joypad.c + @mkdir -p $(dir $@) + @$(if $(Q), $(shell echo echo CC $<),) + $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $< + $(OBJDIR)/tools/udev_joypad.o: input/udev_joypad.c @mkdir -p $(dir $@) @$(if $(Q), $(shell echo echo CC $<),) diff --git a/Makefile.common b/Makefile.common index 40f6e197ab..bbea4f8b3a 100644 --- a/Makefile.common +++ b/Makefile.common @@ -59,8 +59,8 @@ endif ifneq ($(findstring Linux,$(OS)),) LIBS += -lrt JOYCONFIG_LIBS += -lrt - OBJ += input/linuxraw_input.o input/linuxraw_joypad.o - JOYCONFIG_OBJ += tools/linuxraw_joypad.o + OBJ += input/linuxraw_input.o input/linuxraw_joypad.o input/parport_joypad.o + JOYCONFIG_OBJ += tools/linuxraw_joypad.o tools/parport_joypad.o endif ifeq ($(findstring Haiku,$(OS)),) diff --git a/input/input_common.c b/input/input_common.c index ba099ba8fb..6ccb262395 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -75,6 +75,7 @@ rarch_joypad_driver_t *joypad_drivers[] = { #endif #if defined(__linux) && !defined(ANDROID) &linuxraw_joypad, + &parport_joypad, #endif #ifdef ANDROID &android_joypad, diff --git a/input/input_common.h b/input/input_common.h index d73819473b..25d0131515 100644 --- a/input/input_common.h +++ b/input/input_common.h @@ -127,6 +127,7 @@ const char *input_joypad_name(const rarch_joypad_driver_t *driver, extern rarch_joypad_driver_t dinput_joypad; extern rarch_joypad_driver_t linuxraw_joypad; +extern rarch_joypad_driver_t parport_joypad; extern rarch_joypad_driver_t udev_joypad; extern rarch_joypad_driver_t winxinput_joypad; extern rarch_joypad_driver_t sdl_joypad; diff --git a/input/parport_joypad.c b/input/parport_joypad.c new file mode 100644 index 0000000000..130fb62aa0 --- /dev/null +++ b/input/parport_joypad.c @@ -0,0 +1,244 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2014 - Mike Robinson + * + * RetroArch 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 Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch 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 RetroArch. + * If not, see . + */ + +#include "input_common.h" +#include "../general.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Linux parport driver does not support reading the control register + Other platforms may support up to 17 buttons */ +#define NUM_BUTTONS 13 + +struct parport_joypad +{ + int fd; + bool buttons[NUM_BUTTONS]; + + char *ident; +}; + +static struct parport_joypad g_pads[MAX_PLAYERS]; + +static void poll_pad(struct parport_joypad *pad) +{ + /* RetroArch uses an extended version of the Linux + * Multisystem 2-button joystick protocol for parallel port + * joypads: + * + * | Function | Pin | Register | Bit | Active | + * |-------------|-----|----------|-----|--------| + * | Up | 2 | Data | 0 | Low | + * | Down | 3 | Data | 1 | Low | + * | Left | 4 | Data | 2 | Low | + * | Right | 5 | Data | 3 | Low | + * | A | 6 | Data | 4 | Low | + * | B | 7 | Data | 5 | Low | + * | Start | 8 | Data | 6 | Low | + * | Select | 9 | Data | 7 | Low | + * | Menu toggle | 10 | Status | 6 | Low | + * | X | 11 | Status | 7 | Low* | + * | Y | 12 | Status | 5 | Low | + * | L1 | 13 | Status | 4 | Low | + * | R1 | 15 | Status | 3 | Low | + * + * (*) Pin is hardware inverted, but RetroArch inverts it + * back again so the same pullup scheme may be used for + * all pins. + * + * RetroArch does not perform debouncing, and so long as + * the button settling time is less than the frame time + * no bouncing will be observed. This replicates the latching + * behavior common in old games consoles. For optimum latency + * and jitter a high performance debouncing routine should be + * implemented in the controller hardware. + */ + + int i; + char data; + char status; + + ioctl(pad->fd, PPRDATA, &data); + ioctl(pad->fd, PPRSTATUS, &status); + + for (i = 0; i < 8; i++) + { + pad->buttons[i] = !(data & UINT8_C(1 << i)); + } + for (i = 3; i < 8; i++) + { + pad->buttons[i + 5] = !(status & UINT8_C(1 << i)); + } + pad->buttons[12] = pad->buttons[12] ? false : true; +} + +static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad) +{ + int datadir = 1; /* read */ + char data; + bool irq_disable = false; + int mode = IEEE1284_MODE_BYTE; + + if (pad->fd >= 0) + return false; + + if (access(path, R_OK | W_OK) < 0) + return false; + + pad->fd = open(path, O_RDWR); + + *pad->ident = '\0'; + if (pad->fd >= 0) + { + RARCH_LOG("[Joypad]: Found parallel port: %s\n", path); + + /* Parport driver does not log failures with RARCH_ERR because they could be + * a normal result of connected non-joypad devices. */ + if (ioctl(pad->fd, PPCLAIM) < 0) + { + RARCH_WARN("[Joypad]: Failed to claim %s\n", path); + goto error; + } + if (ioctl(pad->fd, PPSETMODE, &mode) < 0) + { + RARCH_WARN("[Joypad]: Failed to set byte mode on %s\n", path); + goto error; + } + if (ioctl(pad->fd, PPDATADIR, &datadir) < 0) + { + RARCH_WARN("[Joypad]: Failed to set data direction to input on %s\n", path); + goto error; + } + if (ioctl(pad->fd, PPRCONTROL, &data) == 0) + { + data &= 0xEF; /* Clear bit 4 to disable interrupts */ + if (ioctl(pad->fd, PPWCONTROL, &data) == 0) + irq_disable = true; + } + /* Failure to disable interrupts only slightly increases CPU use, not an error */ + if (!irq_disable) + RARCH_WARN("[Joypad]: Failed to disable interrupts on %s\n", path); + + strlcpy(pad->ident, "Parallel port device", sizeof(g_settings.input.device_names[0])); + return true; +error: + close(pad->fd); + pad->fd = 0; + return false; + } + + RARCH_WARN("[Joypad]: Failed to open parallel port %s (error: %s).\n", path, strerror(errno)); + return false; +} + +static void parport_joypad_poll(void) +{ + int i; + + for (i = 0; i < MAX_PLAYERS; i++) + { + if (g_pads[i].fd >= 0) + { + poll_pad(&g_pads[i]); + } + } +} + +static bool parport_joypad_init(void) +{ + unsigned i; + + for (i = 0; i < MAX_PLAYERS; i++) + { + struct parport_joypad *pad = &g_pads[i]; + pad->fd = -1; + pad->ident = g_settings.input.device_names[i]; + + char path[PATH_MAX]; + snprintf(path, sizeof(path), "/dev/parport%u", i); + + if (parport_joypad_init_pad(path, pad)) + { + input_config_autoconfigure_joypad(i, pad->ident, 0, 0, "parport"); + poll_pad(pad); + } + else + input_config_autoconfigure_joypad(i, NULL, 0, 0, NULL); + } + + return true; +} + +static void parport_joypad_destroy(void) +{ + unsigned i; + for (i = 0; i < MAX_PLAYERS; i++) + { + if (g_pads[i].fd >= 0) + { + ioctl(g_pads[i].fd, PPRELEASE); + close(g_pads[i].fd); + } + } + memset(g_pads, 0, sizeof(g_pads)); + for (i = 0; i < MAX_PLAYERS; i++) + g_pads[i].fd = -1; +} + +static bool parport_joypad_button(unsigned port, uint16_t joykey) +{ + const struct parport_joypad *pad = &g_pads[port]; + + return joykey < NUM_BUTTONS && pad->buttons[joykey]; +} + +static int16_t parport_joypad_axis(unsigned port, uint32_t joyaxis) +{ + /* Parport does not support analog sticks */ + return 0; +} + +static bool parport_joypad_query_pad(unsigned pad) +{ + return pad < MAX_PLAYERS && g_pads[pad].fd >= 0; +} + +static const char *parport_joypad_name(unsigned pad) +{ + if (pad >= MAX_PLAYERS) + return NULL; + + return *g_pads[pad].ident ? g_pads[pad].ident : NULL; +} + +rarch_joypad_driver_t parport_joypad = { + parport_joypad_init, + parport_joypad_query_pad, + parport_joypad_destroy, + parport_joypad_button, + parport_joypad_axis, + parport_joypad_poll, + NULL, + parport_joypad_name, + "parport", +}; From 44df93dfd1a71241626a3be592d51fa72351b076 Mon Sep 17 00:00:00 2001 From: Mike Robinson Date: Sat, 4 Oct 2014 17:26:28 +0100 Subject: [PATCH 2/7] More robust error and register state handling --- input/parport_joypad.c | 67 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/input/parport_joypad.c b/input/parport_joypad.c index 130fb62aa0..bb38d94c9f 100644 --- a/input/parport_joypad.c +++ b/input/parport_joypad.c @@ -34,7 +34,9 @@ struct parport_joypad { int fd; bool buttons[NUM_BUTTONS]; - + bool button_enable[NUM_BUTTONS]; + char saved_data; + char saved_control; char *ident; }; @@ -90,13 +92,17 @@ static void poll_pad(struct parport_joypad *pad) pad->buttons[i + 5] = !(status & UINT8_C(1 << i)); } pad->buttons[12] = pad->buttons[12] ? false : true; + + } static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad) { int datadir = 1; /* read */ char data; - bool irq_disable = false; + struct ppdev_frob_struct frob; + bool set_control = false; + int mode = IEEE1284_MODE_BYTE; if (pad->fd >= 0) @@ -129,17 +135,40 @@ static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad RARCH_WARN("[Joypad]: Failed to set data direction to input on %s\n", path); goto error; } + + if (ioctl(pad->fd, PPRDATA, &data) < 0) + { + RARCH_WARN("[Joypad]: Failed to save original data register on %s\n", path); + goto error; + } + pad->saved_data = data; + if (ioctl(pad->fd, PPRCONTROL, &data) == 0) { - data &= 0xEF; /* Clear bit 4 to disable interrupts */ - if (ioctl(pad->fd, PPWCONTROL, &data) == 0) - irq_disable = true; + pad->saved_control = data; + /* Clear strobe bit to set strobe high for pullup +V */ + /* Clear control bit 4 to disable interrupts */ + frob.mask = PARPORT_CONTROL_STROBE | (UINT8_C(1 << 4)); + frob.val = 0; + if (ioctl(pad->fd, PPFCONTROL, &frob) == 0) + set_control = true; + } + else + { + data = pad->saved_data; + if (ioctl(pad->fd, PPWDATA, &data) < 0) + RARCH_WARN("[Joypad]: Failed to restore original data register on %s\n", path); + RARCH_WARN("[Joypad]: Failed to save original control register on %s\n", path); + goto error; } - /* Failure to disable interrupts only slightly increases CPU use, not an error */ - if (!irq_disable) - RARCH_WARN("[Joypad]: Failed to disable interrupts on %s\n", path); - strlcpy(pad->ident, "Parallel port device", sizeof(g_settings.input.device_names[0])); + /* Failure to enable strobe breaks Linux Multisystem style controllers. + * Controllers using an alternative power source will still work. + * Failure to disable interrupts slightly increases CPU usage. */ + if (!set_control) + RARCH_WARN("[Joypad]: Failed to clear nStrobe and nIRQ bits on %s\n", path); + + strlcpy(pad->ident, path, sizeof(g_settings.input.device_names[0])); return true; error: close(pad->fd); @@ -192,12 +221,26 @@ static bool parport_joypad_init(void) static void parport_joypad_destroy(void) { unsigned i; + char data; + struct parport_joypad *pad; + for (i = 0; i < MAX_PLAYERS; i++) { - if (g_pads[i].fd >= 0) + pad = &g_pads[i]; + if (pad->fd >= 0) { - ioctl(g_pads[i].fd, PPRELEASE); - close(g_pads[i].fd); + data = pad->saved_data; + if (ioctl(pad->fd, PPWDATA, &data) < 0) + RARCH_ERR("[Joypad]: Failed to restore original data register on %s\n", pad->ident); + + data = pad->saved_control; + if (ioctl(pad->fd, PPWDATA, &data) < 0) + RARCH_ERR("[Joypad]: Failed to restore original control register on %s\n", pad->ident); + + if (ioctl(pad->fd, PPRELEASE) < 0) + RARCH_ERR("[Joypad]: Failed to release parallel port %s\n", pad->ident); + + close(pad->fd); } } memset(g_pads, 0, sizeof(g_pads)); From 531ad20ddd1acd7f3e6d732b587bdf9e6a31d947 Mon Sep 17 00:00:00 2001 From: Mike Robinson Date: Sat, 4 Oct 2014 18:03:00 +0100 Subject: [PATCH 3/7] Attempt to autodetect non-connected pins --- input/parport_joypad.c | 91 +++++++++++++++++++++++++++++------------- 1 file changed, 64 insertions(+), 27 deletions(-) diff --git a/input/parport_joypad.c b/input/parport_joypad.c index bb38d94c9f..1b44b1eb68 100644 --- a/input/parport_joypad.c +++ b/input/parport_joypad.c @@ -68,6 +68,8 @@ static void poll_pad(struct parport_joypad *pad) * back again so the same pullup scheme may be used for * all pins. * + * Pin 1 is set high so it can be used for pullups. + * * RetroArch does not perform debouncing, and so long as * the button settling time is less than the frame time * no bouncing will be observed. This replicates the latching @@ -85,15 +87,13 @@ static void poll_pad(struct parport_joypad *pad) for (i = 0; i < 8; i++) { - pad->buttons[i] = !(data & UINT8_C(1 << i)); + pad->buttons[i] = !(data & UINT8_C(1 << i)) && pad->button_enable[i]; } for (i = 3; i < 8; i++) { - pad->buttons[i + 5] = !(status & UINT8_C(1 << i)); + pad->buttons[i + 5] = !(status & UINT8_C(1 << i)) && pad->button_enable[i]; } - pad->buttons[12] = pad->buttons[12] ? false : true; - - + pad->buttons[12] = pad->buttons[12] ? false : true && pad->button_enable[12]; } static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad) @@ -102,6 +102,7 @@ static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad char data; struct ppdev_frob_struct frob; bool set_control = false; + int i; int mode = IEEE1284_MODE_BYTE; @@ -162,13 +163,17 @@ static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad goto error; } - /* Failure to enable strobe breaks Linux Multisystem style controllers. + /* Failure to enable strobe can break Linux Multisystem style controllers. * Controllers using an alternative power source will still work. * Failure to disable interrupts slightly increases CPU usage. */ if (!set_control) RARCH_WARN("[Joypad]: Failed to clear nStrobe and nIRQ bits on %s\n", path); strlcpy(pad->ident, path, sizeof(g_settings.input.device_names[0])); + + for (i = 0; i < NUM_BUTTONS; i++) + pad->button_enable[i] = true; + return true; error: close(pad->fd); @@ -193,9 +198,28 @@ static void parport_joypad_poll(void) } } +static void destroy_pad(struct parport_joypad *pad) +{ + char data; + data = pad->saved_data; + if (ioctl(pad->fd, PPWDATA, &data) < 0) + RARCH_ERR("[Joypad]: Failed to restore original data register on %s\n", pad->ident); + + data = pad->saved_control; + if (ioctl(pad->fd, PPWDATA, &data) < 0) + RARCH_ERR("[Joypad]: Failed to restore original control register on %s\n", pad->ident); + + if (ioctl(pad->fd, PPRELEASE) < 0) + RARCH_ERR("[Joypad]: Failed to release parallel port %s\n", pad->ident); + + close(pad->fd); + pad->fd = -1; +} + static bool parport_joypad_init(void) { - unsigned i; + unsigned i, j; + bool found_button; for (i = 0; i < MAX_PLAYERS; i++) { @@ -207,13 +231,38 @@ static bool parport_joypad_init(void) snprintf(path, sizeof(path), "/dev/parport%u", i); if (parport_joypad_init_pad(path, pad)) - { - input_config_autoconfigure_joypad(i, pad->ident, 0, 0, "parport"); - poll_pad(pad); - } - else - input_config_autoconfigure_joypad(i, NULL, 0, 0, NULL); - } + { + /* If a pin is low on initialization it can either mean + * a button is pressed or that nothing is connected. + * Polling non-connected pins can render the menu unusable + * so assume the user is not holding any button on startup + * and disable any low pins. + */ + for (j = 0; j < NUM_BUTTONS; j++) + pad->button_enable[j] = true; + + poll_pad(pad); + found_button = false; + + for (j = 0; j < NUM_BUTTONS; j++) + { + if (!pad->buttons[j]) + found_button = true; + else + pad->button_enable[j] = false; + } + + if (found_button) + input_config_autoconfigure_joypad(i, pad->ident, 0, 0, "parport"); + else + { + destroy_pad(pad); /* assume nothing was connected */ + input_config_autoconfigure_joypad(i, NULL, 0, 0, NULL); + } + } + else + input_config_autoconfigure_joypad(i, NULL, 0, 0, NULL); + } return true; } @@ -221,7 +270,6 @@ static bool parport_joypad_init(void) static void parport_joypad_destroy(void) { unsigned i; - char data; struct parport_joypad *pad; for (i = 0; i < MAX_PLAYERS; i++) @@ -229,18 +277,7 @@ static void parport_joypad_destroy(void) pad = &g_pads[i]; if (pad->fd >= 0) { - data = pad->saved_data; - if (ioctl(pad->fd, PPWDATA, &data) < 0) - RARCH_ERR("[Joypad]: Failed to restore original data register on %s\n", pad->ident); - - data = pad->saved_control; - if (ioctl(pad->fd, PPWDATA, &data) < 0) - RARCH_ERR("[Joypad]: Failed to restore original control register on %s\n", pad->ident); - - if (ioctl(pad->fd, PPRELEASE) < 0) - RARCH_ERR("[Joypad]: Failed to release parallel port %s\n", pad->ident); - - close(pad->fd); + destroy_pad(pad); } } memset(g_pads, 0, sizeof(g_pads)); From aab4f3032a70afe17b4e96f569533e0599b12618 Mon Sep 17 00:00:00 2001 From: Mike Robinson Date: Sat, 4 Oct 2014 18:59:31 +0100 Subject: [PATCH 4/7] Add reporting of autodetected non-connected pins --- input/parport_joypad.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/input/parport_joypad.c b/input/parport_joypad.c index 1b44b1eb68..3203d95a92 100644 --- a/input/parport_joypad.c +++ b/input/parport_joypad.c @@ -219,7 +219,10 @@ static void destroy_pad(struct parport_joypad *pad) static bool parport_joypad_init(void) { unsigned i, j; - bool found_button; + bool found_enabled_button; + bool found_disabled_button; + char buf[NUM_BUTTONS * 3 + 1]; + char pin[3 + 1]; for (i = 0; i < MAX_PLAYERS; i++) { @@ -238,25 +241,46 @@ static bool parport_joypad_init(void) * so assume the user is not holding any button on startup * and disable any low pins. */ - for (j = 0; j < NUM_BUTTONS; j++) - pad->button_enable[j] = true; - poll_pad(pad); - found_button = false; + found_enabled_button = false; + found_disabled_button = false; for (j = 0; j < NUM_BUTTONS; j++) { if (!pad->buttons[j]) - found_button = true; + { + pad->button_enable[j] = true; + found_enabled_button = true; + } else + { pad->button_enable[j] = false; + found_disabled_button = true; + } } - if (found_button) + if (found_enabled_button) + { + if (found_disabled_button) + { + buf[0] = '\0'; + for (j = 0; j < NUM_BUTTONS; j++) + { + if (!pad->button_enable[j]) + { + snprintf(pin, sizeof(pin), "%d ", j); + strlcat(buf, pin, sizeof(buf)); + } + } + RARCH_WARN("[Joypad]: Pin(s) %son %s were low on init, assuming not connected\n", \ + buf, path); + } input_config_autoconfigure_joypad(i, pad->ident, 0, 0, "parport"); + } else { - destroy_pad(pad); /* assume nothing was connected */ + RARCH_WARN("[Joypad]: All pins low on %s, assuming nothing connected\n", path); + destroy_pad(pad); input_config_autoconfigure_joypad(i, NULL, 0, 0, NULL); } } From bf5cbfacee0004b291a85f7696ebf9d468386dc4 Mon Sep 17 00:00:00 2001 From: Mike Robinson Date: Sat, 4 Oct 2014 19:00:09 +0100 Subject: [PATCH 5/7] Fix autodetection of non-connected status pins --- input/parport_joypad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/parport_joypad.c b/input/parport_joypad.c index 3203d95a92..c7b94aefb9 100644 --- a/input/parport_joypad.c +++ b/input/parport_joypad.c @@ -91,7 +91,7 @@ static void poll_pad(struct parport_joypad *pad) } for (i = 3; i < 8; i++) { - pad->buttons[i + 5] = !(status & UINT8_C(1 << i)) && pad->button_enable[i]; + pad->buttons[i + 5] = !(status & UINT8_C(1 << i)) && pad->button_enable[i + 5]; } pad->buttons[12] = pad->buttons[12] ? false : true && pad->button_enable[12]; } From f3a0e58bd99a0ecde883e66581c8323bfdf6914d Mon Sep 17 00:00:00 2001 From: Mike Robinson Date: Sat, 4 Oct 2014 22:04:38 +0100 Subject: [PATCH 6/7] Add HAVE_PARPORT build option --- Makefile.common | 8 ++++++-- input/input_common.c | 2 ++ qb/config.libs.sh | 5 ++++- qb/config.params.sh | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile.common b/Makefile.common index bbea4f8b3a..825291691d 100644 --- a/Makefile.common +++ b/Makefile.common @@ -59,8 +59,8 @@ endif ifneq ($(findstring Linux,$(OS)),) LIBS += -lrt JOYCONFIG_LIBS += -lrt - OBJ += input/linuxraw_input.o input/linuxraw_joypad.o input/parport_joypad.o - JOYCONFIG_OBJ += tools/linuxraw_joypad.o tools/parport_joypad.o + OBJ += input/linuxraw_input.o input/linuxraw_joypad.o + JOYCONFIG_OBJ += tools/linuxraw_joypad.o endif ifeq ($(findstring Haiku,$(OS)),) @@ -336,6 +336,10 @@ ifeq ($(HAVE_UDEV), 1) JOYCONFIG_OBJ += tools/udev_joypad.o endif +ifeq ($(HAVE_PARPORT), 1) + OBJ += input/parport_joypad.o + JOYCONFIG_OBJ += tools/parport_joypad.o +endif # Video # diff --git a/input/input_common.c b/input/input_common.c index 6ccb262395..97a3b3c36b 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -75,6 +75,8 @@ rarch_joypad_driver_t *joypad_drivers[] = { #endif #if defined(__linux) && !defined(ANDROID) &linuxraw_joypad, +#endif +#ifdef HAVE_PARPORT &parport_joypad, #endif #ifdef ANDROID diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 6f58ad53d8..f84a3aaddf 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -324,6 +324,9 @@ if [ "$HAVE_UDEV" != "no" ]; then fi fi +check_header PARPORT linux/parport.h +check_header PARPORT linux/ppdev.h + check_lib STRL "$CLIB" strlcpy check_lib STRCASESTR "$CLIB" strcasestr check_lib MMAP "$CLIB" mmap @@ -336,6 +339,6 @@ add_define_make OS "$OS" # Creates config.mk and config.h. add_define_make GLOBAL_CONFIG_DIR "$GLOBAL_CONFIG_DIR" -VARS="RGUI LAKKA GLUI ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL SDL2 D3D9 DINPUT WINXINPUT DSOUND XAUDIO OPENGL LIMA OMAP GLES GLES3 VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG LIBXML2 ZLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE FREETYPE XKBCOMMON XVIDEO X11 XEXT XF86VM XINERAMA WAYLAND MALI_FBDEV VIVANTE_FBDEV NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL STRCASESTR MMAP PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 BSV_MOVIE VIDEOCORE NEON FLOATHARD FLOATSOFTFP UDEV V4L2 AV_CHANNEL_LAYOUT 7ZIP" +VARS="RGUI LAKKA GLUI ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL SDL2 D3D9 DINPUT WINXINPUT DSOUND XAUDIO OPENGL LIMA OMAP GLES GLES3 VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG LIBXML2 ZLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE FREETYPE XKBCOMMON XVIDEO X11 XEXT XF86VM XINERAMA WAYLAND MALI_FBDEV VIVANTE_FBDEV NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL STRCASESTR MMAP PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 BSV_MOVIE VIDEOCORE NEON FLOATHARD FLOATSOFTFP UDEV V4L2 AV_CHANNEL_LAYOUT 7ZIP PARPORT" create_config_make config.mk $VARS create_config_header config.h $VARS diff --git a/qb/config.params.sh b/qb/config.params.sh index 523da197d2..897b3173c8 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -47,3 +47,4 @@ HAVE_FLOATHARD=no # Force hard float ABI (for ARM) HAVE_FLOATSOFTFP=no # Force soft float ABI (for ARM) HAVE_7ZIP=yes # Compile in 7z support HAVE_PRESERVE_DYLIB=no # Disable dlclose() for Valgrind support +HAVE_PARPORT=auto # Parallel port joypad support From 02185efe1031266092bb27dc734846d1cbf66902 Mon Sep 17 00:00:00 2001 From: Mike Robinson Date: Sat, 4 Oct 2014 22:27:02 +0100 Subject: [PATCH 7/7] Add support for bind autoconfiguration --- input/parport_joypad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/parport_joypad.c b/input/parport_joypad.c index c7b94aefb9..ef8430dbba 100644 --- a/input/parport_joypad.c +++ b/input/parport_joypad.c @@ -275,7 +275,7 @@ static bool parport_joypad_init(void) RARCH_WARN("[Joypad]: Pin(s) %son %s were low on init, assuming not connected\n", \ buf, path); } - input_config_autoconfigure_joypad(i, pad->ident, 0, 0, "parport"); + input_config_autoconfigure_joypad(i, "Generic Parallel Port device", 0, 0, "parport"); } else {