RetroArch/input/connect/joypad_connection.h
gblues 5b37ced196 Update HID pad driver architecture
== DETAILS

The current HID implementation assumes a very low-level USB library
is being used. This causes a problem on Wii U, because the Cafe OS
only exposes a high-level interface.

To get these functions exposed to the HID pad drivers, I had to make
three changes:

1. I added the legacy "send_control" function to the HID driver
   interface
2. I modified the signature of pad_connection_pad_init() to send the
   driver pointer instead of the function pointer
3. I updated the HID pad drivers to keep the pointer to the driver
   instead of the function pointer, and updated the calls into the
   send_control function as appropriate
4. I updated the HID drivers to use the new pad init signature

== TESTING
Untested, in theory it should work without a hitch because at this
point all I've done is abstract things a little. I still need to
update the HID pad drivers to use the Wii U-specific calls as
appropriate.
2017-12-30 04:41:01 +01:00

94 lines
3.2 KiB
C

/* RetroArch - A frontend for libretro.
* Copyright (C) 2013-2014 - Jason Fetters
* 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 _JOYPAD_CONNECTION_H
#define _JOYPAD_CONNECTION_H
#include <stdint.h>
#include <stddef.h>
#include <libretro.h>
#include <retro_miscellaneous.h>
#include "../input_driver.h"
struct joypad_connection
{
bool connected;
struct pad_connection_interface *iface;
void* data;
};
typedef struct pad_connection_interface
{
void* (*init)(void *data, uint32_t slot, hid_driver_t *driver);
void (*deinit)(void* device);
void (*packet_handler)(void* device, uint8_t *packet, uint16_t size);
void (*set_rumble)(void* device, enum retro_rumble_effect effect,
uint16_t strength);
void (*get_buttons)(void *data, retro_bits_t *state);
int16_t (*get_axis)(void *data, unsigned axis);
const char* (*get_name)(void *data);
} pad_connection_interface_t;
typedef struct joypad_connection joypad_connection_t;
extern pad_connection_interface_t pad_connection_wii;
extern pad_connection_interface_t pad_connection_wiiupro;
extern pad_connection_interface_t pad_connection_ps3;
extern pad_connection_interface_t pad_connection_ps4;
extern pad_connection_interface_t pad_connection_snesusb;
extern pad_connection_interface_t pad_connection_nesusb;
extern pad_connection_interface_t pad_connection_wiiugca;
extern pad_connection_interface_t pad_connection_ps2adapter;
extern pad_connection_interface_t pad_connection_psxadapter;
int32_t pad_connection_pad_init(joypad_connection_t *joyconn,
const char* name, uint16_t vid, uint16_t pid,
void *data, hid_driver_t *driver);
joypad_connection_t *pad_connection_init(unsigned pads);
void pad_connection_destroy(joypad_connection_t *joyconn);
void pad_connection_pad_deinit(joypad_connection_t *joyconn,
uint32_t idx);
void pad_connection_packet(joypad_connection_t *joyconn,
uint32_t idx, uint8_t* data, uint32_t length);
void pad_connection_get_buttons(joypad_connection_t *joyconn,
unsigned idx, retro_bits_t* state);
int16_t pad_connection_get_axis(joypad_connection_t *joyconn,
unsigned idx, unsigned i);
/* Determine if connected joypad is a hidpad backed device.
* If false, pad_connection_packet cannot be used */
bool pad_connection_has_interface(joypad_connection_t *joyconn,
unsigned idx);
int pad_connection_find_vacant_pad(joypad_connection_t *joyconn);
bool pad_connection_rumble(joypad_connection_t *s,
unsigned pad, enum retro_rumble_effect effect, uint16_t strength);
const char* pad_connection_get_name(joypad_connection_t *joyconn,
unsigned idx);
#endif