diff options
Diffstat (limited to 'libgamepad_get_button_is_pressed.c')
-rw-r--r-- | libgamepad_get_button_is_pressed.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libgamepad_get_button_is_pressed.c b/libgamepad_get_button_is_pressed.c index e3c0265..3c545c1 100644 --- a/libgamepad_get_button_is_pressed.c +++ b/libgamepad_get_button_is_pressed.c @@ -2,8 +2,17 @@ #include "common.h" +#if defined(__GNUC__) +# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" +#endif + + int libgamepad_get_button_is_pressed(struct libgamepad_device *device, uint16_t code) { - return libevdev_get_event_value(device->internals->dev, EV_KEY, (unsigned int)code); + int16_t i; + if ((size_t)code >= ELEMSOF(device->button_map)) + return 0; + i = device->button_map[code]; + return i >= 0 && (int)GETBIT(device->internals->buttons, (uint16_t)i); } |