2015-04-01 20:31:43 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2015-04-01 20:31:43 +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>
|
|
|
|
#include <ctype.h>
|
2015-09-04 19:13:12 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2016-09-06 21:59:43 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
2015-09-04 19:13:12 +00:00
|
|
|
#include "input_hid_driver.h"
|
2016-03-20 16:28:24 +00:00
|
|
|
#include "../list_special.h"
|
2015-11-23 11:03:38 +00:00
|
|
|
#include "../verbosity.h"
|
2015-04-01 20:31:43 +00:00
|
|
|
|
|
|
|
static hid_driver_t *hid_drivers[] = {
|
2015-11-16 03:17:13 +00:00
|
|
|
#if defined(HAVE_BTSTACK)
|
2015-04-04 00:07:18 +00:00
|
|
|
&btstack_hid,
|
|
|
|
#endif
|
2015-04-19 13:59:20 +00:00
|
|
|
#if defined(__APPLE__) && defined(HAVE_IOHIDMANAGER)
|
2015-04-20 09:52:10 +00:00
|
|
|
&iohidmanager_hid,
|
2015-04-02 13:43:23 +00:00
|
|
|
#endif
|
2016-05-11 17:02:43 +00:00
|
|
|
#if defined(HAVE_LIBUSB) && defined(HAVE_THREADS)
|
2015-04-02 13:43:23 +00:00
|
|
|
&libusb_hid,
|
2015-08-30 07:48:38 +00:00
|
|
|
#endif
|
2015-09-04 23:21:39 +00:00
|
|
|
#ifdef HW_RVL
|
2015-08-30 07:48:38 +00:00
|
|
|
&wiiusb_hid,
|
2015-04-01 20:31:43 +00:00
|
|
|
#endif
|
2015-04-01 22:20:28 +00:00
|
|
|
&null_hid,
|
2015-04-01 20:31:43 +00:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2016-02-05 13:06:43 +00:00
|
|
|
static const void *hid_data = NULL;
|
2015-11-29 20:11:57 +00:00
|
|
|
|
2015-04-01 20:31:43 +00:00
|
|
|
/**
|
|
|
|
* hid_driver_find_handle:
|
|
|
|
* @idx : index of driver to get handle to.
|
|
|
|
*
|
|
|
|
* Returns: handle to HID driver at index. Can be NULL
|
|
|
|
* if nothing found.
|
|
|
|
**/
|
|
|
|
const void *hid_driver_find_handle(int idx)
|
|
|
|
{
|
|
|
|
const void *drv = hid_drivers[idx];
|
|
|
|
if (!drv)
|
|
|
|
return NULL;
|
|
|
|
return drv;
|
|
|
|
}
|
|
|
|
|
2015-11-29 20:11:57 +00:00
|
|
|
const void *hid_driver_get_data(void)
|
|
|
|
{
|
|
|
|
return hid_data;
|
|
|
|
}
|
|
|
|
|
2015-04-01 20:31:43 +00:00
|
|
|
/**
|
|
|
|
* hid_driver_find_ident:
|
|
|
|
* @idx : index of driver to get handle to.
|
|
|
|
*
|
|
|
|
* Returns: Human-readable identifier of HID driver at index. Can be NULL
|
|
|
|
* if nothing found.
|
|
|
|
**/
|
|
|
|
const char *hid_driver_find_ident(int idx)
|
|
|
|
{
|
|
|
|
const hid_driver_t *drv = hid_drivers[idx];
|
|
|
|
if (!drv)
|
|
|
|
return NULL;
|
|
|
|
return drv->ident;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* config_get_hid_driver_options:
|
|
|
|
*
|
|
|
|
* Get an enumerated list of all HID driver names, separated by '|'.
|
|
|
|
*
|
|
|
|
* Returns: string listing of all HID driver names, separated by '|'.
|
|
|
|
**/
|
|
|
|
const char* config_get_hid_driver_options(void)
|
|
|
|
{
|
2015-10-26 18:41:20 +00:00
|
|
|
return char_list_new_special(STRING_LIST_INPUT_HID_DRIVERS, NULL);
|
2015-04-01 20:31:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* input_hid_init_first:
|
|
|
|
*
|
|
|
|
* Finds first suitable HID driver and initializes.
|
|
|
|
*
|
|
|
|
* Returns: HID driver if found, otherwise NULL.
|
|
|
|
**/
|
2015-04-01 21:33:00 +00:00
|
|
|
const hid_driver_t *input_hid_init_first(void)
|
2015-04-01 20:31:43 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; hid_drivers[i]; i++)
|
|
|
|
{
|
2015-11-29 20:11:57 +00:00
|
|
|
hid_data = hid_drivers[i]->init();
|
2015-04-01 20:31:43 +00:00
|
|
|
|
2015-11-29 20:11:57 +00:00
|
|
|
if (hid_data)
|
2015-04-01 20:31:43 +00:00
|
|
|
{
|
|
|
|
RARCH_LOG("Found HID driver: \"%s\".\n",
|
|
|
|
hid_drivers[i]->ident);
|
|
|
|
return hid_drivers[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|