mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 12:40:23 +00:00
dinput_joypad_button - further cleanups
This commit is contained in:
parent
051fb92e83
commit
f06607141d
@ -49,8 +49,10 @@ struct dinput_joypad_data
|
||||
|
||||
/* For DIJOYSTATE2 struct, rgbButtons will always have 128 elements */
|
||||
#define ARRAY_SIZE_RGB_BUTTONS 128
|
||||
/* For DIJOYSTATE2 struct, rgdwPOV will always have 4 elements */
|
||||
#define ARRAY_SIZE_RGDWPOV 4
|
||||
|
||||
#ifndef NUM_HATS
|
||||
#define NUM_HATS 4
|
||||
#endif
|
||||
|
||||
static struct dinput_joypad_data g_pads[MAX_USERS];
|
||||
static unsigned g_joypad_cnt;
|
||||
@ -423,26 +425,15 @@ static bool dinput_joypad_init(void *data)
|
||||
|
||||
static bool dinput_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
unsigned hat_dir = 0;
|
||||
const struct dinput_joypad_data *pad = &g_pads[port_num];
|
||||
|
||||
if (!pad || !pad->joypad)
|
||||
return false;
|
||||
|
||||
hat_dir = GET_HAT_DIR(joykey);
|
||||
|
||||
/* Check hat. */
|
||||
unsigned hat_dir = GET_HAT_DIR(joykey);
|
||||
|
||||
if (hat_dir)
|
||||
{
|
||||
unsigned pov;
|
||||
unsigned hat = GET_HAT(joykey);
|
||||
|
||||
if (hat >= ARRAY_SIZE_RGDWPOV)
|
||||
return false;
|
||||
|
||||
pov = pad->joy_state.rgdwPOV[hat];
|
||||
|
||||
unsigned h = GET_HAT(joykey);
|
||||
if (h < NUM_HATS)
|
||||
{
|
||||
unsigned pov = pad->joy_state.rgdwPOV[h];
|
||||
switch (hat_dir)
|
||||
{
|
||||
case HAT_UP_MASK:
|
||||
@ -482,12 +473,11 @@ static bool dinput_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
(pov == check2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return (joykey < ARRAY_SIZE_RGB_BUTTONS)
|
||||
&& pad->joy_state.rgbButtons[joykey];
|
||||
return (joykey < ARRAY_SIZE_RGB_BUTTONS) && pad->joy_state.rgbButtons[joykey];
|
||||
}
|
||||
|
||||
static int16_t dinput_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
|
@ -51,7 +51,10 @@
|
||||
|
||||
#define UDEV_NUM_BUTTONS 32
|
||||
#define NUM_AXES 32
|
||||
|
||||
#ifndef NUM_HATS
|
||||
#define NUM_HATS 4
|
||||
#endif
|
||||
|
||||
#define test_bit(nr, addr) \
|
||||
(((1UL << ((nr) % (sizeof(long) * CHAR_BIT))) & ((addr)[(nr) / (sizeof(long) * CHAR_BIT)])) != 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user