2015-01-12 17:37:50 +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-01-12 17:37:50 +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 __INPUT_DRIVER__H
|
|
|
|
#define __INPUT_DRIVER__H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <sys/types.h>
|
2016-06-03 03:54:21 +00:00
|
|
|
|
2015-01-12 17:37:50 +00:00
|
|
|
#include <boolean.h>
|
2016-06-03 03:54:21 +00:00
|
|
|
#include <retro_common_api.h>
|
2015-01-12 17:37:50 +00:00
|
|
|
|
2015-01-12 19:29:01 +00:00
|
|
|
#include "input_joypad_driver.h"
|
2016-09-05 15:29:19 +00:00
|
|
|
#include "input_defines.h"
|
2015-01-12 17:37:50 +00:00
|
|
|
|
2016-10-25 17:50:03 +00:00
|
|
|
#include "../msg_hash.h"
|
|
|
|
|
2016-06-03 03:54:21 +00:00
|
|
|
RETRO_BEGIN_DECLS
|
2015-01-12 17:37:50 +00:00
|
|
|
|
2015-10-22 17:17:47 +00:00
|
|
|
enum input_device_type
|
|
|
|
{
|
|
|
|
INPUT_DEVICE_TYPE_NONE = 0,
|
|
|
|
INPUT_DEVICE_TYPE_KEYBOARD,
|
|
|
|
INPUT_DEVICE_TYPE_JOYPAD
|
|
|
|
};
|
|
|
|
|
2016-08-02 14:45:50 +00:00
|
|
|
enum input_toggle_type
|
|
|
|
{
|
|
|
|
INPUT_TOGGLE_NONE = 0,
|
|
|
|
INPUT_TOGGLE_DOWN_Y_L_R,
|
|
|
|
INPUT_TOGGLE_L3_R3,
|
2016-08-02 14:48:54 +00:00
|
|
|
INPUT_TOGGLE_L1_R1_START_SELECT,
|
2016-08-02 14:45:50 +00:00
|
|
|
INPUT_TOGGLE_START_SELECT,
|
|
|
|
INPUT_TOGGLE_LAST
|
|
|
|
};
|
|
|
|
|
2017-05-10 05:07:06 +00:00
|
|
|
enum input_action
|
|
|
|
{
|
|
|
|
INPUT_ACTION_NONE = 0,
|
2017-05-11 05:36:21 +00:00
|
|
|
INPUT_ACTION_AXIS_THRESHOLD,
|
|
|
|
INPUT_ACTION_MAX_USERS
|
2017-05-10 05:07:06 +00:00
|
|
|
};
|
|
|
|
|
2015-01-12 17:37:50 +00:00
|
|
|
struct retro_keybind
|
|
|
|
{
|
|
|
|
bool valid;
|
|
|
|
unsigned id;
|
2016-10-25 17:50:03 +00:00
|
|
|
enum msg_hash_enums enum_idx;
|
2015-01-12 17:37:50 +00:00
|
|
|
enum retro_key key;
|
|
|
|
|
2017-01-26 01:49:42 +00:00
|
|
|
/* Joypad key. Joypad POV (hats)
|
|
|
|
* are embedded into this key as well. */
|
2015-01-12 17:37:50 +00:00
|
|
|
uint64_t joykey;
|
2017-01-26 01:49:42 +00:00
|
|
|
|
|
|
|
/* Default key binding value -
|
|
|
|
* for resetting bind to default */
|
2015-01-12 17:37:50 +00:00
|
|
|
uint64_t def_joykey;
|
|
|
|
|
2017-01-26 01:49:42 +00:00
|
|
|
/* Joypad axis. Negative and positive axes
|
|
|
|
* are embedded into this variable. */
|
2015-01-12 17:37:50 +00:00
|
|
|
uint32_t joyaxis;
|
2017-01-26 01:49:42 +00:00
|
|
|
|
|
|
|
/* Default joy axis binding value -
|
|
|
|
* for resetting bind to default */
|
2015-01-12 17:37:50 +00:00
|
|
|
uint32_t def_joyaxis;
|
|
|
|
|
|
|
|
/* Used by input_{push,pop}_analog_dpad(). */
|
|
|
|
uint32_t orig_joyaxis;
|
|
|
|
|
|
|
|
char joykey_label[256];
|
|
|
|
char joyaxis_label[256];
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct input_driver
|
|
|
|
{
|
2017-01-26 01:49:42 +00:00
|
|
|
/* Inits input driver.
|
|
|
|
*/
|
2017-01-10 16:59:48 +00:00
|
|
|
void *(*init)(const char *joypad_driver);
|
2017-01-26 01:49:42 +00:00
|
|
|
|
|
|
|
/* Polls input. Called once every frame. */
|
2015-01-12 17:37:50 +00:00
|
|
|
void (*poll)(void *data);
|
2017-01-26 01:49:42 +00:00
|
|
|
|
|
|
|
/* Queries input state for a certain key on a certain player.
|
|
|
|
* Players are 1 - MAX_USERS.
|
|
|
|
* For digital inputs, pressed key is 1, not pressed key is 0.
|
|
|
|
* Analog values have same range as a signed 16-bit integer.
|
|
|
|
*/
|
2015-01-12 17:37:50 +00:00
|
|
|
int16_t (*input_state)(void *data,
|
2017-01-10 16:40:21 +00:00
|
|
|
rarch_joypad_info_t joypad_info,
|
2015-01-12 17:37:50 +00:00
|
|
|
const struct retro_keybind **retro_keybinds,
|
|
|
|
unsigned port, unsigned device, unsigned index, unsigned id);
|
2017-01-26 01:49:42 +00:00
|
|
|
|
2015-11-07 19:59:12 +00:00
|
|
|
bool (*meta_key_pressed)(void *data, int key);
|
2017-01-26 01:49:42 +00:00
|
|
|
|
|
|
|
/* Frees the input struct. */
|
2015-01-12 17:37:50 +00:00
|
|
|
void (*free)(void *data);
|
2017-01-26 01:49:42 +00:00
|
|
|
|
2015-01-12 17:37:50 +00:00
|
|
|
bool (*set_sensor_state)(void *data, unsigned port,
|
|
|
|
enum retro_sensor_action action, unsigned rate);
|
|
|
|
float (*get_sensor_input)(void *data, unsigned port, unsigned id);
|
|
|
|
uint64_t (*get_capabilities)(void *data);
|
|
|
|
const char *ident;
|
|
|
|
|
|
|
|
void (*grab_mouse)(void *data, bool state);
|
2015-05-19 17:33:58 +00:00
|
|
|
bool (*grab_stdin)(void *data);
|
2015-01-12 17:37:50 +00:00
|
|
|
bool (*set_rumble)(void *data, unsigned port,
|
|
|
|
enum retro_rumble_effect effect, uint16_t state);
|
2015-04-14 14:37:59 +00:00
|
|
|
const input_device_driver_t *(*get_joypad_driver)(void *data);
|
2015-11-16 01:39:38 +00:00
|
|
|
const input_device_driver_t *(*get_sec_joypad_driver)(void *data);
|
2015-06-19 01:45:23 +00:00
|
|
|
bool (*keyboard_mapping_is_blocked)(void *data);
|
|
|
|
void (*keyboard_mapping_set_block)(void *data, bool value);
|
2015-01-12 17:37:50 +00:00
|
|
|
} input_driver_t;
|
|
|
|
|
2016-10-23 02:38:08 +00:00
|
|
|
extern const input_driver_t *current_input;
|
|
|
|
extern void *current_input_data;
|
|
|
|
|
2015-01-12 17:37:50 +00:00
|
|
|
/**
|
|
|
|
* input_driver_find_handle:
|
|
|
|
* @index : index of driver to get handle to.
|
|
|
|
*
|
|
|
|
* Returns: handle to input driver at index. Can be NULL
|
|
|
|
* if nothing found.
|
|
|
|
**/
|
|
|
|
const void *input_driver_find_handle(int index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* input_driver_find_ident:
|
|
|
|
* @index : index of driver to get handle to.
|
|
|
|
*
|
|
|
|
* Returns: Human-readable identifier of input driver at index. Can be NULL
|
|
|
|
* if nothing found.
|
|
|
|
**/
|
|
|
|
const char *input_driver_find_ident(int index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* config_get_input_driver_options:
|
|
|
|
*
|
|
|
|
* Get an enumerated list of all input driver names, separated by '|'.
|
|
|
|
*
|
|
|
|
* Returns: string listing of all input driver names, separated by '|'.
|
|
|
|
**/
|
|
|
|
const char* config_get_input_driver_options(void);
|
|
|
|
|
2015-01-19 03:16:43 +00:00
|
|
|
/**
|
|
|
|
* input_driver_set_rumble_state:
|
|
|
|
* @port : User number.
|
|
|
|
* @effect : Rumble effect.
|
|
|
|
* @strength : Strength of rumble effect.
|
|
|
|
*
|
|
|
|
* Sets the rumble state.
|
|
|
|
* Used by RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE.
|
|
|
|
**/
|
|
|
|
bool input_driver_set_rumble_state(unsigned port,
|
|
|
|
enum retro_rumble_effect effect, uint16_t strength);
|
|
|
|
|
2015-03-23 03:18:27 +00:00
|
|
|
uint64_t input_driver_get_capabilities(void);
|
|
|
|
|
2015-04-14 14:37:59 +00:00
|
|
|
const input_device_driver_t * input_driver_get_joypad_driver(void);
|
2015-03-23 02:40:09 +00:00
|
|
|
|
2015-11-16 01:39:38 +00:00
|
|
|
const input_device_driver_t * input_driver_get_sec_joypad_driver(void);
|
|
|
|
|
2015-06-19 01:45:23 +00:00
|
|
|
void input_driver_keyboard_mapping_set_block(bool value);
|
|
|
|
|
2015-11-25 02:25:31 +00:00
|
|
|
void input_driver_set(const input_driver_t **input, void **input_data);
|
|
|
|
|
2015-11-25 02:29:18 +00:00
|
|
|
/**
|
|
|
|
* input_sensor_set_state:
|
|
|
|
* @port : User number.
|
|
|
|
* @effect : Sensor action.
|
|
|
|
* @rate : Sensor rate update.
|
|
|
|
*
|
|
|
|
* Sets the sensor state.
|
|
|
|
* Used by RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE.
|
|
|
|
**/
|
|
|
|
bool input_sensor_set_state(unsigned port,
|
|
|
|
enum retro_sensor_action action, unsigned rate);
|
|
|
|
|
|
|
|
float input_sensor_get_input(unsigned port, unsigned id);
|
|
|
|
|
2016-12-04 20:37:47 +00:00
|
|
|
#define inherit_joyaxis(binds) (((binds)[x_plus].joyaxis == (binds)[x_minus].joyaxis) || ( (binds)[y_plus].joyaxis == (binds)[y_minus].joyaxis))
|
2016-12-04 20:30:50 +00:00
|
|
|
|
2016-12-04 21:20:47 +00:00
|
|
|
/**
|
|
|
|
* input_pop_analog_dpad:
|
|
|
|
* @binds : Binds to modify.
|
|
|
|
*
|
|
|
|
* Restores binds temporarily overridden by input_push_analog_dpad().
|
|
|
|
**/
|
|
|
|
#define input_pop_analog_dpad(binds) \
|
|
|
|
{ \
|
|
|
|
unsigned j; \
|
|
|
|
for (j = RETRO_DEVICE_ID_JOYPAD_UP; j <= RETRO_DEVICE_ID_JOYPAD_RIGHT; j++) \
|
|
|
|
(binds)[j].joyaxis = (binds)[j].orig_joyaxis; \
|
|
|
|
}
|
|
|
|
|
2015-11-28 01:09:11 +00:00
|
|
|
/**
|
|
|
|
* input_push_analog_dpad:
|
|
|
|
* @binds : Binds to modify.
|
|
|
|
* @mode : Which analog stick to bind D-Pad to.
|
|
|
|
* E.g:
|
|
|
|
* ANALOG_DPAD_LSTICK
|
|
|
|
* ANALOG_DPAD_RSTICK
|
|
|
|
*
|
|
|
|
* Push analog to D-Pad mappings to binds.
|
|
|
|
**/
|
2016-12-04 20:37:47 +00:00
|
|
|
#define input_push_analog_dpad(binds, mode) \
|
|
|
|
{ \
|
|
|
|
unsigned k; \
|
|
|
|
unsigned x_plus = RARCH_ANALOG_RIGHT_X_PLUS; \
|
|
|
|
unsigned y_plus = RARCH_ANALOG_RIGHT_Y_PLUS; \
|
|
|
|
unsigned x_minus = RARCH_ANALOG_RIGHT_X_MINUS; \
|
|
|
|
unsigned y_minus = RARCH_ANALOG_RIGHT_Y_MINUS; \
|
|
|
|
if ((mode) == ANALOG_DPAD_LSTICK) \
|
|
|
|
{ \
|
|
|
|
x_plus = RARCH_ANALOG_LEFT_X_PLUS; \
|
|
|
|
y_plus = RARCH_ANALOG_LEFT_Y_PLUS; \
|
|
|
|
x_minus = RARCH_ANALOG_LEFT_X_MINUS; \
|
|
|
|
y_minus = RARCH_ANALOG_LEFT_Y_MINUS; \
|
|
|
|
} \
|
2016-12-04 21:20:47 +00:00
|
|
|
for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) \
|
|
|
|
(binds)[k].orig_joyaxis = (binds)[k].joyaxis; \
|
2016-12-04 20:37:47 +00:00
|
|
|
if (!inherit_joyaxis(binds)) \
|
|
|
|
{ \
|
|
|
|
unsigned j = x_plus + 3; \
|
|
|
|
/* Inherit joyaxis from analogs. */ \
|
|
|
|
for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) \
|
|
|
|
(binds)[k].joyaxis = (binds)[j--].joyaxis; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2015-11-28 01:09:11 +00:00
|
|
|
/**
|
|
|
|
* input_poll:
|
|
|
|
*
|
|
|
|
* Input polling callback function.
|
|
|
|
**/
|
|
|
|
void input_poll(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* input_state:
|
|
|
|
* @port : user number.
|
|
|
|
* @device : device identifier of user.
|
|
|
|
* @idx : index value of user.
|
|
|
|
* @id : identifier of key pressed by user.
|
|
|
|
*
|
|
|
|
* Input state callback function.
|
|
|
|
*
|
|
|
|
* Returns: Non-zero if the given key (identified by @id) was pressed by the user
|
|
|
|
* (assigned to @port).
|
|
|
|
**/
|
|
|
|
int16_t input_state(unsigned port, unsigned device,
|
|
|
|
unsigned idx, unsigned id);
|
|
|
|
|
2017-05-21 20:31:15 +00:00
|
|
|
uint64_t input_keys_pressed(void *data, uint64_t last_input);
|
2016-12-06 17:12:35 +00:00
|
|
|
|
2016-12-07 02:16:34 +00:00
|
|
|
#ifdef HAVE_MENU
|
2017-05-21 20:31:15 +00:00
|
|
|
uint64_t input_menu_keys_pressed(void *data, uint64_t last_input);
|
2016-12-07 02:16:34 +00:00
|
|
|
#endif
|
2016-10-27 04:38:02 +00:00
|
|
|
|
2015-11-29 17:18:25 +00:00
|
|
|
void *input_driver_get_data(void);
|
|
|
|
|
2015-11-29 17:59:49 +00:00
|
|
|
const input_driver_t *input_get_ptr(void);
|
|
|
|
|
2015-11-29 18:07:02 +00:00
|
|
|
const input_driver_t **input_get_double_ptr(void);
|
|
|
|
|
2015-11-28 17:22:05 +00:00
|
|
|
void **input_driver_get_data_ptr(void);
|
|
|
|
|
2016-05-08 21:12:04 +00:00
|
|
|
bool input_driver_has_capabilities(void);
|
|
|
|
|
|
|
|
void input_driver_poll(void);
|
|
|
|
|
|
|
|
bool input_driver_init(void);
|
|
|
|
|
|
|
|
void input_driver_deinit(void);
|
|
|
|
|
|
|
|
void input_driver_destroy_data(void);
|
|
|
|
|
|
|
|
void input_driver_destroy(void);
|
|
|
|
|
|
|
|
bool input_driver_grab_stdin(void);
|
|
|
|
|
|
|
|
bool input_driver_keyboard_mapping_is_blocked(void);
|
|
|
|
|
|
|
|
bool input_driver_find_driver(void);
|
|
|
|
|
|
|
|
void input_driver_set_flushing_input(void);
|
|
|
|
|
2016-12-06 05:32:28 +00:00
|
|
|
void input_driver_unset_hotkey_block(void);
|
|
|
|
|
2016-05-08 21:12:04 +00:00
|
|
|
void input_driver_set_hotkey_block(void);
|
|
|
|
|
|
|
|
void input_driver_set_libretro_input_blocked(void);
|
|
|
|
|
|
|
|
void input_driver_unset_libretro_input_blocked(void);
|
|
|
|
|
|
|
|
bool input_driver_is_libretro_input_blocked(void);
|
|
|
|
|
|
|
|
void input_driver_set_nonblock_state(void);
|
|
|
|
|
|
|
|
void input_driver_unset_nonblock_state(void);
|
|
|
|
|
|
|
|
bool input_driver_is_nonblock_state(void);
|
|
|
|
|
|
|
|
void input_driver_set_own_driver(void);
|
|
|
|
|
|
|
|
void input_driver_unset_own_driver(void);
|
|
|
|
|
|
|
|
bool input_driver_owns_driver(void);
|
|
|
|
|
|
|
|
void input_driver_deinit_command(void);
|
|
|
|
|
|
|
|
bool input_driver_init_command(void);
|
|
|
|
|
|
|
|
void input_driver_deinit_remote(void);
|
|
|
|
|
|
|
|
bool input_driver_init_remote(void);
|
|
|
|
|
|
|
|
bool input_driver_grab_mouse(void);
|
|
|
|
|
|
|
|
bool input_driver_ungrab_mouse(void);
|
|
|
|
|
2017-05-10 05:07:06 +00:00
|
|
|
float *input_driver_get_float(enum input_action action);
|
|
|
|
|
2017-05-11 05:36:21 +00:00
|
|
|
unsigned *input_driver_get_uint(enum input_action action);
|
|
|
|
|
2016-05-08 21:12:04 +00:00
|
|
|
bool input_driver_is_data_ptr_same(void *data);
|
|
|
|
|
|
|
|
extern input_driver_t input_android;
|
|
|
|
extern input_driver_t input_sdl;
|
|
|
|
extern input_driver_t input_dinput;
|
|
|
|
extern input_driver_t input_x;
|
|
|
|
extern input_driver_t input_ps3;
|
|
|
|
extern input_driver_t input_psp;
|
|
|
|
extern input_driver_t input_ctr;
|
|
|
|
extern input_driver_t input_xenon360;
|
|
|
|
extern input_driver_t input_gx;
|
2016-10-27 00:34:10 +00:00
|
|
|
extern input_driver_t input_wiiu;
|
2016-05-08 21:12:04 +00:00
|
|
|
extern input_driver_t input_xinput;
|
|
|
|
extern input_driver_t input_linuxraw;
|
|
|
|
extern input_driver_t input_udev;
|
|
|
|
extern input_driver_t input_cocoa;
|
|
|
|
extern input_driver_t input_qnx;
|
|
|
|
extern input_driver_t input_rwebinput;
|
2017-01-24 05:55:55 +00:00
|
|
|
extern input_driver_t input_dos;
|
2017-05-18 16:48:41 +00:00
|
|
|
extern input_driver_t input_winraw;
|
2016-05-08 21:12:04 +00:00
|
|
|
extern input_driver_t input_null;
|
|
|
|
|
2016-06-03 03:54:21 +00:00
|
|
|
RETRO_END_DECLS
|
2015-01-12 17:37:50 +00:00
|
|
|
|
|
|
|
#endif
|