2014-10-04 16:41:23 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2013-2014 - Jason Fetters
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
2014-10-04 16:41:23 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _JOYPAD_CONNECTION_H
|
|
|
|
#define _JOYPAD_CONNECTION_H
|
|
|
|
|
2014-10-04 17:14:04 +00:00
|
|
|
#include <stdint.h>
|
2014-10-04 17:07:59 +00:00
|
|
|
#include <stddef.h>
|
2014-10-05 23:49:00 +00:00
|
|
|
#include "../input_common.h"
|
2014-10-04 17:07:59 +00:00
|
|
|
|
2014-10-04 20:05:38 +00:00
|
|
|
typedef void (*send_control_t)(void *data, uint8_t *buf, size_t size);
|
|
|
|
|
2014-10-04 17:14:04 +00:00
|
|
|
typedef struct pad_connection_interface
|
2014-10-04 17:07:59 +00:00
|
|
|
{
|
2014-10-22 05:59:52 +00:00
|
|
|
void* (*init)(void *data, uint32_t slot, send_control_t ptr);
|
|
|
|
void (*deinit)(void* device);
|
2014-10-04 18:53:58 +00:00
|
|
|
void (*packet_handler)(void* device, uint8_t *packet, uint16_t size);
|
|
|
|
void (*set_rumble)(void* device, enum retro_rumble_effect effect,
|
2014-10-04 17:07:59 +00:00
|
|
|
uint16_t strength);
|
2015-02-15 00:57:29 +00:00
|
|
|
uint64_t (*get_buttons)(void *data);
|
2014-10-04 18:53:58 +00:00
|
|
|
int16_t (*get_axis)(void *data, unsigned axis);
|
2014-10-04 17:14:04 +00:00
|
|
|
} pad_connection_interface_t;
|
|
|
|
|
2014-10-04 19:10:59 +00:00
|
|
|
extern pad_connection_interface_t pad_connection_wii;
|
|
|
|
extern pad_connection_interface_t pad_connection_ps3;
|
2015-03-31 17:23:06 +00:00
|
|
|
extern pad_connection_interface_t pad_connection_ps4;
|
2014-10-04 17:07:59 +00:00
|
|
|
|
2015-03-31 13:14:39 +00:00
|
|
|
typedef struct joypad_connection
|
2014-10-05 22:37:11 +00:00
|
|
|
{
|
2015-02-15 02:54:38 +00:00
|
|
|
bool connected;
|
2014-10-05 22:37:11 +00:00
|
|
|
struct pad_connection_interface *iface;
|
|
|
|
void* data;
|
|
|
|
} joypad_connection_t;
|
|
|
|
|
2014-10-22 05:59:52 +00:00
|
|
|
int32_t pad_connection_pad_init(joypad_connection_t *joyconn,
|
2015-04-03 21:30:39 +00:00
|
|
|
const char* name, uint16_t vid, uint16_t pid,
|
|
|
|
void *data, send_control_t ptr);
|
2014-10-04 17:07:59 +00:00
|
|
|
|
2014-10-05 23:49:00 +00:00
|
|
|
void *pad_connection_init(unsigned pads);
|
2014-10-04 20:32:14 +00:00
|
|
|
|
2014-10-05 23:49:00 +00:00
|
|
|
void pad_connection_destroy(joypad_connection_t *joyconn);
|
2014-10-04 20:32:14 +00:00
|
|
|
|
2014-10-22 05:59:52 +00:00
|
|
|
void pad_connection_pad_deinit(joypad_connection_t *joyconn,
|
2014-10-20 18:32:41 +00:00
|
|
|
unsigned idx);
|
2014-10-04 17:07:59 +00:00
|
|
|
|
2014-10-05 23:49:00 +00:00
|
|
|
void pad_connection_packet(joypad_connection_t *joyconn,
|
2014-10-20 18:32:41 +00:00
|
|
|
unsigned idx, uint8_t* data, uint32_t length);
|
2014-10-04 17:07:59 +00:00
|
|
|
|
2015-02-15 00:57:29 +00:00
|
|
|
uint64_t pad_connection_get_buttons(joypad_connection_t *joyconn,
|
2014-10-20 18:32:41 +00:00
|
|
|
unsigned idx);
|
2014-10-04 18:53:58 +00:00
|
|
|
|
2014-10-05 23:49:00 +00:00
|
|
|
int16_t pad_connection_get_axis(joypad_connection_t *joyconn,
|
2014-10-20 18:32:41 +00:00
|
|
|
unsigned idx, unsigned i);
|
2014-10-04 18:53:58 +00:00
|
|
|
|
2014-10-04 17:07:59 +00:00
|
|
|
/* Determine if connected joypad is a hidpad backed device.
|
|
|
|
* If false, pad_connection_packet cannot be used */
|
|
|
|
|
2014-10-05 23:49:00 +00:00
|
|
|
bool pad_connection_has_interface(joypad_connection_t *joyconn,
|
2014-10-20 18:32:41 +00:00
|
|
|
unsigned idx);
|
2014-10-04 17:07:59 +00:00
|
|
|
|
2015-04-04 21:34:04 +00:00
|
|
|
int pad_connection_find_vacant_pad(joypad_connection_t *joyconn);
|
|
|
|
|
2014-10-14 17:01:52 +00:00
|
|
|
bool pad_connection_rumble(joypad_connection_t *s,
|
|
|
|
unsigned pad, enum retro_rumble_effect effect, uint16_t strength);
|
|
|
|
|
2014-10-04 16:41:23 +00:00
|
|
|
#endif
|