mirror of
https://github.com/libretro/RetroArch
synced 2025-03-16 07:21:03 +00:00
Merge input_hid_driver
This commit is contained in:
parent
80e2911bec
commit
612cb54cfe
@ -736,8 +736,7 @@ endif
|
||||
|
||||
ifeq ($(HAVE_HID), 1)
|
||||
DEFINES += -DHAVE_HID
|
||||
OBJ += input/input_hid_driver.o \
|
||||
input/drivers_joypad/hid_joypad.o \
|
||||
OBJ += input/drivers_joypad/hid_joypad.o \
|
||||
input/connect/joypad_connection.o \
|
||||
input/connect/connect_ps2adapter.o \
|
||||
input/connect/connect_ps3.o \
|
||||
|
@ -506,7 +506,6 @@ INPUT
|
||||
INPUT (HID)
|
||||
============================================================ */
|
||||
#ifdef HAVE_HID
|
||||
#include "../input/input_hid_driver.c"
|
||||
#include "../input/drivers_joypad/hid_joypad.c"
|
||||
#include "../input/drivers_hid/null_hid.c"
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "../input_defines.h"
|
||||
#include "../input_hid_driver.h"
|
||||
#include "../input_driver.h"
|
||||
#define BUILDING_BTDYNAMIC
|
||||
#include "../connect/joypad_connection.h"
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include "../input_config.h"
|
||||
#include "../input_defines.h"
|
||||
#include "../input_hid_driver.h"
|
||||
#include "../input_driver.h"
|
||||
|
||||
#include "../connect/joypad_connection.h"
|
||||
#include "../../tasks/tasks_internal.h"
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "../../tasks/tasks_internal.h"
|
||||
#include "../input_config.h"
|
||||
#include "../input_driver.h"
|
||||
#include "../input_hid_driver.h"
|
||||
#include "../../verbosity.h"
|
||||
|
||||
#ifndef LIBUSB_CAP_HAS_HOTPLUG
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../input_defines.h"
|
||||
#include "../input_hid_driver.h"
|
||||
#include "../input_driver.h"
|
||||
|
||||
typedef struct null_hid
|
||||
{
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "../input_config.h"
|
||||
#include "../input_defines.h"
|
||||
#include "../input_hid_driver.h"
|
||||
#include "../input_driver.h"
|
||||
|
||||
#include "../connect/joypad_connection.h"
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
|
||||
#include "../../tasks/tasks_internal.h"
|
||||
#include "../input_hid_driver.h"
|
||||
#include "../input_driver.h"
|
||||
|
||||
static const hid_driver_t *generic_hid = NULL;
|
||||
|
@ -164,6 +164,23 @@ static input_device_driver_t *joypad_drivers[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static hid_driver_t *hid_drivers[] = {
|
||||
#if defined(HAVE_BTSTACK)
|
||||
&btstack_hid,
|
||||
#endif
|
||||
#if defined(__APPLE__) && defined(HAVE_IOHIDMANAGER)
|
||||
&iohidmanager_hid,
|
||||
#endif
|
||||
#if defined(HAVE_LIBUSB) && defined(HAVE_THREADS)
|
||||
&libusb_hid,
|
||||
#endif
|
||||
#ifdef HW_RVL
|
||||
&wiiusb_hid,
|
||||
#endif
|
||||
&null_hid,
|
||||
NULL,
|
||||
};
|
||||
|
||||
typedef struct turbo_buttons turbo_buttons_t;
|
||||
|
||||
/* Turbo support. */
|
||||
@ -191,6 +208,8 @@ static bool input_driver_data_own = false;
|
||||
static float input_driver_axis_threshold = 0.0f;
|
||||
static unsigned input_driver_max_users = 0;
|
||||
|
||||
static const void *hid_data = NULL;
|
||||
|
||||
/**
|
||||
* input_driver_find_handle:
|
||||
* @idx : index of driver to get handle to.
|
||||
@ -1534,3 +1553,76 @@ void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
const void *hid_driver_get_data(void)
|
||||
{
|
||||
return hid_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
return char_list_new_special(STRING_LIST_INPUT_HID_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* input_hid_init_first:
|
||||
*
|
||||
* Finds first suitable HID driver and initializes.
|
||||
*
|
||||
* Returns: HID driver if found, otherwise NULL.
|
||||
**/
|
||||
const hid_driver_t *input_hid_init_first(void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; hid_drivers[i]; i++)
|
||||
{
|
||||
hid_data = hid_drivers[i]->init();
|
||||
|
||||
if (hid_data)
|
||||
{
|
||||
RARCH_LOG("Found HID driver: \"%s\".\n",
|
||||
hid_drivers[i]->ident);
|
||||
return hid_drivers[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ RETRO_BEGIN_DECLS
|
||||
|
||||
typedef struct rarch_joypad_driver input_device_driver_t;
|
||||
|
||||
typedef struct hid_driver hid_driver_t;
|
||||
|
||||
enum input_device_type
|
||||
{
|
||||
@ -152,6 +153,21 @@ struct rarch_joypad_driver
|
||||
const char *ident;
|
||||
};
|
||||
|
||||
struct hid_driver
|
||||
{
|
||||
void *(*init)(void);
|
||||
bool (*query_pad)(void *, unsigned);
|
||||
void (*free)(void *);
|
||||
bool (*button)(void *, unsigned, uint16_t);
|
||||
uint64_t (*get_buttons)(void *, unsigned);
|
||||
int16_t (*axis)(void *, unsigned, uint32_t);
|
||||
void (*poll)(void *);
|
||||
bool (*set_rumble)(void *, unsigned, enum retro_rumble_effect, uint16_t);
|
||||
const char *(*name)(void *, unsigned);
|
||||
|
||||
const char *ident;
|
||||
};
|
||||
|
||||
extern const input_driver_t *current_input;
|
||||
extern void *current_input_data;
|
||||
|
||||
@ -550,6 +566,44 @@ const char *input_joypad_name(const input_device_driver_t *driver,
|
||||
|
||||
bool input_config_get_bind_idx(unsigned port, unsigned *joy_idx_real);
|
||||
|
||||
/**
|
||||
* hid_driver_find_handle:
|
||||
* @index : 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 index);
|
||||
|
||||
/**
|
||||
* hid_driver_find_ident:
|
||||
* @index : 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 index);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* input_hid_init_first:
|
||||
*
|
||||
* Finds first suitable HID driver and initializes.
|
||||
*
|
||||
* Returns: HID driver if found, otherwise NULL.
|
||||
**/
|
||||
const hid_driver_t *input_hid_init_first(void);
|
||||
|
||||
const void *hid_driver_get_data(void);
|
||||
|
||||
extern input_device_driver_t dinput_joypad;
|
||||
extern input_device_driver_t linuxraw_joypad;
|
||||
extern input_device_driver_t parport_joypad;
|
||||
@ -590,6 +644,12 @@ extern input_driver_t input_winraw;
|
||||
extern input_driver_t input_wayland;
|
||||
extern input_driver_t input_null;
|
||||
|
||||
extern hid_driver_t iohidmanager_hid;
|
||||
extern hid_driver_t btstack_hid;
|
||||
extern hid_driver_t libusb_hid;
|
||||
extern hid_driver_t wiiusb_hid;
|
||||
extern hid_driver_t null_hid;
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
@ -1,119 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2017 - 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/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
#include "input_hid_driver.h"
|
||||
#include "../list_special.h"
|
||||
#include "../verbosity.h"
|
||||
|
||||
static hid_driver_t *hid_drivers[] = {
|
||||
#if defined(HAVE_BTSTACK)
|
||||
&btstack_hid,
|
||||
#endif
|
||||
#if defined(__APPLE__) && defined(HAVE_IOHIDMANAGER)
|
||||
&iohidmanager_hid,
|
||||
#endif
|
||||
#if defined(HAVE_LIBUSB) && defined(HAVE_THREADS)
|
||||
&libusb_hid,
|
||||
#endif
|
||||
#ifdef HW_RVL
|
||||
&wiiusb_hid,
|
||||
#endif
|
||||
&null_hid,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const void *hid_data = NULL;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
const void *hid_driver_get_data(void)
|
||||
{
|
||||
return hid_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
return char_list_new_special(STRING_LIST_INPUT_HID_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* input_hid_init_first:
|
||||
*
|
||||
* Finds first suitable HID driver and initializes.
|
||||
*
|
||||
* Returns: HID driver if found, otherwise NULL.
|
||||
**/
|
||||
const hid_driver_t *input_hid_init_first(void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; hid_drivers[i]; i++)
|
||||
{
|
||||
hid_data = hid_drivers[i]->init();
|
||||
|
||||
if (hid_data)
|
||||
{
|
||||
RARCH_LOG("Found HID driver: \"%s\".\n",
|
||||
hid_drivers[i]->ident);
|
||||
return hid_drivers[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2017 - 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/>.
|
||||
*/
|
||||
|
||||
#ifndef INPUT_HID_DRIVER_H__
|
||||
#define INPUT_HID_DRIVER_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
#include <libretro.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
typedef struct hid_driver hid_driver_t;
|
||||
|
||||
struct hid_driver
|
||||
{
|
||||
void *(*init)(void);
|
||||
bool (*query_pad)(void *, unsigned);
|
||||
void (*free)(void *);
|
||||
bool (*button)(void *, unsigned, uint16_t);
|
||||
uint64_t (*get_buttons)(void *, unsigned);
|
||||
int16_t (*axis)(void *, unsigned, uint32_t);
|
||||
void (*poll)(void *);
|
||||
bool (*set_rumble)(void *, unsigned, enum retro_rumble_effect, uint16_t);
|
||||
const char *(*name)(void *, unsigned);
|
||||
|
||||
const char *ident;
|
||||
};
|
||||
|
||||
/**
|
||||
* hid_driver_find_handle:
|
||||
* @index : 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 index);
|
||||
|
||||
/**
|
||||
* hid_driver_find_ident:
|
||||
* @index : 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 index);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* input_hid_init_first:
|
||||
*
|
||||
* Finds first suitable HID driver and initializes.
|
||||
*
|
||||
* Returns: HID driver if found, otherwise NULL.
|
||||
**/
|
||||
const hid_driver_t *input_hid_init_first(void);
|
||||
|
||||
const void *hid_driver_get_data(void);
|
||||
|
||||
extern hid_driver_t iohidmanager_hid;
|
||||
extern hid_driver_t btstack_hid;
|
||||
extern hid_driver_t libusb_hid;
|
||||
extern hid_driver_t wiiusb_hid;
|
||||
extern hid_driver_t null_hid;
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
@ -48,7 +48,6 @@
|
||||
#include "core_info.h"
|
||||
#include "gfx/video_driver.h"
|
||||
#include "input/input_driver.h"
|
||||
#include "input/input_hid_driver.h"
|
||||
#include "audio/audio_driver.h"
|
||||
#include "record/record_driver.h"
|
||||
#include "configuration.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user