From bab9ee307d61f0ae5fc61885a8b98ec3ffa01c82 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 27 Oct 2014 14:45:28 +0100 Subject: [PATCH] Add null joypad driver --- Makefile | 10 ++++++ Makefile.common | 3 ++ Makefile.win | 10 ++++++ config.def.h | 1 + griffin/griffin.c | 1 + input/input_context.c | 1 + input/input_context.h | 1 + input/nullinput_joypad.c | 67 ++++++++++++++++++++++++++++++++++++++++ settings.c | 2 ++ 9 files changed, 96 insertions(+) create mode 100644 input/nullinput_joypad.c diff --git a/Makefile b/Makefile index 2bf176e517..9e815845de 100644 --- a/Makefile +++ b/Makefile @@ -134,6 +134,16 @@ $(OBJDIR)/tools/input_common_joyconfig.o: input/input_common.c @$(if $(Q), $(shell echo echo CC $<),) $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $< +$(OBJDIR)/tools/nullinput_joyconfig.o: input/nullinput.c + @mkdir -p $(dir $@) + @$(if $(Q), $(shell echo echo CC $<),) + $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $< + +$(OBJDIR)/tools/nullinput_joypad_joyconfig.o: input/nullinput_joypad.c + @mkdir -p $(dir $@) + @$(if $(Q), $(shell echo echo CC $<),) + $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $< + $(OBJDIR)/tools/input_keymaps_joyconfig.o: input/input_keymaps.c @mkdir -p $(dir $@) @$(if $(Q), $(shell echo echo CC $<),) diff --git a/Makefile.common b/Makefile.common index 78d3f97339..ea35f77281 100644 --- a/Makefile.common +++ b/Makefile.common @@ -145,6 +145,7 @@ OBJ += frontend/frontend.o \ gfx/nullgfx.o \ audio/nullaudio.o \ input/nullinput.o \ + input/nullinput_joypad.o \ input/osk/nullosk.o \ playlist.o \ movie.o \ @@ -638,6 +639,8 @@ JOYCONFIG_OBJ += tools/retroarch-joyconfig.o \ libretro-sdk/file/file_path.o \ libretro-sdk/string/string_list.o \ libretro-sdk/compat/compat.o \ + input/nullinput.o \ + input/nullinput_joypad.o \ tools/input_context_joyconfig.o \ tools/input_common_joyconfig.o \ tools/input_keymaps_joyconfig.o diff --git a/Makefile.win b/Makefile.win index 167f95dd38..a38f504169 100644 --- a/Makefile.win +++ b/Makefile.win @@ -171,6 +171,16 @@ $(OBJDIR)/tools/input_context_joyconfig.o: input/input_context.c @$(if $(Q), $(shell echo echo CC $<),) $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $< +$(OBJDIR)/tools/nullinput_joyconfig.o: input/nullinput.c + @mkdir -p $(dir $@) + @$(if $(Q), $(shell echo echo CC $<),) + $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $< + +$(OBJDIR)/tools/nullinput_joypad_joyconfig.o: input/nullinput_joypad.c + @mkdir -p $(dir $@) + @$(if $(Q), $(shell echo echo CC $<),) + $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $< + $(OBJDIR)/%.o: %.cpp @mkdir -p $(dir $@) @$(if $(Q), $(shell echo echo CXX $<),) diff --git a/config.def.h b/config.def.h index 5d7f4909f9..46abc8df47 100644 --- a/config.def.h +++ b/config.def.h @@ -101,6 +101,7 @@ enum JOYPAD_APPLE_HID, JOYPAD_APPLE_IOS, JOYPAD_QNX, + JOYPAD_NULL, CAMERA_V4L2, CAMERA_RWEBCAM, diff --git a/griffin/griffin.c b/griffin/griffin.c index 1a2b86c94c..530c37a0ba 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -370,6 +370,7 @@ INPUT #endif #include "../input/nullinput.c" +#include "../input/nullinput_joypad.c" /*============================================================ STATE TRACKER diff --git a/input/input_context.c b/input/input_context.c index bee105cfba..51d1a51e46 100644 --- a/input/input_context.c +++ b/input/input_context.c @@ -66,6 +66,7 @@ rarch_joypad_driver_t *joypad_drivers[] = { #ifdef __QNX__ &qnx_joypad, #endif + &null_joypad, NULL, }; diff --git a/input/input_context.h b/input/input_context.h index f135e2d070..f01b907de9 100644 --- a/input/input_context.h +++ b/input/input_context.h @@ -62,6 +62,7 @@ extern rarch_joypad_driver_t apple_hid_joypad; extern rarch_joypad_driver_t apple_ios_joypad; extern rarch_joypad_driver_t android_joypad; extern rarch_joypad_driver_t qnx_joypad; +extern rarch_joypad_driver_t null_joypad; #ifdef __cplusplus } diff --git a/input/nullinput_joypad.c b/input/nullinput_joypad.c new file mode 100644 index 0000000000..22fb63163e --- /dev/null +++ b/input/nullinput_joypad.c @@ -0,0 +1,67 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2014 - Daniel De Matteis + * Copyright (C) 2013-2014 - CatalystG + * + * 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 +#include +#include +#include "input_context.h" + +static const char *null_joypad_name(unsigned pad) +{ + return "null"; +} + +static bool null_joypad_init(void) +{ + return true; +} + +static bool null_joypad_button(unsigned port_num, uint16_t joykey) +{ + return false; +} + +static int16_t null_joypad_axis(unsigned port_num, uint32_t joyaxis) +{ + return 0; +} + +static void null_joypad_poll(void) +{ +} + +static bool null_joypad_query_pad(unsigned pad) +{ + return true; +} + + +static void null_joypad_destroy(void) +{ +} + +rarch_joypad_driver_t null_joypad = { + null_joypad_init, + null_joypad_query_pad, + null_joypad_destroy, + null_joypad_button, + null_joypad_axis, + null_joypad_poll, + NULL, + null_joypad_name, + "null", +}; diff --git a/settings.c b/settings.c index 3bfd904e90..a3a2bca046 100644 --- a/settings.c +++ b/settings.c @@ -210,6 +210,8 @@ const char *config_get_default_joypad(void) return "apple_ios"; case JOYPAD_QNX: return "qnx"; + case JOYPAD_NULL: + return "null"; } return NULL;