2015-01-10 19:10:45 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2015 - 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_JOYPAD_H__
|
|
|
|
#define INPUT_JOYPAD_H__
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "../driver.h"
|
|
|
|
|
2015-01-10 19:48:26 +00:00
|
|
|
/**
|
|
|
|
* input_conv_analog_id_to_bind_id:
|
|
|
|
* @idx : Analog key index.
|
|
|
|
* E.g.:
|
|
|
|
* - RETRO_DEVICE_INDEX_ANALOG_LEFT
|
|
|
|
* - RETRO_DEVICE_INDEX_ANALOG_RIGHT
|
|
|
|
* @ident : Analog key identifier.
|
|
|
|
* E.g.:
|
|
|
|
* - RETRO_DEVICE_ID_ANALOG_X
|
|
|
|
* - RETRO_DEVICE_ID_ANALOG_Y
|
|
|
|
* @ident_minus : Bind ID minus, will be set by function.
|
|
|
|
* @ident_plus : Bind ID plus, will be set by function.
|
|
|
|
*
|
|
|
|
* Takes as input analog key identifiers and converts
|
|
|
|
* them to corresponding bind IDs @ident_minus and @ident_plus.
|
|
|
|
**/
|
2015-01-10 19:10:45 +00:00
|
|
|
static inline void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident,
|
|
|
|
unsigned *ident_minus, unsigned *ident_plus)
|
|
|
|
{
|
|
|
|
switch ((idx << 1) | ident)
|
|
|
|
{
|
|
|
|
case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_X:
|
|
|
|
*ident_minus = RARCH_ANALOG_LEFT_X_MINUS;
|
|
|
|
*ident_plus = RARCH_ANALOG_LEFT_X_PLUS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_Y:
|
|
|
|
*ident_minus = RARCH_ANALOG_LEFT_Y_MINUS;
|
|
|
|
*ident_plus = RARCH_ANALOG_LEFT_Y_PLUS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_X:
|
|
|
|
*ident_minus = RARCH_ANALOG_RIGHT_X_MINUS;
|
|
|
|
*ident_plus = RARCH_ANALOG_RIGHT_X_PLUS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_Y:
|
|
|
|
*ident_minus = RARCH_ANALOG_RIGHT_Y_MINUS;
|
|
|
|
*ident_plus = RARCH_ANALOG_RIGHT_Y_PLUS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:34:37 +00:00
|
|
|
/**
|
|
|
|
* input_joypad_pressed:
|
|
|
|
* @drv : Joypad driver handle.
|
|
|
|
* @port : User number.
|
|
|
|
* @binds : Binds of user.
|
|
|
|
* @key : Identifier of key.
|
|
|
|
*
|
|
|
|
* Checks if key (@key) was being pressed by user
|
|
|
|
* with number @port with provided keybinds (@binds).
|
|
|
|
*
|
|
|
|
* Returns: true (1) if key was pressed, otherwise
|
|
|
|
* false (0).
|
|
|
|
**/
|
2015-01-10 19:10:45 +00:00
|
|
|
bool input_joypad_pressed(const rarch_joypad_driver_t *driver,
|
|
|
|
unsigned port, const struct retro_keybind *binds, unsigned key);
|
|
|
|
|
2015-01-10 19:48:26 +00:00
|
|
|
/**
|
|
|
|
* input_joypad_analog:
|
|
|
|
* @drv : Joypad driver handle.
|
|
|
|
* @port : User number.
|
|
|
|
* @idx : Analog key index.
|
|
|
|
* E.g.:
|
|
|
|
* - RETRO_DEVICE_INDEX_ANALOG_LEFT
|
|
|
|
* - RETRO_DEVICE_INDEX_ANALOG_RIGHT
|
|
|
|
* @ident : Analog key identifier.
|
|
|
|
* E.g.:
|
|
|
|
* - RETRO_DEVICE_ID_ANALOG_X
|
|
|
|
* - RETRO_DEVICE_ID_ANALOG_Y
|
|
|
|
* @binds : Binds of user.
|
|
|
|
*
|
|
|
|
* Gets analog value of analog key identifiers @idx and @ident
|
|
|
|
* from user with number @port with provided keybinds (@binds).
|
|
|
|
*
|
|
|
|
* Returns: analog value on success, otherwise 0.
|
|
|
|
**/
|
2015-01-10 19:10:45 +00:00
|
|
|
int16_t input_joypad_analog(const rarch_joypad_driver_t *driver,
|
|
|
|
unsigned port, unsigned idx, unsigned ident,
|
|
|
|
const struct retro_keybind *binds);
|
|
|
|
|
2015-01-10 19:48:26 +00:00
|
|
|
/**
|
|
|
|
* input_joypad_set_rumble:
|
|
|
|
* @drv : Joypad driver handle.
|
|
|
|
* @port : User number.
|
|
|
|
* @effect : Rumble effect to set.
|
|
|
|
* @strength : Strength of rumble effect.
|
|
|
|
*
|
|
|
|
* Sets rumble effect @effect with strength @strength.
|
|
|
|
*
|
|
|
|
* Returns: true (1) if successful, otherwise false (0).
|
|
|
|
**/
|
2015-01-10 19:10:45 +00:00
|
|
|
bool input_joypad_set_rumble(const rarch_joypad_driver_t *driver,
|
|
|
|
unsigned port, enum retro_rumble_effect effect, uint16_t strength);
|
|
|
|
|
2015-01-10 19:34:37 +00:00
|
|
|
/**
|
|
|
|
* input_joypad_axis_raw:
|
|
|
|
* @drv : Joypad driver handle.
|
|
|
|
* @port : Joystick number.
|
|
|
|
* @axis : Identifier of axis.
|
|
|
|
*
|
|
|
|
* Checks if axis (@axis) was being pressed by user
|
|
|
|
* with joystick number @port.
|
|
|
|
*
|
|
|
|
* Returns: true (1) if axis was pressed, otherwise
|
|
|
|
* false (0).
|
|
|
|
**/
|
2015-01-10 19:10:45 +00:00
|
|
|
int16_t input_joypad_axis_raw(const rarch_joypad_driver_t *driver,
|
2015-01-10 19:34:37 +00:00
|
|
|
unsigned port, unsigned axis);
|
2015-01-10 19:10:45 +00:00
|
|
|
|
2015-01-10 19:34:37 +00:00
|
|
|
/**
|
|
|
|
* input_joypad_button_raw:
|
|
|
|
* @drv : Joypad driver handle.
|
|
|
|
* @port : Joystick number.
|
|
|
|
* @button : Identifier of key.
|
|
|
|
*
|
|
|
|
* Checks if key (@button) was being pressed by user
|
|
|
|
* with joystick number @port.
|
|
|
|
*
|
|
|
|
* Returns: true (1) if key was pressed, otherwise
|
|
|
|
* false (0).
|
|
|
|
**/
|
2015-01-10 19:10:45 +00:00
|
|
|
bool input_joypad_button_raw(const rarch_joypad_driver_t *driver,
|
2015-01-10 19:34:37 +00:00
|
|
|
unsigned port, unsigned button);
|
2015-01-10 19:10:45 +00:00
|
|
|
|
|
|
|
bool input_joypad_hat_raw(const rarch_joypad_driver_t *driver,
|
|
|
|
unsigned joypad, unsigned hat_dir, unsigned hat);
|
|
|
|
|
2015-01-10 19:34:37 +00:00
|
|
|
/**
|
|
|
|
* input_joypad_name:
|
|
|
|
* @drv : Joypad driver handle.
|
|
|
|
* @port : Joystick number.
|
|
|
|
*
|
|
|
|
* Gets name of the joystick (@port).
|
|
|
|
*
|
|
|
|
* Returns: name of joystick #port.
|
|
|
|
**/
|
2015-01-10 19:10:45 +00:00
|
|
|
const char *input_joypad_name(const rarch_joypad_driver_t *driver,
|
2015-01-10 19:34:37 +00:00
|
|
|
unsigned port);
|
2015-01-10 19:10:45 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|