mirror of
https://github.com/libretro/RetroArch
synced 2025-03-30 16:20:27 +00:00
(Linuxraw joypad) Update linuxraw joypad driver
This commit is contained in:
parent
3fff1abb83
commit
85c4c15c84
@ -32,7 +32,7 @@
|
||||
struct linuxraw_joypad
|
||||
{
|
||||
int fd;
|
||||
bool buttons[NUM_BUTTONS];
|
||||
uint32_t buttons;
|
||||
int16_t axes[NUM_AXES];
|
||||
|
||||
char *ident;
|
||||
@ -54,7 +54,12 @@ static void poll_pad(struct linuxraw_joypad *pad)
|
||||
{
|
||||
case JS_EVENT_BUTTON:
|
||||
if (event.number < NUM_BUTTONS)
|
||||
pad->buttons[event.number] = event.value;
|
||||
{
|
||||
if (event.value)
|
||||
BIT32_SET(pad->buttons, event.value);
|
||||
else
|
||||
BIT32_CLEAR(pad->buttons, event.number);
|
||||
}
|
||||
break;
|
||||
|
||||
case JS_EVENT_AXIS:
|
||||
@ -146,7 +151,7 @@ static void handle_plugged_pad(void)
|
||||
|
||||
RARCH_LOG("[Joypad]: Joypad %s disconnected.\n", g_pads[index].ident);
|
||||
close(g_pads[index].fd);
|
||||
memset(g_pads[index].buttons, 0, sizeof(g_pads[index].buttons));
|
||||
g_pads[index].buttons = 0;
|
||||
memset(g_pads[index].axes, 0, sizeof(g_pads[index].axes));
|
||||
g_pads[index].fd = -1;
|
||||
*g_pads[index].ident = '\0';
|
||||
@ -267,7 +272,7 @@ static bool linuxraw_joypad_button(unsigned port, uint16_t joykey)
|
||||
{
|
||||
const struct linuxraw_joypad *pad = &g_pads[port];
|
||||
|
||||
return joykey < NUM_BUTTONS && pad->buttons[joykey];
|
||||
return joykey < NUM_BUTTONS && BIT32_GET(pad->buttons, joykey);
|
||||
}
|
||||
|
||||
static int16_t linuxraw_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
|
@ -45,7 +45,7 @@ struct udev_joypad
|
||||
dev_t device;
|
||||
|
||||
// Input state polled
|
||||
int16_t buttons;
|
||||
uint32_t buttons;
|
||||
int16_t axes[NUM_AXES];
|
||||
int8_t hats[NUM_HATS][2];
|
||||
|
||||
@ -102,9 +102,9 @@ static void poll_pad(unsigned p)
|
||||
if (code >= BTN_MISC || (code >= KEY_UP && code <= KEY_DOWN))
|
||||
{
|
||||
if (events[i].value)
|
||||
BIT16_SET(pad->buttons, pad->button_bind[code]);
|
||||
BIT32_SET(pad->buttons, pad->button_bind[code]);
|
||||
else
|
||||
BIT16_CLEAR(pad->buttons, pad->button_bind[code]);
|
||||
BIT32_CLEAR(pad->buttons, pad->button_bind[code]);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -557,7 +557,7 @@ static bool udev_joypad_button(unsigned port, uint16_t joykey)
|
||||
|
||||
if (GET_HAT_DIR(joykey))
|
||||
return udev_joypad_hat(pad, joykey);
|
||||
return joykey < NUM_BUTTONS && BIT16_GET(pad->buttons, joykey);
|
||||
return joykey < NUM_BUTTONS && BIT32_GET(pad->buttons, joykey);
|
||||
}
|
||||
|
||||
static int16_t udev_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
|
Loading…
x
Reference in New Issue
Block a user