aboutsummaryrefslogblamecommitdiffstats
path: root/libgamepad_get_button_is_pressed.c
blob: 3c545c16ebdc75f655978262422f1c87d6433610 (plain) (tree)
1
2
3
4
5
6
7
8
9



                                                         




                                                          


                                                                                 




                                                                              
 
/* See LICENSE file for copyright and license details. */
#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)
{
	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);
}