mirror of
https://github.com/libretro/RetroArch
synced 2025-03-05 19:13:45 +00:00
Change function signature of joypad driver's 'button'
This commit is contained in:
parent
34662e8fe8
commit
8b078662cd
@ -70,7 +70,7 @@ typedef struct pad_connection_interface
|
||||
void (*get_buttons)(void *data, input_bits_t *state);
|
||||
int16_t (*get_axis)(void *data, unsigned axis);
|
||||
const char* (*get_name)(void *data);
|
||||
bool (*button)(void *data, uint16_t joykey);
|
||||
int16_t (*button)(void *data, uint16_t joykey);
|
||||
} pad_connection_interface_t;
|
||||
|
||||
extern pad_connection_interface_t pad_connection_wii;
|
||||
|
@ -1363,7 +1363,7 @@ static void btstack_hid_joypad_get_buttons(void *data, unsigned port,
|
||||
BIT256_CLEAR_ALL_PTR(state);
|
||||
}
|
||||
|
||||
static bool btstack_hid_joypad_button(void *data,
|
||||
static int16_t btstack_hid_joypad_button(void *data,
|
||||
unsigned port, uint16_t joykey)
|
||||
{
|
||||
input_bits_t buttons;
|
||||
@ -1371,13 +1371,11 @@ static bool btstack_hid_joypad_button(void *data,
|
||||
|
||||
/* Check hat. */
|
||||
if (GET_HAT_DIR(joykey))
|
||||
return false;
|
||||
|
||||
/* Check the button. */
|
||||
if ((port < MAX_USERS) && (joykey < 32))
|
||||
return 0;
|
||||
else if ((port < MAX_USERS) && (joykey < 32))
|
||||
return (BIT256_GET(buttons, joykey) != 0);
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool btstack_hid_joypad_rumble(void *data, unsigned pad,
|
||||
|
@ -146,12 +146,12 @@ static void iohidmanager_hid_joypad_get_buttons(void *data,
|
||||
BIT256_CLEAR_ALL_PTR(state);
|
||||
}
|
||||
|
||||
static bool iohidmanager_hid_joypad_button(void *data,
|
||||
static int16_t iohidmanager_hid_joypad_button(void *data,
|
||||
unsigned port, uint16_t joykey)
|
||||
{
|
||||
input_bits_t buttons;
|
||||
iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data;
|
||||
unsigned hat_dir = GET_HAT_DIR(joykey);
|
||||
unsigned hat_dir = GET_HAT_DIR(joykey);
|
||||
|
||||
iohidmanager_hid_joypad_get_buttons(data, port, &buttons);
|
||||
|
||||
@ -160,7 +160,7 @@ static bool iohidmanager_hid_joypad_button(void *data,
|
||||
{
|
||||
unsigned h = GET_HAT(joykey);
|
||||
if (h >= 1)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
switch(hat_dir)
|
||||
{
|
||||
@ -172,17 +172,16 @@ static bool iohidmanager_hid_joypad_button(void *data,
|
||||
return hid->hats[port][1] < 0;
|
||||
case HAT_DOWN_MASK:
|
||||
return hid->hats[port][1] > 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
/* hat requested and no hat button down */
|
||||
}
|
||||
|
||||
/* Check the button. */
|
||||
if ((port < MAX_USERS) && (joykey < 32))
|
||||
else if ((port < MAX_USERS) && (joykey < 32))
|
||||
return (BIT256_GET(buttons, joykey) != 0)
|
||||
|| ((hid->buttons[port] & (1 << joykey)) != 0);
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool iohidmanager_hid_joypad_rumble(void *data, unsigned pad,
|
||||
|
@ -454,7 +454,7 @@ static void libusb_hid_joypad_get_buttons(void *data, unsigned port,
|
||||
BIT256_CLEAR_ALL_PTR(state);
|
||||
}
|
||||
|
||||
static bool libusb_hid_joypad_button(void *data,
|
||||
static int16_t libusb_hid_joypad_button(void *data,
|
||||
unsigned port, uint16_t joykey)
|
||||
{
|
||||
input_bits_t buttons;
|
||||
@ -462,12 +462,10 @@ static bool libusb_hid_joypad_button(void *data,
|
||||
|
||||
/* Check hat. */
|
||||
if (GET_HAT_DIR(joykey))
|
||||
return false;
|
||||
|
||||
/* Check the button. */
|
||||
if ((port < MAX_USERS) && (joykey < 32))
|
||||
return 0;
|
||||
else if ((port < MAX_USERS) && (joykey < 32))
|
||||
return (BIT256_GET(buttons, joykey) != 0);
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool libusb_hid_joypad_rumble(void *data, unsigned pad,
|
||||
|
@ -61,13 +61,12 @@ static void wiiu_hid_joypad_get_buttons(void *data, unsigned slot, input_bits_t
|
||||
pad->iface->get_buttons(pad->data, state);
|
||||
}
|
||||
|
||||
static bool wiiu_hid_joypad_button(void *data, unsigned slot, uint16_t joykey)
|
||||
static int16_t wiiu_hid_joypad_button(void *data, unsigned slot, uint16_t joykey)
|
||||
{
|
||||
joypad_connection_t *pad = get_pad((wiiu_hid_t *)data, slot);
|
||||
|
||||
if (!pad)
|
||||
return false;
|
||||
|
||||
return 0;
|
||||
return pad->iface->button(pad->data, joykey);
|
||||
}
|
||||
|
||||
|
@ -539,7 +539,7 @@ static void wiiusb_hid_joypad_get_buttons(void *data,
|
||||
BIT256_CLEAR_ALL_PTR(state);
|
||||
}
|
||||
|
||||
static bool wiiusb_hid_joypad_button(void *data,
|
||||
static int16_t wiiusb_hid_joypad_button(void *data,
|
||||
unsigned port, uint16_t joykey)
|
||||
{
|
||||
input_bits_t buttons;
|
||||
@ -548,13 +548,10 @@ static bool wiiusb_hid_joypad_button(void *data,
|
||||
|
||||
/* Check hat. */
|
||||
if (GET_HAT_DIR(joykey))
|
||||
return false;
|
||||
|
||||
/* Check the button. */
|
||||
if ((port < MAX_USERS) && (joykey < 32))
|
||||
return 0;
|
||||
else if ((port < MAX_USERS) && (joykey < 32))
|
||||
return (BIT256_GET(buttons, joykey) != 0);
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool wiiusb_hid_joypad_rumble(void *data, unsigned pad,
|
||||
|
@ -30,20 +30,20 @@ static bool android_joypad_init(void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool android_joypad_button(unsigned port, uint16_t joykey)
|
||||
static int16_t android_joypad_button(unsigned port, uint16_t joykey)
|
||||
{
|
||||
uint8_t *buf = android_keyboard_state_get(port);
|
||||
struct android_app *android_app = (struct android_app*)g_android;
|
||||
unsigned hat_dir = GET_HAT_DIR(joykey);
|
||||
|
||||
if (port >= DEFAULT_MAX_PADS)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
if (hat_dir)
|
||||
{
|
||||
unsigned h = GET_HAT(joykey);
|
||||
if (h > 0)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
switch (hat_dir)
|
||||
{
|
||||
@ -56,11 +56,14 @@ static bool android_joypad_button(unsigned port, uint16_t joykey)
|
||||
case HAT_DOWN_MASK:
|
||||
return android_app->hat_state[port][1] == 1;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
/* hat requested and no hat button down */
|
||||
}
|
||||
else if (joykey < LAST_KEYCODE)
|
||||
return BIT_GET(buf, joykey);
|
||||
|
||||
return joykey < LAST_KEYCODE && BIT_GET(buf, joykey);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t android_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
@ -87,9 +90,7 @@ static int16_t android_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
return val;
|
||||
}
|
||||
|
||||
static void android_joypad_poll(void)
|
||||
{
|
||||
}
|
||||
static void android_joypad_poll(void) { }
|
||||
|
||||
static bool android_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
|
@ -52,17 +52,13 @@ static void ctr_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
static bool ctr_joypad_init(void *data)
|
||||
{
|
||||
ctr_joypad_autodetect_add(0);
|
||||
|
||||
(void)data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ctr_joypad_button(unsigned port_num, uint16_t key)
|
||||
static int16_t ctr_joypad_button(unsigned port_num, uint16_t key)
|
||||
{
|
||||
if (port_num >= DEFAULT_MAX_PADS)
|
||||
return false;
|
||||
|
||||
return 0;
|
||||
return (pad_state & (1 << key));
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,13 @@
|
||||
#include "../../verbosity.h"
|
||||
#include "dinput_joypad.h"
|
||||
|
||||
/* For DIJOYSTATE2 struct, rgbButtons will always have 128 elements */
|
||||
#define ARRAY_SIZE_RGB_BUTTONS 128
|
||||
|
||||
#ifndef NUM_HATS
|
||||
#define NUM_HATS 4
|
||||
#endif
|
||||
|
||||
struct dinput_joypad_data
|
||||
{
|
||||
LPDIRECTINPUTDEVICE8 joypad;
|
||||
@ -48,13 +55,7 @@ struct dinput_joypad_data
|
||||
DIEFFECT rumble_props;
|
||||
};
|
||||
|
||||
/* For DIJOYSTATE2 struct, rgbButtons will always have 128 elements */
|
||||
#define ARRAY_SIZE_RGB_BUTTONS 128
|
||||
|
||||
#ifndef NUM_HATS
|
||||
#define NUM_HATS 4
|
||||
#endif
|
||||
|
||||
/* TODO/FIXME - static globals */
|
||||
static struct dinput_joypad_data g_pads[MAX_USERS];
|
||||
static unsigned g_joypad_cnt;
|
||||
static unsigned g_last_xinput_pad_idx;
|
||||
@ -73,7 +74,9 @@ extern bool g_xinput_block_pads;
|
||||
extern int g_xinput_pad_indexes[MAX_USERS];
|
||||
extern LPDIRECTINPUT8 g_dinput_ctx;
|
||||
|
||||
bool dinput_joypad_get_vidpid_from_xinput_index(int32_t index, int32_t *vid, int32_t *pid, int32_t *dinput_index)
|
||||
bool dinput_joypad_get_vidpid_from_xinput_index(
|
||||
int32_t index, int32_t *vid,
|
||||
int32_t *pid, int32_t *dinput_index)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -439,13 +442,13 @@ static bool dinput_joypad_init(void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool dinput_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
static int16_t dinput_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
const struct dinput_joypad_data *pad = &g_pads[port_num];
|
||||
unsigned hat_dir = 0;
|
||||
|
||||
if (!pad || !pad->joypad)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
hat_dir = GET_HAT_DIR(joykey);
|
||||
|
||||
@ -493,12 +496,15 @@ static bool dinput_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
(pov == check1) ||
|
||||
(pov == check2);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
/* hat requested and no hat button down */
|
||||
}
|
||||
return (joykey < ARRAY_SIZE_RGB_BUTTONS) && pad->joy_state.rgbButtons[joykey];
|
||||
else if (joykey < ARRAY_SIZE_RGB_BUTTONS)
|
||||
return pad->joy_state.rgbButtons[joykey];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t dinput_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
|
@ -24,7 +24,9 @@
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
bool dinput_joypad_get_vidpid_from_xinput_index(int32_t index, int32_t *vid, int32_t *pid, int32_t *dinput_index);
|
||||
bool dinput_joypad_get_vidpid_from_xinput_index(
|
||||
int32_t index, int32_t *vid,
|
||||
int32_t *pid, int32_t *dinput_index);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
|
@ -164,12 +164,12 @@ static bool dos_joypad_init(void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool dos_joypad_button(unsigned port_num, uint16_t key)
|
||||
static int16_t dos_joypad_button(unsigned port_num, uint16_t key)
|
||||
{
|
||||
uint16_t *buf = dos_keyboard_state_get(port_num);
|
||||
|
||||
if (port_num >= DEFAULT_MAX_PADS)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
@ -195,7 +195,7 @@ static bool dos_joypad_button(unsigned port_num, uint16_t key)
|
||||
return buf[DOSKEY_RIGHT];
|
||||
}
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dos_joypad_poll(void)
|
||||
|
@ -243,10 +243,10 @@ static void check_port0_active(uint8_t pad_count)
|
||||
}
|
||||
}
|
||||
|
||||
static bool gx_joypad_button(unsigned port, uint16_t key)
|
||||
static int16_t gx_joypad_button(unsigned port, uint16_t key)
|
||||
{
|
||||
if (port >= DEFAULT_MAX_PADS)
|
||||
return false;
|
||||
return 0;
|
||||
return (pad_state[port] & (UINT64_C(1) << key));
|
||||
}
|
||||
|
||||
|
@ -48,11 +48,11 @@ static void hid_joypad_free(void)
|
||||
generic_hid = NULL;
|
||||
}
|
||||
|
||||
static bool hid_joypad_button(unsigned port, uint16_t joykey)
|
||||
static int16_t hid_joypad_button(unsigned port, uint16_t joykey)
|
||||
{
|
||||
if (generic_hid && generic_hid->button)
|
||||
return generic_hid->button((void*)hid_driver_get_data(), port, joykey);
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hid_joypad_get_buttons(unsigned port, input_bits_t *state)
|
||||
|
@ -301,12 +301,14 @@ static void linuxraw_joypad_destroy(void)
|
||||
linuxraw_hotplug = false;
|
||||
}
|
||||
|
||||
static bool linuxraw_joypad_button(unsigned port, uint16_t joykey)
|
||||
static int16_t linuxraw_joypad_button(unsigned port, uint16_t joykey)
|
||||
{
|
||||
const struct linuxraw_joypad *pad = (const struct linuxraw_joypad*)
|
||||
&linuxraw_pads[port];
|
||||
|
||||
return joykey < NUM_BUTTONS && BIT32_GET(pad->buttons, joykey);
|
||||
if (joykey < NUM_BUTTONS)
|
||||
return BIT32_GET(pad->buttons, joykey);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void linuxraw_joypad_get_buttons(unsigned port, input_bits_t *state)
|
||||
|
@ -335,16 +335,15 @@ static void apple_gamecontroller_joypad_destroy(void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool apple_gamecontroller_joypad_button(unsigned port, uint16_t joykey)
|
||||
static int16_t apple_gamecontroller_joypad_button(unsigned port, uint16_t joykey)
|
||||
{
|
||||
/* Check hat. */
|
||||
if (GET_HAT_DIR(joykey))
|
||||
return false;
|
||||
return 0;
|
||||
/* Check the button. */
|
||||
if ((port < MAX_USERS) && (joykey < 32))
|
||||
return ((mfi_buttons[port] & (1 << joykey)) != 0);
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void apple_gamecontroller_joypad_get_buttons(unsigned port,
|
||||
|
@ -329,10 +329,12 @@ static void parport_joypad_destroy(void)
|
||||
parport_pads[i].fd = -1;
|
||||
}
|
||||
|
||||
static bool parport_joypad_button(unsigned port, uint16_t joykey)
|
||||
static int16_t parport_joypad_button(unsigned port, uint16_t joykey)
|
||||
{
|
||||
const struct parport_joypad *pad = (const struct parport_joypad*)&parport_pads[port];
|
||||
return joykey < PARPORT_NUM_BUTTONS && BIT32_GET(pad->buttons, joykey);
|
||||
if (joykey < PARPORT_NUM_BUTTONS)
|
||||
return BIT32_GET(pad->buttons, joykey);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void parport_joypad_get_buttons(unsigned port, input_bits_t *state)
|
||||
|
@ -84,11 +84,10 @@ static bool ps2_joypad_init(void *data)
|
||||
return init;
|
||||
}
|
||||
|
||||
static bool ps2_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
static int16_t ps2_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
if (port_num >= DEFAULT_MAX_PADS)
|
||||
return false;
|
||||
|
||||
return 0;
|
||||
return (pad_state[port_num] & (UINT64_C(1) << joykey));
|
||||
}
|
||||
|
||||
|
@ -61,11 +61,10 @@ static bool ps3_joypad_init(void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ps3_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
static int16_t ps3_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
if (port_num >= DEFAULT_MAX_PADS)
|
||||
return false;
|
||||
|
||||
return 0;
|
||||
return pad_state[port_num] & (UINT64_C(1) << joykey);
|
||||
}
|
||||
|
||||
|
@ -130,10 +130,10 @@ static bool ps4_joypad_init(void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ps4_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
static int16_t ps4_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
if (port_num >= PS4_MAX_ORBISPADS)
|
||||
return false;
|
||||
return 0;
|
||||
return (pad_state[port_num] & (UINT64_C(1) << joykey));
|
||||
}
|
||||
|
||||
|
@ -119,11 +119,10 @@ static bool psp_joypad_init(void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool psp_joypad_button(unsigned port_num, uint16_t key)
|
||||
static int16_t psp_joypad_button(unsigned port_num, uint16_t key)
|
||||
{
|
||||
if (port_num >= DEFAULT_MAX_PADS)
|
||||
return false;
|
||||
|
||||
return 0;
|
||||
return (pad_state[port_num] & (UINT64_C(1) << key));
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ static bool qnx_joypad_init(void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool qnx_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
static int16_t qnx_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
qnx_input_device_t* controller = NULL;
|
||||
qnx_input_t *qnx = (qnx_input_t*)input_driver_get_data();
|
||||
@ -56,8 +56,7 @@ static bool qnx_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
|
||||
if(port_num < MAX_USERS && joykey <= 19)
|
||||
return (controller->buttons & (1 << joykey)) != 0;
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t qnx_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
|
@ -99,7 +99,7 @@ static const char *rwebpad_joypad_name(unsigned pad)
|
||||
return "";
|
||||
}
|
||||
|
||||
static bool rwebpad_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
static int16_t rwebpad_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
EmscriptenGamepadEvent gamepad_state;
|
||||
EMSCRIPTEN_RESULT r = emscripten_get_gamepad_status(
|
||||
@ -109,7 +109,7 @@ static bool rwebpad_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
if (joykey < gamepad_state.numButtons)
|
||||
return gamepad_state.digitalButton[joykey];
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rwebpad_joypad_get_buttons(unsigned port_num, input_bits_t *state)
|
||||
|
@ -295,12 +295,12 @@ error:
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool sdl_joypad_button(unsigned port, uint16_t joykey)
|
||||
static int16_t sdl_joypad_button(unsigned port, uint16_t joykey)
|
||||
{
|
||||
unsigned hat_dir = 0;
|
||||
sdl_joypad_t *pad = (sdl_joypad_t*)&sdl_pads[port];
|
||||
if (!pad || !pad->joypad)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
hat_dir = GET_HAT_DIR(joykey);
|
||||
/* Check hat. */
|
||||
@ -327,14 +327,12 @@ static bool sdl_joypad_button(unsigned port, uint16_t joykey)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
/* hat requested and no hat button down */
|
||||
}
|
||||
else if (joykey < pad->num_buttons)
|
||||
return sdl_pad_get_button(pad, joykey);
|
||||
|
||||
/* Check the button */
|
||||
if (joykey < pad->num_buttons && sdl_pad_get_button(pad, joykey))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t sdl_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
|
@ -83,10 +83,10 @@ static bool switch_joypad_init(void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool switch_joypad_button(unsigned port_num, uint16_t key)
|
||||
static int16_t switch_joypad_button(unsigned port_num, uint16_t key)
|
||||
{
|
||||
if (port_num >= DEFAULT_MAX_PADS)
|
||||
return false;
|
||||
return 0;
|
||||
return (pad_state[port_num] & (1 << key));
|
||||
}
|
||||
|
||||
|
@ -590,7 +590,7 @@ error:
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool udev_joypad_button(unsigned port, uint16_t joykey)
|
||||
static int16_t udev_joypad_button(unsigned port, uint16_t joykey)
|
||||
{
|
||||
const struct udev_joypad *pad = (const struct udev_joypad*)&udev_pads[port];
|
||||
unsigned hat_dir = GET_HAT_DIR(joykey);
|
||||
@ -610,11 +610,15 @@ static bool udev_joypad_button(unsigned port, uint16_t joykey)
|
||||
return pad->hats[h][1] < 0;
|
||||
case HAT_DOWN_MASK:
|
||||
return pad->hats[h][1] > 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
/* hat requested and no hat button down */
|
||||
}
|
||||
return joykey < UDEV_NUM_BUTTONS && BIT64_GET(pad->buttons, joykey);
|
||||
else if (joykey < UDEV_NUM_BUTTONS)
|
||||
return BIT64_GET(pad->buttons, joykey);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void udev_joypad_get_buttons(unsigned port, input_bits_t *state)
|
||||
|
@ -58,11 +58,10 @@ static void hidpad_destroy(void)
|
||||
hid_deinit(&hid_instance);
|
||||
}
|
||||
|
||||
static bool hidpad_button(unsigned pad, uint16_t button)
|
||||
static int16_t hidpad_button(unsigned pad, uint16_t button)
|
||||
{
|
||||
if (!hidpad_query_pad(pad))
|
||||
return false;
|
||||
|
||||
return 0;
|
||||
return HID_BUTTON(pad, button);
|
||||
}
|
||||
|
||||
|
@ -98,15 +98,15 @@ static void kpad_destroy(void)
|
||||
kpad_ready = false;
|
||||
}
|
||||
|
||||
static bool kpad_button(unsigned pad, uint16_t button_bit)
|
||||
static int16_t kpad_button(unsigned pad, uint16_t button_bit)
|
||||
{
|
||||
int channel;
|
||||
if (!kpad_query_pad(pad))
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
channel = to_wiimote_channel(pad);
|
||||
if(channel < 0)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
return wiimotes[channel].button_state
|
||||
& (UINT64_C(1) << button_bit);
|
||||
|
@ -278,16 +278,16 @@ static void wpad_destroy(void)
|
||||
|
||||
}
|
||||
|
||||
static bool wpad_button(unsigned pad, uint16_t button_bit)
|
||||
static int16_t wpad_button(unsigned pad, uint16_t button_bit)
|
||||
{
|
||||
VPADChan channel;
|
||||
|
||||
if (!wpad_query_pad(pad))
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
channel = to_gamepad_channel(pad);
|
||||
if (channel < 0)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
return gamepads[channel].button_state & (UINT64_C(1) << button_bit);
|
||||
}
|
||||
|
@ -60,11 +60,10 @@ static void wiiu_joypad_destroy(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool wiiu_joypad_button(unsigned pad, uint16_t key)
|
||||
static int16_t wiiu_joypad_button(unsigned pad, uint16_t key)
|
||||
{
|
||||
if (!wiiu_joypad_query_pad(pad))
|
||||
return false;
|
||||
|
||||
return 0;
|
||||
return pad_drivers[pad]->button(pad, key);
|
||||
}
|
||||
|
||||
|
@ -90,13 +90,13 @@ static const uint16_t button_index_to_bitmap_code[] = {
|
||||
};
|
||||
#endif
|
||||
|
||||
static bool xdk_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
static int16_t xdk_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
uint16_t btn_word = 0;
|
||||
unsigned hat_dir = 0;
|
||||
|
||||
if (port_num >= DEFAULT_MAX_PADS)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
btn_word = g_xinput_states[port_num].xstate.Gamepad.wButtons;
|
||||
hat_dir = GET_HAT_DIR(joykey);
|
||||
@ -114,46 +114,47 @@ static bool xdk_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
case HAT_RIGHT_MASK:
|
||||
return btn_word & XINPUT_GAMEPAD_DPAD_RIGHT;
|
||||
}
|
||||
|
||||
return false; /* hat requested and no hat button down. */
|
||||
/* hat requested and no hat button down */
|
||||
}
|
||||
|
||||
#ifdef _XBOX1
|
||||
switch (joykey)
|
||||
else
|
||||
{
|
||||
case RETRO_DEVICE_ID_JOYPAD_A:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_B] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_B:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_A] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_Y:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_X] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_X:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_Y] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_START:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.wButtons & XINPUT_GAMEPAD_START);
|
||||
case RETRO_DEVICE_ID_JOYPAD_SELECT:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.wButtons & XINPUT_GAMEPAD_BACK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_L3:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB);
|
||||
case RETRO_DEVICE_ID_JOYPAD_R3:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB);
|
||||
case RETRO_DEVICE_ID_JOYPAD_L2:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_WHITE] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_R2:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_BLACK] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_L:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_R:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#ifdef _XBOX1
|
||||
switch (joykey)
|
||||
{
|
||||
case RETRO_DEVICE_ID_JOYPAD_A:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_B] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_B:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_A] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_Y:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_X] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_X:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_Y] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_START:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.wButtons & XINPUT_GAMEPAD_START);
|
||||
case RETRO_DEVICE_ID_JOYPAD_SELECT:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.wButtons & XINPUT_GAMEPAD_BACK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_L3:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB);
|
||||
case RETRO_DEVICE_ID_JOYPAD_R3:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB);
|
||||
case RETRO_DEVICE_ID_JOYPAD_L2:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_WHITE] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_R2:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_BLACK] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_L:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
case RETRO_DEVICE_ID_JOYPAD_R:
|
||||
return (g_xinput_states[port_num].xstate.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#else
|
||||
if (joykey < 10)
|
||||
return btn_word & button_index_to_bitmap_code[joykey];
|
||||
if (joykey < 10)
|
||||
return btn_word & button_index_to_bitmap_code[joykey];
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t xdk_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
|
@ -422,7 +422,7 @@ static const uint16_t button_index_to_bitmap_code[] = {
|
||||
XINPUT_GAMEPAD_GUIDE
|
||||
};
|
||||
|
||||
static bool xinput_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
static int16_t xinput_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
uint16_t btn_word = 0;
|
||||
unsigned hat_dir = 0;
|
||||
@ -434,7 +434,7 @@ static bool xinput_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
#endif
|
||||
|
||||
if (!(g_xinput_states[xuser].connected))
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
btn_word = g_xinput_states[xuser].xstate.Gamepad.wButtons;
|
||||
hat_dir = GET_HAT_DIR(joykey);
|
||||
@ -451,15 +451,15 @@ static bool xinput_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
return btn_word & XINPUT_GAMEPAD_DPAD_LEFT;
|
||||
case HAT_RIGHT_MASK:
|
||||
return btn_word & XINPUT_GAMEPAD_DPAD_RIGHT;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false; /* hat requested and no hat button down. */
|
||||
/* hat requested and no hat button down */
|
||||
}
|
||||
|
||||
if (joykey < g_xinput_num_buttons)
|
||||
else if (joykey < g_xinput_num_buttons)
|
||||
return btn_word & button_index_to_bitmap_code[joykey];
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t xinput_joypad_axis (unsigned port_num, uint32_t joyaxis)
|
||||
|
@ -205,7 +205,7 @@ struct rarch_joypad_driver
|
||||
bool (*init)(void *data);
|
||||
bool (*query_pad)(unsigned);
|
||||
void (*destroy)(void);
|
||||
bool (*button)(unsigned, uint16_t);
|
||||
int16_t (*button)(unsigned, uint16_t);
|
||||
void (*get_buttons)(unsigned, input_bits_t *);
|
||||
int16_t (*axis)(unsigned, uint32_t);
|
||||
void (*poll)(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user