aboutsummaryrefslogblamecommitdiffstats
path: root/common.h
blob: 9889858f08efe4ad6c2a045691b9fdba1519caf8 (plain) (tree)
1
2
3
4
5
6
7
8
9


                                                         
                     




                   
                 




                   
                    



                              
                    


                    









                                                      
                                             


                                                              

 



                                      

 



                                    

                                      


  










                                                    
/* See LICENSE file for copyright and license details. */
#include "libgamepad.h"

#include <sys/stat.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <math.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <time.h>
#include <unistd.h>

#include <libevdev/libevdev.h>
#include <libsha2.h>
#include <libudev.h>


#if defined(__GNUC__)
# define LIBGAMEPAD_CONST__ __attribute__((__const__))
#else
# define LIBGAMEPAD_CONST__
#endif


#define READ_(ARR, I) ((ARR)[(I) / BITSOF(*(ARR))])
#define SHIFT_(ARR, I) ((I) % BITSOF(*(ARR)))

#define ELEMSOF(A) (sizeof(A) / sizeof(*(A)))
#define BITSOF(T) (8 * sizeof(T))
#define SETBIT(ARR, I) (READ_(ARR, I) |= 1 << SHIFT_(ARR, I))
#define GETBIT(ARR, I) ((READ_(ARR, I) >> SHIFT_(ARR, I)) & 1)


struct libgamepad_attachment_monitor {
	struct udev *udev;
	struct udev_monitor *monitor;
};


struct libgamepad_device_internals {
	int close_fd;
	int require_sync;
	struct libevdev *dev;
	struct input_absinfo *absinfo;
	uint8_t *buttons;
};


extern const char *libgamepad_button_names__[
#include "button.count"
];

extern const char *libgamepad_absolute_axis_names__[
#include "absolute-axis.count"
];

extern const char *libgamepad_relative_axis_names__[
#include "relative-axis.count"
];