SDL_evdev_capabilities.h (2310B)
1 /* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org> 4 Copyright (C) 2020 Collabora Ltd. 5 6 This software is provided 'as-is', without any express or implied 7 warranty. In no event will the authors be held liable for any damages 8 arising from the use of this software. 9 10 Permission is granted to anyone to use this software for any purpose, 11 including commercial applications, and to alter it and redistribute it 12 freely, subject to the following restrictions: 13 14 1. The origin of this software must not be misrepresented; you must not 15 claim that you wrote the original software. If you use this software 16 in a product, an acknowledgment in the product documentation would be 17 appreciated but is not required. 18 2. Altered source versions must be plainly marked as such, and must not be 19 misrepresented as being the original software. 20 3. This notice may not be removed or altered from any source distribution. 21 */ 22 23 #include "../../SDL_internal.h" 24 25 #ifndef SDL_evdev_capabilities_h_ 26 #define SDL_evdev_capabilities_h_ 27 28 #if HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX) 29 30 #include <linux/input.h> 31 32 /* A device can be any combination of these classes */ 33 typedef enum 34 { 35 SDL_UDEV_DEVICE_UNKNOWN = 0x0000, 36 SDL_UDEV_DEVICE_MOUSE = 0x0001, 37 SDL_UDEV_DEVICE_KEYBOARD = 0x0002, 38 SDL_UDEV_DEVICE_JOYSTICK = 0x0004, 39 SDL_UDEV_DEVICE_SOUND = 0x0008, 40 SDL_UDEV_DEVICE_TOUCHSCREEN = 0x0010, 41 SDL_UDEV_DEVICE_ACCELEROMETER = 0x0020 42 } SDL_UDEV_deviceclass; 43 44 #define BITS_PER_LONG (sizeof(unsigned long) * 8) 45 #define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1) 46 #define EVDEV_OFF(x) ((x)%BITS_PER_LONG) 47 #define EVDEV_LONG(x) ((x)/BITS_PER_LONG) 48 #define test_bit(bit, array) ((array[EVDEV_LONG(bit)] >> EVDEV_OFF(bit)) & 1) 49 50 extern int SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)], 51 unsigned long bitmask_abs[NBITS(ABS_MAX)], 52 unsigned long bitmask_key[NBITS(KEY_MAX)], 53 unsigned long bitmask_rel[NBITS(REL_MAX)]); 54 55 #endif /* HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX) */ 56 57 #endif /* SDL_evdev_capabilities_h_ */ 58 59 /* vi: set ts=4 sw=4 expandtab: */