From 586ddd6fad5061ea1de4b0fbe903c1c9ea582f72 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 27 Jul 2022 15:32:10 +0200 Subject: m + add controller fingerprint + relay less on libevdev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libgamepad_get_button_is_pressed.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'libgamepad_get_button_is_pressed.c') 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); } -- cgit v1.2.3-70-g09d2