mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-24 20:02:45 +00:00
(Joyconfig) Create retroarch-joyconfig-griffin.c - should be a lot
easier to maintain now instead of having to do constant Makefile maintenance
This commit is contained in:
parent
a43d4e74f6
commit
5f2a3e5bf7
25
Makefile
25
Makefile
@ -124,31 +124,6 @@ $(OBJDIR)/tools/udev_joypad.o: input/udev_joypad.c
|
||||
@$(if $(Q), $(shell echo echo CC $<),)
|
||||
$(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $<
|
||||
|
||||
$(OBJDIR)/tools/input_context_joyconfig.o: input/input_context.c
|
||||
@mkdir -p $(dir $@)
|
||||
@$(if $(Q), $(shell echo echo CC $<),)
|
||||
$(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $<
|
||||
|
||||
$(OBJDIR)/tools/input_common_joyconfig.o: input/input_common.c
|
||||
@mkdir -p $(dir $@)
|
||||
@$(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 $<),)
|
||||
$(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 $<),)
|
||||
|
@ -63,7 +63,6 @@ ifneq ($(findstring Linux,$(OS)),)
|
||||
LIBS += -lrt
|
||||
JOYCONFIG_LIBS += -lrt
|
||||
OBJ += input/linuxraw_input.o input/linuxraw_joypad.o
|
||||
JOYCONFIG_OBJ += tools/linuxraw_joypad.o
|
||||
endif
|
||||
|
||||
ifeq ($(findstring Haiku,$(OS)),)
|
||||
@ -323,14 +322,12 @@ ifeq ($(HAVE_DINPUT), 1)
|
||||
DEFINES += -DHAVE_DINPUT
|
||||
OBJ += input/dinput.o
|
||||
JOYCONFIG_LIBS += -ldinput8 -ldxguid -lole32
|
||||
JOYCONFIG_OBJ += input/dinput.o
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_WINXINPUT), 1)
|
||||
DEFINES += -DHAVE_WINXINPUT -DHAVE_BUILTIN_AUTOCONFIG
|
||||
OBJ += input/winxinput_joypad.o \
|
||||
input/autoconf/builtin_win.o
|
||||
JOYCONFIG_OBJ += input/winxinput_joypad.o
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_X11), 1)
|
||||
@ -349,12 +346,10 @@ ifeq ($(HAVE_UDEV), 1)
|
||||
LIBS += $(UDEV_LIBS)
|
||||
JOYCONFIG_LIBS += $(UDEV_LIBS)
|
||||
OBJ += input/udev_input.o input/udev_joypad.o
|
||||
JOYCONFIG_OBJ += tools/udev_joypad.o
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_PARPORT), 1)
|
||||
OBJ += input/parport_joypad.o
|
||||
JOYCONFIG_OBJ += tools/parport_joypad.o
|
||||
endif
|
||||
|
||||
# Video
|
||||
@ -451,7 +446,6 @@ ifeq ($(HAVE_SDL), 1)
|
||||
OBJ += gfx/context/sdl_gl_ctx.o
|
||||
endif
|
||||
|
||||
JOYCONFIG_OBJ += input/sdl_joypad.o
|
||||
JOYCONFIG_LIBS += $(SDL_LIBS)
|
||||
DEFINES += $(SDL_CFLAGS) $(BSD_LOCAL_INC)
|
||||
LIBS += $(SDL_LIBS)
|
||||
@ -464,7 +458,6 @@ ifeq ($(HAVE_SDL2), 1)
|
||||
OBJ += gfx/context/sdl_gl_ctx.o
|
||||
endif
|
||||
|
||||
JOYCONFIG_OBJ += input/sdl_joypad.o
|
||||
JOYCONFIG_LIBS += $(SDL2_LIBS)
|
||||
DEFINES += $(SDL2_CFLAGS) $(BSD_LOCAL_INC)
|
||||
LIBS += $(SDL2_LIBS)
|
||||
@ -544,21 +537,18 @@ ifeq ($(HAVE_7ZIP),1)
|
||||
deps/7zip/7zBuf.o \
|
||||
decompress/7zip_support.o
|
||||
OBJ += $(7ZOBJ)
|
||||
JOYCONFIG_OBJ += $(7ZOBJ)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_ZLIB), 1)
|
||||
ZLIB_OBJS = decompress/zip_support.o
|
||||
OBJ += gfx/rpng/rpng.o file_extract.o
|
||||
OBJ += $(ZLIB_OBJS)
|
||||
JOYCONFIG_OBJ += $(ZLIB_OBJS)
|
||||
DEFINES += -DHAVE_ZLIB
|
||||
HAVE_COMPRESSION = 1
|
||||
ifeq ($(WANT_MINIZ), 1)
|
||||
DEFINES += -DWANT_MINIZ
|
||||
else
|
||||
LIBS += -lz
|
||||
JOYCONFIG_LIBS += -lz
|
||||
HAVE_ZLIB_DEFLATE = 1
|
||||
endif
|
||||
endif
|
||||
@ -588,7 +578,6 @@ else
|
||||
ifeq ($(HAVE_ZLIB),1)
|
||||
ZLIB_OBJS = deps/rzlib/unzip.o deps/rzlib/ioapi.o
|
||||
OBJ += $(ZLIB_OBJS)
|
||||
JOYCONFIG_OBJ += $(ZLIB_OBJS)
|
||||
HAVE_ZLIB_DEFLATE = 1
|
||||
endif
|
||||
endif
|
||||
@ -634,13 +623,4 @@ endif
|
||||
|
||||
# Joyconfig binary
|
||||
|
||||
JOYCONFIG_OBJ += tools/retroarch-joyconfig.o \
|
||||
libretro-sdk/file/config_file.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
|
||||
JOYCONFIG_OBJ += tools/retroarch-joyconfig-griffin.o
|
||||
|
25
Makefile.win
25
Makefile.win
@ -156,31 +156,6 @@ $(OBJDIR)/git_version.o: git_version.c .FORCE
|
||||
@$(if $(Q), $(shell echo echo CC $<),)
|
||||
$(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -c -o $@ $<
|
||||
|
||||
$(OBJDIR)/tools/input_common_joyconfig.o: input/input_common.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 $<),)
|
||||
$(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $<
|
||||
|
||||
$(OBJDIR)/tools/input_context_joyconfig.o: input/input_context.c
|
||||
@mkdir -p $(dir $@)
|
||||
@$(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 $<),)
|
||||
|
@ -39,7 +39,7 @@ struct linuxraw_joypad
|
||||
char *ident;
|
||||
};
|
||||
|
||||
static struct linuxraw_joypad g_pads[MAX_PLAYERS];
|
||||
static struct linuxraw_joypad linuxraw_pads[MAX_PLAYERS];
|
||||
static int g_notify;
|
||||
static int g_epoll;
|
||||
static bool g_hotplug;
|
||||
@ -94,7 +94,7 @@ static bool linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *p
|
||||
if (g_hotplug)
|
||||
{
|
||||
char msg[512];
|
||||
snprintf(msg, sizeof(msg), "Joypad #%u (%s) connected.", (unsigned)(pad - g_pads), pad->ident);
|
||||
snprintf(msg, sizeof(msg), "Joypad #%u (%s) connected.", (unsigned)(pad - linuxraw_pads), pad->ident);
|
||||
msg_queue_push(g_extern.msg_queue, msg, 0, 60);
|
||||
}
|
||||
#endif
|
||||
@ -139,23 +139,23 @@ static void handle_plugged_pad(void)
|
||||
|
||||
if (event->mask & IN_DELETE)
|
||||
{
|
||||
if (g_pads[idx].fd >= 0)
|
||||
if (linuxraw_pads[idx].fd >= 0)
|
||||
{
|
||||
#ifndef IS_JOYCONFIG
|
||||
if (g_hotplug)
|
||||
{
|
||||
char msg[512];
|
||||
snprintf(msg, sizeof(msg), "Joypad #%u (%s) disconnected.", idx, g_pads[idx].ident);
|
||||
snprintf(msg, sizeof(msg), "Joypad #%u (%s) disconnected.", idx, linuxraw_pads[idx].ident);
|
||||
msg_queue_push(g_extern.msg_queue, msg, 0, 60);
|
||||
}
|
||||
#endif
|
||||
|
||||
RARCH_LOG("[Joypad]: Joypad %s disconnected.\n", g_pads[idx].ident);
|
||||
close(g_pads[idx].fd);
|
||||
g_pads[idx].buttons = 0;
|
||||
memset(g_pads[idx].axes, 0, sizeof(g_pads[idx].axes));
|
||||
g_pads[idx].fd = -1;
|
||||
*g_pads[idx].ident = '\0';
|
||||
RARCH_LOG("[Joypad]: Joypad %s disconnected.\n", linuxraw_pads[idx].ident);
|
||||
close(linuxraw_pads[idx].fd);
|
||||
linuxraw_pads[idx].buttons = 0;
|
||||
memset(linuxraw_pads[idx].axes, 0, sizeof(linuxraw_pads[idx].axes));
|
||||
linuxraw_pads[idx].fd = -1;
|
||||
*linuxraw_pads[idx].ident = '\0';
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
input_config_autoconfigure_joypad(idx, NULL, 0, 0, NULL);
|
||||
@ -166,11 +166,11 @@ static void handle_plugged_pad(void)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
snprintf(path, sizeof(path), "/dev/input/%s", event->name);
|
||||
bool ret = linuxraw_joypad_init_pad(path, &g_pads[idx]);
|
||||
bool ret = linuxraw_joypad_init_pad(path, &linuxraw_pads[idx]);
|
||||
|
||||
if (*g_pads[idx].ident && ret)
|
||||
if (*linuxraw_pads[idx].ident && ret)
|
||||
/* TODO - implement VID/PID? */
|
||||
input_config_autoconfigure_joypad(idx, g_pads[idx].ident, 0, 0, "linuxraw");
|
||||
input_config_autoconfigure_joypad(idx, linuxraw_pads[idx].ident, 0, 0, "linuxraw");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -212,7 +212,7 @@ static bool linuxraw_joypad_init(void)
|
||||
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
struct linuxraw_joypad *pad = &g_pads[i];
|
||||
struct linuxraw_joypad *pad = (struct linuxraw_joypad*)&linuxraw_pads[i];
|
||||
pad->fd = -1;
|
||||
pad->ident = g_settings.input.device_names[i];
|
||||
|
||||
@ -250,13 +250,13 @@ static void linuxraw_joypad_destroy(void)
|
||||
unsigned i;
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
if (g_pads[i].fd >= 0)
|
||||
close(g_pads[i].fd);
|
||||
if (linuxraw_pads[i].fd >= 0)
|
||||
close(linuxraw_pads[i].fd);
|
||||
}
|
||||
|
||||
memset(g_pads, 0, sizeof(g_pads));
|
||||
memset(linuxraw_pads, 0, sizeof(linuxraw_pads));
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
g_pads[i].fd = -1;
|
||||
linuxraw_pads[i].fd = -1;
|
||||
|
||||
if (g_notify >= 0)
|
||||
close(g_notify);
|
||||
@ -271,9 +271,10 @@ static void linuxraw_joypad_destroy(void)
|
||||
|
||||
static bool linuxraw_joypad_button(unsigned port, uint16_t joykey)
|
||||
{
|
||||
const struct linuxraw_joypad *pad = &g_pads[port];
|
||||
|
||||
return joykey < NUM_BUTTONS && BIT32_GET(pad->buttons, joykey);
|
||||
const struct linuxraw_joypad *pad = (const struct linuxraw_joypad*)&linuxraw_pads[port];
|
||||
if (pad)
|
||||
return joykey < NUM_BUTTONS && BIT32_GET(pad->buttons, joykey);
|
||||
return false;
|
||||
}
|
||||
|
||||
static int16_t linuxraw_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
@ -281,7 +282,8 @@ static int16_t linuxraw_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
if (joyaxis == AXIS_NONE)
|
||||
return 0;
|
||||
|
||||
const struct linuxraw_joypad *pad = &g_pads[port];
|
||||
const struct linuxraw_joypad *pad = (const struct linuxraw_joypad*)
|
||||
&linuxraw_pads[port];
|
||||
|
||||
int16_t val = 0;
|
||||
if (AXIS_NEG_GET(joyaxis) < NUM_AXES)
|
||||
@ -303,7 +305,7 @@ static int16_t linuxraw_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
|
||||
static bool linuxraw_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
return pad < MAX_PLAYERS && g_pads[pad].fd >= 0;
|
||||
return pad < MAX_PLAYERS && linuxraw_pads[pad].fd >= 0;
|
||||
}
|
||||
|
||||
static const char *linuxraw_joypad_name(unsigned pad)
|
||||
@ -311,7 +313,7 @@ static const char *linuxraw_joypad_name(unsigned pad)
|
||||
if (pad >= MAX_PLAYERS)
|
||||
return NULL;
|
||||
|
||||
return *g_pads[pad].ident ? g_pads[pad].ident : NULL;
|
||||
return *linuxraw_pads[pad].ident ? linuxraw_pads[pad].ident : NULL;
|
||||
}
|
||||
|
||||
rarch_joypad_driver_t linuxraw_joypad = {
|
||||
|
@ -29,21 +29,21 @@
|
||||
|
||||
/* Linux parport driver does not support reading the control register
|
||||
Other platforms may support up to 17 buttons */
|
||||
#define NUM_BUTTONS 13
|
||||
#define PARPORT_NUM_BUTTONS 13
|
||||
|
||||
struct parport_joypad
|
||||
{
|
||||
int fd;
|
||||
uint32_t buttons;
|
||||
bool button_enable[NUM_BUTTONS];
|
||||
bool button_enable[PARPORT_NUM_BUTTONS];
|
||||
char saved_data;
|
||||
char saved_control;
|
||||
char *ident;
|
||||
};
|
||||
|
||||
static struct parport_joypad g_pads[MAX_PLAYERS];
|
||||
static struct parport_joypad parport_pads[MAX_PLAYERS];
|
||||
|
||||
static void poll_pad(struct parport_joypad *pad)
|
||||
static void parport_poll_pad(struct parport_joypad *pad)
|
||||
{
|
||||
/* RetroArch uses an extended version of the Linux
|
||||
* Multisystem 2-button joystick protocol for parallel port
|
||||
@ -182,7 +182,7 @@ static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad
|
||||
|
||||
strlcpy(pad->ident, path, sizeof(g_settings.input.device_names[0]));
|
||||
|
||||
for (i = 0; i < NUM_BUTTONS; i++)
|
||||
for (i = 0; i < PARPORT_NUM_BUTTONS; i++)
|
||||
pad->button_enable[i] = true;
|
||||
|
||||
return true;
|
||||
@ -202,10 +202,8 @@ static void parport_joypad_poll(void)
|
||||
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
if (g_pads[i].fd >= 0)
|
||||
{
|
||||
poll_pad(&g_pads[i]);
|
||||
}
|
||||
if (parport_pads[i].fd >= 0)
|
||||
parport_poll_pad(&parport_pads[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,14 +230,14 @@ static bool parport_joypad_init(void)
|
||||
unsigned i, j;
|
||||
bool found_enabled_button;
|
||||
bool found_disabled_button;
|
||||
char buf[NUM_BUTTONS * 3 + 1];
|
||||
char buf[PARPORT_NUM_BUTTONS * 3 + 1];
|
||||
char pin[3 + 1];
|
||||
|
||||
memset(buf, 0, NUM_BUTTONS * 3 + 1);
|
||||
memset(buf, 0, PARPORT_NUM_BUTTONS * 3 + 1);
|
||||
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
struct parport_joypad *pad = &g_pads[i];
|
||||
struct parport_joypad *pad = &parport_pads[i];
|
||||
pad->fd = -1;
|
||||
pad->ident = g_settings.input.device_names[i];
|
||||
|
||||
@ -254,11 +252,11 @@ static bool parport_joypad_init(void)
|
||||
* so assume the user is not holding any button on startup
|
||||
* and disable any low pins.
|
||||
*/
|
||||
poll_pad(pad);
|
||||
parport_poll_pad(pad);
|
||||
found_enabled_button = false;
|
||||
found_disabled_button = false;
|
||||
|
||||
for (j = 0; j < NUM_BUTTONS; j++)
|
||||
for (j = 0; j < PARPORT_NUM_BUTTONS; j++)
|
||||
{
|
||||
if (!(BIT32_GET(pad->buttons, j)))
|
||||
{
|
||||
@ -277,7 +275,7 @@ static bool parport_joypad_init(void)
|
||||
if (found_disabled_button)
|
||||
{
|
||||
buf[0] = '\0';
|
||||
for (j = 0; j < NUM_BUTTONS; j++)
|
||||
for (j = 0; j < PARPORT_NUM_BUTTONS; j++)
|
||||
{
|
||||
if (!pad->button_enable[j])
|
||||
{
|
||||
@ -311,22 +309,23 @@ static void parport_joypad_destroy(void)
|
||||
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
pad = &g_pads[i];
|
||||
pad = (struct parport_joypad*)&parport_pads[i];
|
||||
if (pad->fd >= 0)
|
||||
{
|
||||
destroy_pad(pad);
|
||||
}
|
||||
}
|
||||
memset(g_pads, 0, sizeof(g_pads));
|
||||
memset(parport_pads, 0, sizeof(parport_pads));
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
g_pads[i].fd = -1;
|
||||
parport_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 && BIT32_GET(pad->buttons, joykey);
|
||||
const struct parport_joypad *pad = (const struct parport_joypad*)&parport_pads[port];
|
||||
if (pad)
|
||||
return joykey < PARPORT_NUM_BUTTONS && BIT32_GET(pad->buttons, joykey);
|
||||
return false;
|
||||
}
|
||||
|
||||
static int16_t parport_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
@ -337,7 +336,7 @@ static int16_t parport_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
|
||||
static bool parport_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
return pad < MAX_PLAYERS && g_pads[pad].fd >= 0;
|
||||
return pad < MAX_PLAYERS && parport_pads[pad].fd >= 0;
|
||||
}
|
||||
|
||||
static const char *parport_joypad_name(unsigned pad)
|
||||
@ -345,7 +344,7 @@ static const char *parport_joypad_name(unsigned pad)
|
||||
if (pad >= MAX_PLAYERS)
|
||||
return NULL;
|
||||
|
||||
return *g_pads[pad].ident ? g_pads[pad].ident : NULL;
|
||||
return *parport_pads[pad].ident ? parport_pads[pad].ident : NULL;
|
||||
}
|
||||
|
||||
rarch_joypad_driver_t parport_joypad = {
|
||||
|
@ -40,7 +40,7 @@ const int g_subsystem = SDL_INIT_GAMECONTROLLER;
|
||||
const int g_subsystem = SDL_INIT_JOYSTICK;
|
||||
#endif
|
||||
|
||||
static sdl_joypad_t g_pads[MAX_PLAYERS];
|
||||
static sdl_joypad_t sdl_pads[MAX_PLAYERS];
|
||||
#ifdef HAVE_SDL2
|
||||
static bool g_has_haptic;
|
||||
#endif
|
||||
@ -48,7 +48,7 @@ static bool g_has_haptic;
|
||||
static const char* pad_name(unsigned id)
|
||||
{
|
||||
#ifdef HAVE_SDL2
|
||||
if (g_pads[id].controller)
|
||||
if (sdl_pads[id].controller)
|
||||
return SDL_GameControllerNameForIndex(id);
|
||||
return SDL_JoystickNameForIndex(id);
|
||||
#else
|
||||
@ -87,7 +87,7 @@ static int16_t pad_get_axis(sdl_joypad_t *pad, unsigned axis)
|
||||
|
||||
static void pad_connect(unsigned id)
|
||||
{
|
||||
sdl_joypad_t *pad = &g_pads[id];
|
||||
sdl_joypad_t *pad = (sdl_joypad_t*)&sdl_pads[id];
|
||||
bool success = false;
|
||||
int32_t product = 0;
|
||||
int32_t vendor = 0;
|
||||
@ -186,25 +186,25 @@ static void pad_connect(unsigned id)
|
||||
static void pad_disconnect(unsigned id)
|
||||
{
|
||||
#ifdef HAVE_SDL2
|
||||
if (g_pads[id].haptic)
|
||||
SDL_HapticClose(g_pads[id].haptic);
|
||||
if (sdl_pads[id].haptic)
|
||||
SDL_HapticClose(sdl_pads[id].haptic);
|
||||
|
||||
if (g_pads[id].controller)
|
||||
if (sdl_pads[id].controller)
|
||||
{
|
||||
SDL_GameControllerClose(g_pads[id].controller);
|
||||
SDL_GameControllerClose(sdl_pads[id].controller);
|
||||
RARCH_LOG("[SDL]: Joypad #%u disconnected.\n", id);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (g_pads[id].joypad)
|
||||
if (sdl_pads[id].joypad)
|
||||
{
|
||||
SDL_JoystickClose(g_pads[id].joypad);
|
||||
SDL_JoystickClose(sdl_pads[id].joypad);
|
||||
RARCH_LOG("[SDL]: Joypad #%u disconnected.\n", id);
|
||||
}
|
||||
|
||||
g_settings.input.device_names[id][0] = '\0';
|
||||
|
||||
memset(&g_pads[id], 0, sizeof(g_pads[id]));
|
||||
memset(&sdl_pads[id], 0, sizeof(sdl_pads[id]));
|
||||
}
|
||||
|
||||
static void sdl_joypad_destroy(void)
|
||||
@ -214,7 +214,7 @@ static void sdl_joypad_destroy(void)
|
||||
pad_disconnect(i);
|
||||
|
||||
SDL_QuitSubSystem(g_subsystem);
|
||||
memset(g_pads, 0, sizeof(g_pads));
|
||||
memset(sdl_pads, 0, sizeof(sdl_pads));
|
||||
}
|
||||
|
||||
static bool sdl_joypad_init(void)
|
||||
@ -238,7 +238,7 @@ static bool sdl_joypad_init(void)
|
||||
g_has_haptic = true;
|
||||
#endif
|
||||
|
||||
memset(g_pads, 0, sizeof(g_pads));
|
||||
memset(sdl_pads, 0, sizeof(sdl_pads));
|
||||
|
||||
unsigned num_sticks = SDL_NumJoysticks();
|
||||
if (num_sticks > MAX_PLAYERS)
|
||||
@ -251,7 +251,7 @@ static bool sdl_joypad_init(void)
|
||||
/* quit if no joypad is detected. */
|
||||
num_sticks = 0;
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
if (g_pads[i].joypad)
|
||||
if (sdl_pads[i].joypad)
|
||||
num_sticks++;
|
||||
|
||||
if (num_sticks == 0)
|
||||
@ -272,7 +272,7 @@ static bool sdl_joypad_button(unsigned port, uint16_t joykey)
|
||||
if (joykey == NO_BTN)
|
||||
return false;
|
||||
|
||||
sdl_joypad_t *pad = &g_pads[port];
|
||||
sdl_joypad_t *pad = (sdl_joypad_t*)&sdl_pads[port];
|
||||
if (!pad->joypad)
|
||||
return false;
|
||||
|
||||
@ -312,7 +312,7 @@ static int16_t sdl_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
if (joyaxis == AXIS_NONE)
|
||||
return 0;
|
||||
|
||||
sdl_joypad_t *pad = &g_pads[port];
|
||||
sdl_joypad_t *pad = (sdl_joypad_t*)&sdl_pads[port];
|
||||
if (!pad->joypad)
|
||||
return false;
|
||||
|
||||
@ -365,7 +365,7 @@ static bool sdl_joypad_set_rumble(unsigned pad, enum retro_rumble_effect effect,
|
||||
SDL_HapticEffect efx;
|
||||
memset(&efx, 0, sizeof(efx));
|
||||
|
||||
sdl_joypad_t *joypad = &g_pads[pad];
|
||||
sdl_joypad_t *joypad = (sdl_joypad_t*)&sdl_pads[pad];
|
||||
|
||||
if (!joypad->joypad || !joypad->haptic)
|
||||
return false;
|
||||
@ -383,7 +383,7 @@ static bool sdl_joypad_set_rumble(unsigned pad, enum retro_rumble_effect effect,
|
||||
|
||||
if (joypad->rumble_effect == -1)
|
||||
{
|
||||
joypad->rumble_effect = SDL_HapticNewEffect(g_pads[pad].haptic, &efx);
|
||||
joypad->rumble_effect = SDL_HapticNewEffect(sdl_pads[pad].haptic, &efx);
|
||||
if (joypad->rumble_effect < 0)
|
||||
{
|
||||
RARCH_WARN("[SDL]: Failed to create rumble effect for joypad %u: %s\n",
|
||||
@ -411,7 +411,7 @@ static bool sdl_joypad_set_rumble(unsigned pad, enum retro_rumble_effect effect,
|
||||
|
||||
static bool sdl_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
return pad < MAX_PLAYERS && g_pads[pad].joypad;
|
||||
return pad < MAX_PLAYERS && sdl_pads[pad].joypad;
|
||||
}
|
||||
|
||||
static const char *sdl_joypad_name(unsigned pad)
|
||||
|
@ -36,7 +36,7 @@
|
||||
//
|
||||
// Code adapted from SDL 2.0's implementation.
|
||||
|
||||
#define NUM_BUTTONS 32
|
||||
#define UDEV_NUM_BUTTONS 32
|
||||
#define NUM_AXES 32
|
||||
#define NUM_HATS 4
|
||||
|
||||
@ -69,7 +69,7 @@ struct udev_joypad
|
||||
|
||||
static struct udev *g_udev;
|
||||
static struct udev_monitor *g_udev_mon;
|
||||
static struct udev_joypad g_pads[MAX_PLAYERS];
|
||||
static struct udev_joypad udev_pads[MAX_PLAYERS];
|
||||
|
||||
static inline int16_t compute_axis(const struct input_absinfo *info, int value)
|
||||
{
|
||||
@ -82,11 +82,11 @@ static inline int16_t compute_axis(const struct input_absinfo *info, int value)
|
||||
return axis;
|
||||
}
|
||||
|
||||
static void poll_pad(unsigned p)
|
||||
static void udev_poll_pad(unsigned p)
|
||||
{
|
||||
int i, len;
|
||||
struct input_event events[32];
|
||||
struct udev_joypad *pad = &g_pads[p];
|
||||
struct udev_joypad *pad = (struct udev_joypad*)&udev_pads[p];
|
||||
|
||||
if (pad->fd < 0)
|
||||
return;
|
||||
@ -188,7 +188,7 @@ end:
|
||||
|
||||
static bool udev_set_rumble(unsigned i, enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
struct udev_joypad *pad = &g_pads[i];
|
||||
struct udev_joypad *pad = (struct udev_joypad*)&udev_pads[i];
|
||||
|
||||
if (pad->fd < 0)
|
||||
return false;
|
||||
@ -253,7 +253,7 @@ static void udev_joypad_poll(void)
|
||||
handle_hotplug();
|
||||
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
poll_pad(i);
|
||||
udev_poll_pad(i);
|
||||
}
|
||||
|
||||
#define test_bit(nr, addr) \
|
||||
@ -290,23 +290,23 @@ static int find_vacant_pad(void)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
if (g_pads[i].fd < 0)
|
||||
if (udev_pads[i].fd < 0)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void free_pad(unsigned pad, bool hotplug)
|
||||
{
|
||||
if (g_pads[pad].fd >= 0)
|
||||
close(g_pads[pad].fd);
|
||||
if (udev_pads[pad].fd >= 0)
|
||||
close(udev_pads[pad].fd);
|
||||
|
||||
free(g_pads[pad].path);
|
||||
if (g_pads[pad].ident)
|
||||
*g_pads[pad].ident = '\0';
|
||||
memset(&g_pads[pad], 0, sizeof(g_pads[pad]));
|
||||
free(udev_pads[pad].path);
|
||||
if (udev_pads[pad].ident)
|
||||
*udev_pads[pad].ident = '\0';
|
||||
memset(&udev_pads[pad], 0, sizeof(udev_pads[pad]));
|
||||
|
||||
g_pads[pad].fd = -1;
|
||||
g_pads[pad].ident = g_settings.input.device_names[pad];
|
||||
udev_pads[pad].fd = -1;
|
||||
udev_pads[pad].ident = g_settings.input.device_names[pad];
|
||||
|
||||
// Avoid autoconfig spam if we're reiniting driver.
|
||||
/* TODO - implement VID/PID? */
|
||||
@ -319,7 +319,7 @@ static void free_pad(unsigned pad, bool hotplug)
|
||||
static bool add_pad(struct udev_device *dev, unsigned p, int fd, const char *path)
|
||||
{
|
||||
int i;
|
||||
struct udev_joypad *pad = &g_pads[p];
|
||||
struct udev_joypad *pad = (struct udev_joypad*)&udev_pads[p];
|
||||
if (ioctl(fd, EVIOCGNAME(sizeof(g_settings.input.device_names[0])), pad->ident) < 0)
|
||||
{
|
||||
RARCH_LOG("[udev]: Failed to get pad name.\n");
|
||||
@ -358,10 +358,10 @@ static bool add_pad(struct udev_device *dev, unsigned p, int fd, const char *pat
|
||||
// and map them to button/axes/hat indices.
|
||||
unsigned buttons = 0;
|
||||
unsigned axes = 0;
|
||||
for (i = KEY_UP; i <= KEY_DOWN && buttons < NUM_BUTTONS; i++)
|
||||
for (i = KEY_UP; i <= KEY_DOWN && buttons < UDEV_NUM_BUTTONS; i++)
|
||||
if (test_bit(i, keybit))
|
||||
pad->button_bind[i] = buttons++;
|
||||
for (i = BTN_MISC; i < KEY_MAX && buttons < NUM_BUTTONS; i++)
|
||||
for (i = BTN_MISC; i < KEY_MAX && buttons < UDEV_NUM_BUTTONS; i++)
|
||||
if (test_bit(i, keybit))
|
||||
pad->button_bind[i] = buttons++;
|
||||
for (i = 0; i < ABS_MISC && axes < NUM_AXES; i++)
|
||||
@ -417,7 +417,7 @@ static void check_device(struct udev_device *dev, const char *path, bool hotplug
|
||||
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
if (st.st_rdev == g_pads[i].device)
|
||||
if (st.st_rdev == udev_pads[i].device)
|
||||
{
|
||||
RARCH_LOG("[udev]: Device ID %u is already plugged.\n", (unsigned)st.st_rdev);
|
||||
return;
|
||||
@ -458,11 +458,11 @@ static void remove_device(const char *path)
|
||||
unsigned i;
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
if (g_pads[i].path && !strcmp(g_pads[i].path, path))
|
||||
if (udev_pads[i].path && !strcmp(udev_pads[i].path, path))
|
||||
{
|
||||
#ifndef IS_JOYCONFIG
|
||||
char msg[512];
|
||||
snprintf(msg, sizeof(msg), "Joypad #%u (%s) disconnected.", i, g_pads[i].ident);
|
||||
snprintf(msg, sizeof(msg), "Joypad #%u (%s) disconnected.", i, udev_pads[i].ident);
|
||||
msg_queue_push(g_extern.msg_queue, msg, 0, 60);
|
||||
RARCH_LOG("[udev]: %s\n", msg);
|
||||
#endif
|
||||
@ -491,8 +491,8 @@ static bool udev_joypad_init(void)
|
||||
unsigned i;
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
g_pads[i].fd = -1;
|
||||
g_pads[i].ident = g_settings.input.device_names[i];
|
||||
udev_pads[i].fd = -1;
|
||||
udev_pads[i].ident = g_settings.input.device_names[i];
|
||||
}
|
||||
|
||||
struct udev_list_entry *devs = NULL;
|
||||
@ -554,11 +554,11 @@ static bool udev_joypad_hat(const struct udev_joypad *pad, uint16_t hat)
|
||||
|
||||
static bool udev_joypad_button(unsigned port, uint16_t joykey)
|
||||
{
|
||||
const struct udev_joypad *pad = &g_pads[port];
|
||||
const struct udev_joypad *pad = (const struct udev_joypad*)&udev_pads[port];
|
||||
|
||||
if (GET_HAT_DIR(joykey))
|
||||
return udev_joypad_hat(pad, joykey);
|
||||
return joykey < NUM_BUTTONS && BIT32_GET(pad->buttons, joykey);
|
||||
return joykey < UDEV_NUM_BUTTONS && BIT32_GET(pad->buttons, joykey);
|
||||
}
|
||||
|
||||
static int16_t udev_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
@ -566,7 +566,7 @@ static int16_t udev_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
if (joyaxis == AXIS_NONE)
|
||||
return 0;
|
||||
|
||||
const struct udev_joypad *pad = &g_pads[port];
|
||||
const struct udev_joypad *pad = (const struct udev_joypad*)&udev_pads[port];
|
||||
|
||||
int16_t val = 0;
|
||||
if (AXIS_NEG_GET(joyaxis) < NUM_AXES)
|
||||
@ -587,7 +587,7 @@ static int16_t udev_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
|
||||
static bool udev_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
return pad < MAX_PLAYERS && g_pads[pad].fd >= 0;
|
||||
return pad < MAX_PLAYERS && udev_pads[pad].fd >= 0;
|
||||
}
|
||||
|
||||
static const char *udev_joypad_name(unsigned pad)
|
||||
@ -595,7 +595,7 @@ static const char *udev_joypad_name(unsigned pad)
|
||||
if (pad >= MAX_PLAYERS)
|
||||
return NULL;
|
||||
|
||||
return *g_pads[pad].ident ? g_pads[pad].ident : NULL;
|
||||
return *udev_pads[pad].ident ? udev_pads[pad].ident : NULL;
|
||||
}
|
||||
|
||||
rarch_joypad_driver_t udev_joypad = {
|
||||
|
40
tools/retroarch-joyconfig-griffin.c
Normal file
40
tools/retroarch-joyconfig-griffin.c
Normal file
@ -0,0 +1,40 @@
|
||||
#include "retroarch-joyconfig.c"
|
||||
|
||||
#if defined(__linux) && !defined(ANDROID)
|
||||
#include "../input/linuxraw_input.c"
|
||||
#include "../input/linuxraw_joypad.c"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DINPUT)
|
||||
#include "../input/dinput.c"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_WINXINPUT)
|
||||
#include "../input/winxinput_joypad.c"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_UDEV)
|
||||
#include "../input/udev_joypad.c"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_PARPORT)
|
||||
#include "../input/parport_joypad.c"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SDL) || defined(HAVE_SDL2)
|
||||
#include "../input/sdl_joypad.c"
|
||||
#endif
|
||||
|
||||
#include "../libretro-sdk/file/config_file.c"
|
||||
#include "../libretro-sdk/file/file_path.c"
|
||||
#include "../libretro-sdk/string/string_list.c"
|
||||
#include "../libretro-sdk/compat/compat.c"
|
||||
|
||||
#include "../input/nullinput.c"
|
||||
#include "../input/nullinput_joypad.c"
|
||||
|
||||
#include "../input/input_context.c"
|
||||
#include "../input/input_common.c"
|
||||
#include "../input/input_keymaps.c"
|
||||
|
||||
#include "../message_queue.c"
|
Loading…
x
Reference in New Issue
Block a user