diff options
author | Mattias Andrée <maandree@kth.se> | 2022-07-27 15:32:10 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-07-27 15:32:10 +0200 |
commit | 586ddd6fad5061ea1de4b0fbe903c1c9ea582f72 (patch) | |
tree | e34b10acf215a2140df2fd3728300c34825f0734 /libgamepad_get_button_is_pressed.c | |
parent | names.sh: improve readability (diff) | |
download | libgamepad-586ddd6fad5061ea1de4b0fbe903c1c9ea582f72.tar.gz libgamepad-586ddd6fad5061ea1de4b0fbe903c1c9ea582f72.tar.bz2 libgamepad-586ddd6fad5061ea1de4b0fbe903c1c9ea582f72.tar.xz |
m + add controller fingerprint + relay less on libevdev
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-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); } |