2014-10-25 17:56:22 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
2014-10-25 17:56:22 +00:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2015-09-05 18:03:27 +00:00
|
|
|
#include <string.h>
|
2014-10-27 03:27:48 +00:00
|
|
|
#include <ctype.h>
|
2015-09-05 18:03:27 +00:00
|
|
|
|
|
|
|
#include "input_keymaps.h"
|
2014-10-25 17:56:22 +00:00
|
|
|
#include "../general.h"
|
2015-10-26 08:06:11 +00:00
|
|
|
#include "../string_list_special.h"
|
2015-11-23 11:03:38 +00:00
|
|
|
#include "../verbosity.h"
|
2014-10-25 17:56:22 +00:00
|
|
|
|
2015-04-14 14:37:59 +00:00
|
|
|
static input_device_driver_t *joypad_drivers[] = {
|
2014-10-25 17:56:22 +00:00
|
|
|
#ifdef __CELLOS_LV2__
|
|
|
|
&ps3_joypad,
|
|
|
|
#endif
|
2015-04-05 18:54:46 +00:00
|
|
|
#ifdef HAVE_XINPUT
|
2015-04-03 00:37:10 +00:00
|
|
|
&xinput_joypad,
|
2014-10-25 17:56:22 +00:00
|
|
|
#endif
|
|
|
|
#ifdef GEKKO
|
|
|
|
&gx_joypad,
|
|
|
|
#endif
|
|
|
|
#ifdef _XBOX
|
|
|
|
&xdk_joypad,
|
|
|
|
#endif
|
2015-08-10 21:19:07 +00:00
|
|
|
#if defined(PSP) || defined(VITA)
|
2014-10-25 17:56:22 +00:00
|
|
|
&psp_joypad,
|
|
|
|
#endif
|
2015-04-01 21:14:13 +00:00
|
|
|
#ifdef _3DS
|
|
|
|
&ctr_joypad,
|
|
|
|
#endif
|
2014-10-25 17:56:22 +00:00
|
|
|
#ifdef HAVE_DINPUT
|
|
|
|
&dinput_joypad,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_UDEV
|
|
|
|
&udev_joypad,
|
|
|
|
#endif
|
|
|
|
#if defined(__linux) && !defined(ANDROID)
|
|
|
|
&linuxraw_joypad,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_PARPORT
|
|
|
|
&parport_joypad,
|
|
|
|
#endif
|
|
|
|
#ifdef ANDROID
|
|
|
|
&android_joypad,
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_SDL) || defined(HAVE_SDL2)
|
|
|
|
&sdl_joypad,
|
|
|
|
#endif
|
|
|
|
#ifdef __QNX__
|
|
|
|
&qnx_joypad,
|
2015-11-16 01:39:38 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_MFI
|
|
|
|
&mfi_joypad,
|
2014-10-25 17:56:22 +00:00
|
|
|
#endif
|
2015-04-01 20:31:43 +00:00
|
|
|
&hid_joypad,
|
2014-10-27 13:45:28 +00:00
|
|
|
&null_joypad,
|
2014-10-25 17:56:22 +00:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2015-01-12 19:25:07 +00:00
|
|
|
/**
|
|
|
|
* joypad_driver_find_handle:
|
2015-01-15 20:10:36 +00:00
|
|
|
* @idx : index of driver to get handle to.
|
2015-01-12 19:25:07 +00:00
|
|
|
*
|
|
|
|
* Returns: handle to joypad driver at index. Can be NULL
|
|
|
|
* if nothing found.
|
|
|
|
**/
|
2015-01-15 20:10:36 +00:00
|
|
|
const void *joypad_driver_find_handle(int idx)
|
2015-01-12 19:25:07 +00:00
|
|
|
{
|
2015-01-15 20:10:36 +00:00
|
|
|
const void *drv = joypad_drivers[idx];
|
2015-01-12 19:25:07 +00:00
|
|
|
if (!drv)
|
|
|
|
return NULL;
|
|
|
|
return drv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* joypad_driver_find_ident:
|
2015-01-15 20:10:36 +00:00
|
|
|
* @idx : index of driver to get handle to.
|
2015-01-12 19:25:07 +00:00
|
|
|
*
|
|
|
|
* Returns: Human-readable identifier of joypad driver at index. Can be NULL
|
|
|
|
* if nothing found.
|
|
|
|
**/
|
2015-01-15 20:10:36 +00:00
|
|
|
const char *joypad_driver_find_ident(int idx)
|
2015-01-12 19:25:07 +00:00
|
|
|
{
|
2015-04-14 14:37:59 +00:00
|
|
|
const input_device_driver_t *drv = joypad_drivers[idx];
|
2015-01-12 19:25:07 +00:00
|
|
|
if (!drv)
|
|
|
|
return NULL;
|
|
|
|
return drv->ident;
|
|
|
|
}
|
|
|
|
|
2015-01-09 23:03:04 +00:00
|
|
|
/**
|
|
|
|
* config_get_joypad_driver_options:
|
|
|
|
*
|
|
|
|
* Get an enumerated list of all joypad driver names, separated by '|'.
|
|
|
|
*
|
|
|
|
* Returns: string listing of all joypad driver names, separated by '|'.
|
|
|
|
**/
|
2014-11-26 20:56:53 +00:00
|
|
|
const char* config_get_joypad_driver_options(void)
|
|
|
|
{
|
2015-10-26 18:41:20 +00:00
|
|
|
return char_list_new_special(STRING_LIST_INPUT_JOYPAD_DRIVERS, NULL);
|
2014-11-26 20:56:53 +00:00
|
|
|
}
|
|
|
|
|
2015-01-09 23:03:04 +00:00
|
|
|
/**
|
|
|
|
* input_joypad_init_driver:
|
|
|
|
* @ident : identifier of driver to initialize.
|
|
|
|
*
|
|
|
|
* Initialize a joypad driver of name @ident.
|
|
|
|
*
|
|
|
|
* If ident points to NULL or a zero-length string,
|
|
|
|
* equivalent to calling input_joypad_init_first().
|
|
|
|
*
|
|
|
|
* Returns: joypad driver if found, otherwise NULL.
|
|
|
|
**/
|
2015-06-03 16:22:54 +00:00
|
|
|
const input_device_driver_t *input_joypad_init_driver(const char *ident, void *data)
|
2014-10-25 17:56:22 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
if (!ident || !*ident)
|
2015-06-03 16:22:54 +00:00
|
|
|
return input_joypad_init_first(data);
|
2014-10-25 17:56:22 +00:00
|
|
|
|
|
|
|
for (i = 0; joypad_drivers[i]; i++)
|
|
|
|
{
|
2015-06-15 04:01:54 +00:00
|
|
|
if (!strcmp(ident, joypad_drivers[i]->ident)
|
2015-06-03 16:22:54 +00:00
|
|
|
&& joypad_drivers[i]->init(data))
|
2014-10-25 17:56:22 +00:00
|
|
|
{
|
|
|
|
RARCH_LOG("Found joypad driver: \"%s\".\n",
|
|
|
|
joypad_drivers[i]->ident);
|
|
|
|
return joypad_drivers[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-03 16:22:54 +00:00
|
|
|
return input_joypad_init_first(data);
|
2014-10-25 17:56:22 +00:00
|
|
|
}
|
|
|
|
|
2015-01-09 23:03:04 +00:00
|
|
|
/**
|
|
|
|
* input_joypad_init_first:
|
|
|
|
*
|
|
|
|
* Finds first suitable joypad driver and initializes.
|
|
|
|
*
|
|
|
|
* Returns: joypad driver if found, otherwise NULL.
|
|
|
|
**/
|
2015-06-03 16:22:54 +00:00
|
|
|
const input_device_driver_t *input_joypad_init_first(void *data)
|
2014-10-25 17:56:22 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
2015-01-09 23:03:04 +00:00
|
|
|
|
2014-10-25 17:56:22 +00:00
|
|
|
for (i = 0; joypad_drivers[i]; i++)
|
|
|
|
{
|
2015-06-03 16:22:54 +00:00
|
|
|
if (joypad_drivers[i]->init(data))
|
2014-10-25 17:56:22 +00:00
|
|
|
{
|
|
|
|
RARCH_LOG("Found joypad driver: \"%s\".\n",
|
|
|
|
joypad_drivers[i]->ident);
|
|
|
|
return joypad_drivers[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|