mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 13:20:30 +00:00
Kill off IS_JOYCONFIG
This commit is contained in:
parent
9deeececf1
commit
1b7576aa64
23
Makefile
23
Makefile
@ -17,7 +17,6 @@ ifeq ($(GLOBAL_CONFIG_DIR),)
|
||||
endif
|
||||
|
||||
OBJ :=
|
||||
JOYCONFIG_OBJ :=
|
||||
LIBS :=
|
||||
DEFINES := -DHAVE_CONFIG_H -DRARCH_INTERNAL -DHAVE_OVERLAY
|
||||
DEFINES += -DGLOBAL_CONFIG_DIR='"$(GLOBAL_CONFIG_DIR)"'
|
||||
@ -96,7 +95,6 @@ ifeq ($(NOUNUSED_VARIABLE), yes)
|
||||
endif
|
||||
|
||||
RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
|
||||
RARCH_JOYCONFIG_OBJ := $(addprefix $(OBJDIR)/,$(JOYCONFIG_OBJ))
|
||||
|
||||
ifneq ($(SANITIZER),)
|
||||
CFLAGS := -fsanitize=$(SANITIZER) $(CFLAGS)
|
||||
@ -106,7 +104,7 @@ endif
|
||||
|
||||
all: $(TARGET) $(JTARGET) config.mk
|
||||
|
||||
-include $(RARCH_OBJ:.o=.d) $(RARCH_JOYCONFIG_OBJ:.o=.d)
|
||||
-include $(RARCH_OBJ:.o=.d)
|
||||
config.mk: configure qb/*
|
||||
@echo "config.mk is outdated or non-existing. Run ./configure again."
|
||||
@exit 1
|
||||
@ -115,10 +113,6 @@ retroarch: $(RARCH_OBJ)
|
||||
@$(if $(Q), $(shell echo echo LD $@),)
|
||||
$(Q)$(LINK) -o $@ $(RARCH_OBJ) $(LIBS) $(LDFLAGS) $(LIBRARY_DIRS)
|
||||
|
||||
$(JTARGET): $(RARCH_JOYCONFIG_OBJ)
|
||||
@$(if $(Q), $(shell echo echo LD $@),)
|
||||
$(Q)$(LINK) -o $@ $(RARCH_JOYCONFIG_OBJ) $(JOYCONFIG_LIBS) $(LDFLAGS) $(LIBRARY_DIRS)
|
||||
|
||||
$(OBJDIR)/%.o: %.c config.h config.mk
|
||||
@mkdir -p $(dir $@)
|
||||
@$(if $(Q), $(shell echo echo CC $<),)
|
||||
@ -141,21 +135,6 @@ $(OBJDIR)/git_version.o: git_version.c .FORCE
|
||||
@$(if $(Q), $(shell echo echo CC $<),)
|
||||
$(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -c -o $@ $<
|
||||
|
||||
$(OBJDIR)/tools/linuxraw_joypad.o: input/linuxraw_joypad.c
|
||||
@mkdir -p $(dir $@)
|
||||
@$(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 $<),)
|
||||
$(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $<
|
||||
|
||||
$(OBJDIR)/%.o: %.S config.h config.mk $(HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
@$(if $(Q), $(shell echo echo AS $<),)
|
||||
|
@ -28,7 +28,6 @@ endif
|
||||
|
||||
ifeq ($(HAVE_DYLIB), 1)
|
||||
DEFINES += -DHAVE_DYLIB
|
||||
JOYCONFIG_LIBS += $(DYLIB_LIB)
|
||||
endif
|
||||
|
||||
ifeq ($(SCALER_NO_SIMD), 1)
|
||||
@ -71,14 +70,12 @@ endif
|
||||
ifneq ($(findstring Darwin,$(OS)),)
|
||||
OSX := 1
|
||||
LIBS += -framework AppKit
|
||||
JOYCONFIG_LIBS += -framework CoreFoundation
|
||||
else
|
||||
OSX := 0
|
||||
endif
|
||||
|
||||
ifneq ($(findstring Linux,$(OS)),)
|
||||
LIBS += -lrt
|
||||
JOYCONFIG_LIBS += -lrt -lpthread
|
||||
OBJ += input/drivers/linuxraw_input.o \
|
||||
input/drivers_joypad/linuxraw_joypad.o \
|
||||
frontend/drivers/platform_linux.o
|
||||
@ -499,7 +496,6 @@ ifeq ($(HAVE_DINPUT), 1)
|
||||
DEFINES += -DHAVE_DINPUT
|
||||
OBJ += input/drivers/dinput.o \
|
||||
input/drivers_joypad/dinput_joypad.o
|
||||
JOYCONFIG_LIBS += -ldinput8 -ldxguid -lole32
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_XINPUT), 1)
|
||||
@ -526,7 +522,6 @@ endif
|
||||
ifeq ($(HAVE_UDEV), 1)
|
||||
DEFINES += $(UDEV_CFLAGS)
|
||||
LIBS += $(UDEV_LIBS)
|
||||
JOYCONFIG_LIBS += $(UDEV_LIBS)
|
||||
OBJ += input/drivers/udev_input.o \
|
||||
input/drivers_joypad/udev_joypad.o
|
||||
endif
|
||||
@ -535,7 +530,6 @@ ifeq ($(HAVE_LIBUSB), 1)
|
||||
DEFINES += -DHAVE_LIBUSB
|
||||
OBJ += input/drivers_hid/libusb_hid.o
|
||||
LIBS += -lusb-1.0
|
||||
JOYCONFIG_LIBS += -lusb-1.0
|
||||
HAVE_HID = 1
|
||||
endif
|
||||
|
||||
@ -544,7 +538,6 @@ ifeq ($(HAVE_IOHIDMANAGER), 1)
|
||||
OBJ += input/drivers_hid/iohidmanager_hid.o
|
||||
HAVE_HID = 1
|
||||
LIBS += -framework IOKit
|
||||
JOYCONFIG_LIBS += -framework IOKit
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_CORELOCATION), 1)
|
||||
@ -674,7 +667,6 @@ ifeq ($(HAVE_SDL), 1)
|
||||
OBJ += gfx/drivers_context/sdl_gl_ctx.o
|
||||
endif
|
||||
|
||||
JOYCONFIG_LIBS += $(SDL_LIBS)
|
||||
DEFINES += $(SDL_CFLAGS) $(BSD_LOCAL_INC)
|
||||
LIBS += $(SDL_LIBS)
|
||||
endif
|
||||
@ -689,7 +681,6 @@ ifeq ($(HAVE_SDL2), 1)
|
||||
OBJ += gfx/drivers_context/sdl_gl_ctx.o
|
||||
endif
|
||||
|
||||
JOYCONFIG_LIBS += $(SDL2_LIBS)
|
||||
DEFINES += $(SDL2_CFLAGS) $(BSD_LOCAL_INC)
|
||||
LIBS += $(SDL2_LIBS)
|
||||
HAVE_SDL = 0
|
||||
@ -927,7 +918,3 @@ ifeq ($(HAVE_COCOA),1)
|
||||
ui/drivers/cocoa/cocoa_common.o \
|
||||
gfx/drivers_context/cocoa_gl_ctx.o
|
||||
endif
|
||||
|
||||
|
||||
# Joyconfig binary
|
||||
JOYCONFIG_OBJ += tools/retroarch-joyconfig-griffin.o
|
||||
|
@ -339,7 +339,6 @@ void input_config_parse_joy_axis(config_file_t *conf, const char *prefix,
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(IS_JOYCONFIG)
|
||||
static void input_get_bind_string_joykey(char *buf, const char *prefix,
|
||||
const struct retro_keybind *bind, size_t size)
|
||||
{
|
||||
@ -434,7 +433,6 @@ void input_get_bind_string(char *buf, const struct retro_keybind *bind,
|
||||
strlcat(buf, keybuf, size);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* input_push_analog_dpad:
|
||||
|
@ -20,9 +20,7 @@
|
||||
|
||||
#include "input_hid_driver.h"
|
||||
#include "../general.h"
|
||||
#ifndef IS_JOYCONFIG
|
||||
#include "../string_list_special.h"
|
||||
#endif
|
||||
|
||||
static hid_driver_t *hid_drivers[] = {
|
||||
#if defined(__APPLE__) && defined(IOS)
|
||||
@ -71,7 +69,6 @@ const char *hid_driver_find_ident(int idx)
|
||||
return drv->ident;
|
||||
}
|
||||
|
||||
#ifndef IS_JOYCONFIG
|
||||
/**
|
||||
* config_get_hid_driver_options:
|
||||
*
|
||||
@ -83,7 +80,6 @@ const char* config_get_hid_driver_options(void)
|
||||
{
|
||||
return char_list_new_special(STRING_LIST_INPUT_HID_DRIVERS, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* input_hid_init_first:
|
||||
|
@ -20,9 +20,7 @@
|
||||
|
||||
#include "input_keymaps.h"
|
||||
#include "../general.h"
|
||||
#ifndef IS_JOYCONFIG
|
||||
#include "../string_list_special.h"
|
||||
#endif
|
||||
|
||||
static input_device_driver_t *joypad_drivers[] = {
|
||||
#ifdef __CELLOS_LV2__
|
||||
@ -99,7 +97,6 @@ const char *joypad_driver_find_ident(int idx)
|
||||
return drv->ident;
|
||||
}
|
||||
|
||||
#ifndef IS_JOYCONFIG
|
||||
/**
|
||||
* config_get_joypad_driver_options:
|
||||
*
|
||||
@ -111,7 +108,6 @@ const char* config_get_joypad_driver_options(void)
|
||||
{
|
||||
return char_list_new_special(STRING_LIST_INPUT_JOYPAD_DRIVERS, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* input_joypad_init_driver:
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <compat/posix_string.h>
|
||||
#include <compat/strl.h>
|
||||
|
||||
#if defined(HAVE_FILE_LOGGER) && defined(RARCH_INTERNAL) && !defined(IS_JOYCONFIG)
|
||||
#if defined(HAVE_FILE_LOGGER) && defined(RARCH_INTERNAL)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
@ -1,115 +0,0 @@
|
||||
/* RetroArch JoyConfig.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define IS_JOYCONFIG
|
||||
|
||||
#include <retro_environment.h>
|
||||
|
||||
#include "retroarch-joyconfig.c"
|
||||
|
||||
#include "../libretro-common/dynamic/dylib.c"
|
||||
#include "../libretro-common/file/retro_file.c"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../libretro-common/file/retro_stat.c"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__linux) && !defined(ANDROID)
|
||||
#include "../input/drivers/linuxraw_input.c"
|
||||
#include "../input/drivers_joypad/linuxraw_joypad.c"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DINPUT)
|
||||
#include "../input/drivers/dinput.c"
|
||||
#include "../input/drivers_joypad/dinput_joypad.c"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_XINPUT)
|
||||
#include "../input/drivers_joypad/xinput_joypad.c"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_UDEV)
|
||||
#include "../input/drivers_joypad/udev_joypad.c"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_PARPORT)
|
||||
#include "../input/drivers_joypad/parport_joypad.c"
|
||||
#endif
|
||||
|
||||
#if __cplusplus || __STDC_VERSION__ >= 199901L
|
||||
#if defined(HAVE_SDL) || defined(HAVE_SDL2)
|
||||
#include "../input/drivers_joypad/sdl_joypad.c"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "../libretro-common/queues/fifo_buffer.c"
|
||||
#include "../libretro-common/file/config_file.c"
|
||||
#include "../libretro-common/file/file_path.c"
|
||||
#include "../libretro-common/hash/rhash.c"
|
||||
#include "../file_path_special.c"
|
||||
#include "../libretro-common/string/string_list.c"
|
||||
#include "../libretro-common/compat/compat_strl.c"
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#include "../libretro-common/compat/compat_posix_string.c"
|
||||
#include "../libretro-common/compat/compat_getopt.c"
|
||||
#endif
|
||||
|
||||
#include "../input/drivers/nullinput.c"
|
||||
#include "../input/drivers_hid/null_hid.c"
|
||||
|
||||
#include "../libretro-common/rthreads/rthreads.c"
|
||||
|
||||
#if __cplusplus || __STDC_VERSION__ >= 199901L
|
||||
#ifdef HAVE_LIBUSB
|
||||
#include "../input/drivers_hid/libusb_hid.c"
|
||||
|
||||
#ifndef HAVE_HID
|
||||
#define HAVE_HID
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) && defined(HAVE_IOHIDMANAGER)
|
||||
#include "../input/drivers_hid/iohidmanager_hid.c"
|
||||
|
||||
#ifndef HAVE_HID
|
||||
#define HAVE_HID
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HID
|
||||
#include "../input/connect/joypad_connection.c"
|
||||
#include "../input/connect/connect_ps3.c"
|
||||
#include "../input/connect/connect_ps4.c"
|
||||
#include "../input/connect/connect_wii.c"
|
||||
#endif
|
||||
|
||||
#include "../input/drivers_joypad/hid_joypad.c"
|
||||
#include "../input/drivers_joypad/null_joypad.c"
|
||||
|
||||
#include "../input/input_hid_driver.c"
|
||||
#include "../input/input_joypad_driver.c"
|
||||
#include "../input/input_joypad.c"
|
||||
#include "../input/input_common.c"
|
||||
#include "../input/input_keymaps.c"
|
||||
|
||||
#include "../libretro-common/queues/message_queue.c"
|
@ -1,538 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <file/config_file.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <compat/getopt.h>
|
||||
#include <compat/posix_string.h>
|
||||
#include <boolean.h>
|
||||
#include "../input/input_common.h"
|
||||
#include "../input/input_joypad.h"
|
||||
#include "../input/input_autodetect.h"
|
||||
#include "../general.h"
|
||||
#include "../runloop.h"
|
||||
#include <assert.h>
|
||||
|
||||
/* Need to be present for build to work, but it's not *really* used.
|
||||
* Better than having to build special versions of lots of objects
|
||||
* with special #ifdefs.
|
||||
*/
|
||||
struct settings g_config;
|
||||
struct global g_extern;
|
||||
driver_t driver;
|
||||
|
||||
static int g_player = 1;
|
||||
static int g_joypad = 0;
|
||||
static int g_timeout = 0;
|
||||
static char *g_in_path = NULL;
|
||||
static char *g_out_path = NULL;
|
||||
static char *g_auto_path = NULL;
|
||||
static char *g_driver = NULL;
|
||||
static unsigned g_meta_level = 0;
|
||||
|
||||
bool retro_main_verbosity(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
settings_t *config_get_ptr(void)
|
||||
{
|
||||
return &g_config;
|
||||
}
|
||||
|
||||
driver_t *driver_get_ptr(void)
|
||||
{
|
||||
return &driver;
|
||||
}
|
||||
|
||||
static void print_help(void)
|
||||
{
|
||||
puts("=====================");
|
||||
puts(" retroarch-joyconfig");
|
||||
puts("=====================");
|
||||
puts("Usage: retroarch-joyconfig [ options ... ]");
|
||||
puts("");
|
||||
puts("-p/--player: Which player to configure for (1 up to and including 8).");
|
||||
puts("-j/--joypad: Which joypad to use when configuring (first joypad is 0).");
|
||||
puts("-i/--input: Input file to configure with. Binds will be added on or overwritten.");
|
||||
puts("\tIf not selected, an empty config will be used as a base.");
|
||||
puts("-o/--output: Output file to write to. If not selected, config file will be dumped to stdout.");
|
||||
puts("-a/--autoconfig: Outputs an autoconfig file for joypad which was configured.");
|
||||
puts("-M/--allmisc: Also configure various keybinds that are not directly libretro related.");
|
||||
puts("\tThese configurations are for player 1 only.");
|
||||
puts("-m/--misc: Same as --allmisc, but exposes a smaller subset of misc binds which are deemed most useful for regular use.");
|
||||
puts("-t/--timeout: Adds a timeout of N seconds to each bind. If timed out, the bind will not be used.");
|
||||
puts("-d/--driver: Uses a specific joypad driver.");
|
||||
puts("-h/--help: This help.");
|
||||
}
|
||||
|
||||
#define MAX_BUTTONS 64
|
||||
#define MAX_AXES 32
|
||||
#define MAX_HATS 32
|
||||
struct poll_data
|
||||
{
|
||||
bool buttons[MAX_BUTTONS];
|
||||
int16_t axes[MAX_AXES];
|
||||
uint16_t hats[MAX_HATS];
|
||||
};
|
||||
|
||||
static void poll_joypad(const input_device_driver_t *driver,
|
||||
unsigned pad,
|
||||
struct poll_data *data)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if (driver)
|
||||
driver->poll();
|
||||
|
||||
for (i = 0; i < MAX_BUTTONS; i++)
|
||||
data->buttons[i] = input_joypad_button_raw(driver, pad, i);
|
||||
|
||||
for (i = 0; i < MAX_AXES; i++)
|
||||
data->axes[i] = input_joypad_axis_raw(driver, pad, i);
|
||||
|
||||
for (i = 0; i < MAX_HATS; i++)
|
||||
{
|
||||
uint16_t hat = 0;
|
||||
hat |= input_joypad_hat_raw(driver, pad, HAT_UP_MASK, i) << HAT_UP_SHIFT;
|
||||
hat |= input_joypad_hat_raw(driver, pad, HAT_DOWN_MASK, i) << HAT_DOWN_SHIFT;
|
||||
hat |= input_joypad_hat_raw(driver, pad, HAT_LEFT_MASK, i) << HAT_LEFT_SHIFT;
|
||||
hat |= input_joypad_hat_raw(driver, pad, HAT_RIGHT_MASK, i) << HAT_RIGHT_SHIFT;
|
||||
|
||||
data->hats[i] = hat;
|
||||
}
|
||||
}
|
||||
|
||||
static void get_binds(config_file_t *conf, config_file_t *auto_conf,
|
||||
int player, int joypad)
|
||||
{
|
||||
int i, timeout_cnt;
|
||||
const input_device_driver_t *driver = input_joypad_init_driver(g_driver, NULL);
|
||||
const char *joypad_name;
|
||||
|
||||
int16_t initial_axes[MAX_AXES] = {0};
|
||||
struct poll_data old_poll = {{0}};
|
||||
struct poll_data new_poll = {{0}};
|
||||
|
||||
int last_axis = -1;
|
||||
bool block_axis = false;
|
||||
|
||||
int timeout_ticks = g_timeout * 100;
|
||||
|
||||
if (!driver)
|
||||
{
|
||||
fprintf(stderr, "Cannot find any valid input driver.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!driver->query_pad(joypad))
|
||||
{
|
||||
fprintf(stderr, "Couldn't open joystick #%d.\n", joypad);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Found joypad driver: %s\n", driver->ident);
|
||||
joypad_name = input_joypad_name(driver, joypad);
|
||||
fprintf(stderr, "Using joypad: %s\n", joypad_name ? joypad_name : "Unknown");
|
||||
|
||||
if (joypad_name && auto_conf)
|
||||
{
|
||||
config_set_string(auto_conf, "input_device", joypad_name);
|
||||
config_set_string(auto_conf, "input_driver", driver->ident);
|
||||
}
|
||||
|
||||
poll_joypad(driver, joypad, &old_poll);
|
||||
fprintf(stderr, "\nJoypads tend to have stale state after opened.\nPress some buttons and move some axes around to make sure joypad state is completely neutral before proceeding.\nWhen done, press Enter ... ");
|
||||
getchar();
|
||||
poll_joypad(driver, joypad, &old_poll);
|
||||
|
||||
for (i = 0; i < MAX_AXES; i++)
|
||||
{
|
||||
int16_t initial = input_joypad_axis_raw(driver, joypad, i);
|
||||
if (abs(initial) < 20000)
|
||||
initial = 0;
|
||||
|
||||
/* Certain joypads (such as XBox360 controller on Linux)
|
||||
* has a default negative axis for shoulder triggers,
|
||||
* which makes configuration very awkward.
|
||||
*
|
||||
* If default negative, we can't trigger on the negative axis,
|
||||
* and similar with defaulted positive axes.
|
||||
*/
|
||||
|
||||
if (initial)
|
||||
fprintf(stderr, "Axis %d is defaulted to %s axis value of %d.\n", i, initial > 0 ? "positive" : "negative", initial);
|
||||
|
||||
initial_axes[i] = initial;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_BUTTONS; i++)
|
||||
{
|
||||
if (old_poll.buttons[i])
|
||||
fprintf(stderr, "Button %d was initially pressed. This indicates broken initial state.\n", i);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Configuring binds for player #%d on joypad #%d.\n\n",
|
||||
player + 1, joypad);
|
||||
|
||||
for (i = 0, timeout_cnt = 0; input_config_bind_map[i].valid; i++, timeout_cnt = 0)
|
||||
{
|
||||
unsigned meta_level;
|
||||
unsigned player_index;
|
||||
int j;
|
||||
if (i == RARCH_TURBO_ENABLE)
|
||||
continue;
|
||||
|
||||
meta_level = input_config_bind_map[i].meta;
|
||||
if (meta_level > g_meta_level)
|
||||
continue;
|
||||
|
||||
fprintf(stderr, "%s\n", input_config_bind_map[i].desc);
|
||||
|
||||
player_index = input_config_bind_map[i].meta ? 0 : player;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
old_poll = new_poll;
|
||||
|
||||
/* To avoid pegging CPU.
|
||||
* Ideally use an event-based joypad scheme,
|
||||
* but it adds far more complexity, so, meh.
|
||||
*/
|
||||
retro_sleep(10);
|
||||
|
||||
if (timeout_ticks)
|
||||
{
|
||||
timeout_cnt++;
|
||||
if (timeout_cnt >= timeout_ticks)
|
||||
{
|
||||
fprintf(stderr, "\tTimed out ...\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
poll_joypad(driver, joypad, &new_poll);
|
||||
for (j = 0; j < MAX_BUTTONS; j++)
|
||||
{
|
||||
if (new_poll.buttons[j] && !old_poll.buttons[j])
|
||||
{
|
||||
char key[64] = {0};
|
||||
|
||||
fprintf(stderr, "\tJoybutton pressed: %d\n", j);
|
||||
|
||||
snprintf(key, sizeof(key), "%s_%s_btn",
|
||||
input_config_get_prefix(player_index,
|
||||
input_config_bind_map[i].meta),
|
||||
input_config_bind_map[i].base);
|
||||
config_set_int(conf, key, j);
|
||||
|
||||
if (auto_conf)
|
||||
{
|
||||
snprintf(key, sizeof(key), "input_%s_btn",
|
||||
input_config_bind_map[i].base);
|
||||
config_set_int(auto_conf, key, j);
|
||||
}
|
||||
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < MAX_AXES; j++)
|
||||
{
|
||||
int16_t value;
|
||||
bool same_axis;
|
||||
bool require_negative;
|
||||
bool require_positive;
|
||||
|
||||
if (new_poll.axes[j] == old_poll.axes[j])
|
||||
continue;
|
||||
|
||||
value = new_poll.axes[j];
|
||||
same_axis = last_axis == j;
|
||||
require_negative = initial_axes[j] > 0;
|
||||
require_positive = initial_axes[j] < 0;
|
||||
|
||||
/* Block the axis config until we're sure
|
||||
* axes have returned to their neutral state. */
|
||||
if (same_axis)
|
||||
{
|
||||
if (abs(value) < 10000 ||
|
||||
(require_positive && value < 0) ||
|
||||
(require_negative && value > 0))
|
||||
block_axis = false;
|
||||
}
|
||||
|
||||
/* If axes are in their neutral state,
|
||||
* we can't allow it. */
|
||||
if (require_negative && value >= 0)
|
||||
continue;
|
||||
if (require_positive && value <= 0)
|
||||
continue;
|
||||
|
||||
if (block_axis)
|
||||
continue;
|
||||
|
||||
if (abs(value) > 20000)
|
||||
{
|
||||
char buf[8] = {0};
|
||||
char key[64] = {0};
|
||||
|
||||
last_axis = j;
|
||||
fprintf(stderr, "\tJoyaxis moved: Axis %d, Value %d\n",
|
||||
j, value);
|
||||
|
||||
snprintf(buf, sizeof(buf),
|
||||
value > 0 ? "+%d" : "-%d", j);
|
||||
|
||||
snprintf(key, sizeof(key), "%s_%s_axis",
|
||||
input_config_get_prefix(player_index,
|
||||
input_config_bind_map[i].meta),
|
||||
input_config_bind_map[i].base);
|
||||
|
||||
config_set_string(conf, key, buf);
|
||||
|
||||
if (auto_conf)
|
||||
{
|
||||
snprintf(key, sizeof(key), "input_%s_axis",
|
||||
input_config_bind_map[i].base);
|
||||
config_set_string(auto_conf, key, buf);
|
||||
}
|
||||
|
||||
block_axis = true;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < MAX_HATS; j++)
|
||||
{
|
||||
const char *quark = NULL;
|
||||
uint16_t value = new_poll.hats[j];
|
||||
uint16_t old_value = old_poll.hats[j];
|
||||
|
||||
if ((value & HAT_UP_MASK) && !(old_value & HAT_UP_MASK))
|
||||
quark = "up";
|
||||
else if ((value & HAT_LEFT_MASK) && !(old_value & HAT_LEFT_MASK))
|
||||
quark = "left";
|
||||
else if ((value & HAT_RIGHT_MASK) && !(old_value & HAT_RIGHT_MASK))
|
||||
quark = "right";
|
||||
else if ((value & HAT_DOWN_MASK) && !(old_value & HAT_DOWN_MASK))
|
||||
quark = "down";
|
||||
|
||||
if (quark)
|
||||
{
|
||||
char buf[16] = {0};
|
||||
char key[64] = {0};
|
||||
|
||||
fprintf(stderr, "\tJoyhat moved: Hat %d, direction %s\n", j, quark);
|
||||
snprintf(buf, sizeof(buf), "h%d%s", j, quark);
|
||||
|
||||
snprintf(key, sizeof(key), "%s_%s_btn",
|
||||
input_config_get_prefix(player_index,
|
||||
input_config_bind_map[i].meta),
|
||||
input_config_bind_map[i].base);
|
||||
|
||||
config_set_string(conf, key, buf);
|
||||
|
||||
if (auto_conf)
|
||||
{
|
||||
snprintf(key, sizeof(key), "input_%s_btn",
|
||||
input_config_bind_map[i].base);
|
||||
config_set_string(auto_conf, key, buf);
|
||||
}
|
||||
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
out:
|
||||
old_poll = new_poll;
|
||||
}
|
||||
}
|
||||
|
||||
static void parse_input(int argc, char *argv[])
|
||||
{
|
||||
char optstring[] = "i:o:a:p:j:t:hmMd:";
|
||||
struct option opts[] = {
|
||||
{ "input", 1, NULL, 'i' },
|
||||
{ "output", 1, NULL, 'o' },
|
||||
{ "autoconfig", 1, NULL, 'a' },
|
||||
{ "player", 1, NULL, 'p' },
|
||||
{ "joypad", 1, NULL, 'j' },
|
||||
{ "help", 0, NULL, 'h' },
|
||||
{ "misc", 0, NULL, 'm' },
|
||||
{ "allmisc", 0, NULL, 'M' },
|
||||
{ "timeout", 1, NULL, 't' },
|
||||
{ "driver", 1, NULL, 'd' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
int option_index = 0;
|
||||
for (;;)
|
||||
{
|
||||
int c = getopt_long(argc, argv, optstring, opts, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 'h':
|
||||
print_help();
|
||||
exit(0);
|
||||
|
||||
case 'i':
|
||||
g_in_path = strdup(optarg);
|
||||
break;
|
||||
|
||||
case 't':
|
||||
g_timeout = strtol(optarg, NULL, 0);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
g_driver = strdup(optarg);
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
g_out_path = strdup(optarg);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
g_auto_path = strdup(optarg);
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
g_meta_level = 1;
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
g_meta_level = 2;
|
||||
break;
|
||||
|
||||
case 'j':
|
||||
g_joypad = strtol(optarg, NULL, 0);
|
||||
if (g_joypad < 0)
|
||||
{
|
||||
fprintf(stderr, "Joypad number can't be negative.\n");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
g_player = strtol(optarg, NULL, 0);
|
||||
if (g_player < 1)
|
||||
{
|
||||
fprintf(stderr, "User number must be at least 1.\n");
|
||||
exit(1);
|
||||
}
|
||||
else if (g_player > MAX_USERS)
|
||||
{
|
||||
fprintf(stderr, "User number must be from 1 to %d.\n",
|
||||
MAX_USERS);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
print_help();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool input_config_autoconfigure_joypad(autoconfig_params_t *params)
|
||||
{
|
||||
(void)params;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Need SDL_main on OSX. */
|
||||
#ifndef __APPLE__
|
||||
#undef main
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
config_file_t *conf;
|
||||
config_file_t *auto_conf = NULL;
|
||||
|
||||
const char *index_list[] = {
|
||||
"input_player1_joypad_index",
|
||||
"input_player2_joypad_index",
|
||||
"input_player3_joypad_index",
|
||||
"input_player4_joypad_index",
|
||||
"input_player5_joypad_index",
|
||||
"input_player6_joypad_index",
|
||||
"input_player7_joypad_index",
|
||||
"input_player8_joypad_index",
|
||||
};
|
||||
|
||||
parse_input(argc, argv);
|
||||
|
||||
conf = config_file_new(g_in_path);
|
||||
if (!conf)
|
||||
{
|
||||
fprintf(stderr, "Couldn't open config file ...\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
config_set_int(conf, index_list[g_player - 1], g_joypad);
|
||||
|
||||
if (g_auto_path)
|
||||
auto_conf = config_file_new(NULL);
|
||||
|
||||
get_binds(conf, auto_conf, g_player - 1, g_joypad);
|
||||
config_file_write(conf, g_out_path);
|
||||
config_file_free(conf);
|
||||
if (auto_conf)
|
||||
{
|
||||
fprintf(stderr, "Writing autoconfig profile to: %s.\n", g_auto_path);
|
||||
config_file_write(auto_conf, g_auto_path);
|
||||
config_file_free(auto_conf);
|
||||
}
|
||||
|
||||
free(g_in_path);
|
||||
free(g_out_path);
|
||||
free(g_auto_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rarch_main_msg_queue_push(const char *msg, unsigned prio, unsigned duration,
|
||||
bool flush)
|
||||
{
|
||||
}
|
||||
|
||||
bool video_driver_viewport_info(struct video_viewport *vp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool video_driver_read_viewport(uint8_t *buffer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void input_config_autoconfigure_disconnect(unsigned id, const char *msg)
|
||||
{
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user