Atlas - SDL_udev.h
Home / ext / SDL / src / core / linux Lines: 1 | Size: 5067 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2026 Sam Lantinga <[email protected]> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20*/ 21 22#include "SDL_internal.h" 23 24#ifndef SDL_udev_h_ 25#define SDL_udev_h_ 26 27#if defined(HAVE_LIBUDEV_H) && defined(HAVE_LINUX_INPUT_H) 28 29#ifndef SDL_USE_LIBUDEV 30#define SDL_USE_LIBUDEV 1 31#endif 32 33#include <libudev.h> 34#include <linux/input.h> 35#include <sys/time.h> 36#include <sys/types.h> 37 38/** 39 * Device type 40 */ 41 42typedef enum 43{ 44 SDL_UDEV_DEVICEADDED = 1, 45 SDL_UDEV_DEVICEREMOVED 46} SDL_UDEV_deviceevent; 47 48typedef void (*SDL_UDEV_Callback)(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); 49 50typedef struct SDL_UDEV_CallbackList 51{ 52 SDL_UDEV_Callback callback; 53 struct SDL_UDEV_CallbackList *next; 54} SDL_UDEV_CallbackList; 55 56typedef struct SDL_UDEV_Symbols 57{ 58 const char *(*udev_device_get_action)(struct udev_device *); 59 const char *(*udev_device_get_devnode)(struct udev_device *); 60 const char *(*udev_device_get_driver)(struct udev_device *); 61 const char *(*udev_device_get_syspath)(struct udev_device *); 62 const char *(*udev_device_get_subsystem)(struct udev_device *); 63 struct udev_device *(*udev_device_get_parent_with_subsystem_devtype)(struct udev_device *udev_device, const char *subsystem, const char *devtype); 64 const char *(*udev_device_get_property_value)(struct udev_device *, const char *); 65 const char *(*udev_device_get_sysattr_value)(struct udev_device *udev_device, const char *sysattr); 66 struct udev_device *(*udev_device_new_from_syspath)(struct udev *, const char *); 67 void (*udev_device_unref)(struct udev_device *); 68 int (*udev_enumerate_add_match_property)(struct udev_enumerate *, const char *, const char *); 69 int (*udev_enumerate_add_match_subsystem)(struct udev_enumerate *, const char *); 70 struct udev_list_entry *(*udev_enumerate_get_list_entry)(struct udev_enumerate *); 71 struct udev_enumerate *(*udev_enumerate_new)(struct udev *); 72 int (*udev_enumerate_scan_devices)(struct udev_enumerate *); 73 void (*udev_enumerate_unref)(struct udev_enumerate *); 74 const char *(*udev_list_entry_get_name)(struct udev_list_entry *); 75 const char *(*udev_list_entry_get_value)(struct udev_list_entry *); 76 struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *); 77 int (*udev_monitor_enable_receiving)(struct udev_monitor *); 78 int (*udev_monitor_filter_add_match_subsystem_devtype)(struct udev_monitor *, const char *, const char *); 79 int (*udev_monitor_get_fd)(struct udev_monitor *); 80 struct udev_monitor *(*udev_monitor_new_from_netlink)(struct udev *, const char *); 81 struct udev_device *(*udev_monitor_receive_device)(struct udev_monitor *); 82 void (*udev_monitor_unref)(struct udev_monitor *); 83 struct udev *(*udev_new)(void); 84 void (*udev_unref)(struct udev *); 85 struct udev_device *(*udev_device_new_from_devnum)(struct udev *udev, char type, dev_t devnum); 86 dev_t (*udev_device_get_devnum)(struct udev_device *udev_device); 87 88 struct udev_hwdb *(*udev_hwdb_new)(struct udev *udev); 89 struct udev_hwdb *(*udev_hwdb_unref)(struct udev_hwdb *hwdb); 90 struct udev_list_entry *(*udev_hwdb_get_properties_list_entry)(struct udev_hwdb *hwdb, const char *modalias, unsigned flags); 91 92} SDL_UDEV_Symbols; 93 94typedef struct SDL_UDEV_PrivateData 95{ 96 const char *udev_library; 97 SDL_SharedObject *udev_handle; 98 struct udev *udev; 99 struct udev_monitor *udev_mon; 100 int ref_count; 101 SDL_UDEV_CallbackList *first, *last; 102 103 // Function pointers 104 SDL_UDEV_Symbols syms; 105} SDL_UDEV_PrivateData; 106 107extern bool SDL_UDEV_Init(void); 108extern void SDL_UDEV_Quit(void); 109extern void SDL_UDEV_UnloadLibrary(void); 110extern bool SDL_UDEV_LoadLibrary(void); 111extern void SDL_UDEV_Poll(void); 112extern bool SDL_UDEV_Scan(void); 113extern bool SDL_UDEV_GetProductInfo(const char *device_path, struct input_id *inpid, int *class, char **driver); 114extern char *SDL_UDEV_GetProductSerial(const char *device_path); 115extern bool SDL_UDEV_AddCallback(SDL_UDEV_Callback cb); 116extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb); 117extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void); 118extern void SDL_UDEV_ReleaseUdevSyms(void); 119 120#endif // HAVE_LIBUDEV_H && HAVE_LINUX_INPUT_H 121 122#endif // SDL_udev_h_ 123[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.