Path: blob/master/thirdparty/sdl/core/linux/SDL_udev.h
10279 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2025 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/2021#include "SDL_internal.h"2223#ifndef SDL_udev_h_24#define SDL_udev_h_2526#if defined(HAVE_LIBUDEV_H) && defined(HAVE_LINUX_INPUT_H)2728#ifndef SDL_USE_LIBUDEV29#define SDL_USE_LIBUDEV 130#endif3132//#include <libudev.h>33#include "thirdparty/linuxbsd_headers/udev/libudev.h"34#include <sys/time.h>35#include <sys/types.h>3637/**38* Device type39*/4041typedef enum42{43SDL_UDEV_DEVICEADDED = 1,44SDL_UDEV_DEVICEREMOVED45} SDL_UDEV_deviceevent;4647typedef void (*SDL_UDEV_Callback)(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath);4849typedef struct SDL_UDEV_CallbackList50{51SDL_UDEV_Callback callback;52struct SDL_UDEV_CallbackList *next;53} SDL_UDEV_CallbackList;5455typedef struct SDL_UDEV_Symbols56{57const char *(*udev_device_get_action)(struct udev_device *);58const char *(*udev_device_get_devnode)(struct udev_device *);59const char *(*udev_device_get_syspath)(struct udev_device *);60const char *(*udev_device_get_subsystem)(struct udev_device *);61struct udev_device *(*udev_device_get_parent_with_subsystem_devtype)(struct udev_device *udev_device, const char *subsystem, const char *devtype);62const char *(*udev_device_get_property_value)(struct udev_device *, const char *);63const char *(*udev_device_get_sysattr_value)(struct udev_device *udev_device, const char *sysattr);64struct udev_device *(*udev_device_new_from_syspath)(struct udev *, const char *);65void (*udev_device_unref)(struct udev_device *);66int (*udev_enumerate_add_match_property)(struct udev_enumerate *, const char *, const char *);67int (*udev_enumerate_add_match_subsystem)(struct udev_enumerate *, const char *);68struct udev_list_entry *(*udev_enumerate_get_list_entry)(struct udev_enumerate *);69struct udev_enumerate *(*udev_enumerate_new)(struct udev *);70int (*udev_enumerate_scan_devices)(struct udev_enumerate *);71void (*udev_enumerate_unref)(struct udev_enumerate *);72const char *(*udev_list_entry_get_name)(struct udev_list_entry *);73struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *);74int (*udev_monitor_enable_receiving)(struct udev_monitor *);75int (*udev_monitor_filter_add_match_subsystem_devtype)(struct udev_monitor *, const char *, const char *);76int (*udev_monitor_get_fd)(struct udev_monitor *);77struct udev_monitor *(*udev_monitor_new_from_netlink)(struct udev *, const char *);78struct udev_device *(*udev_monitor_receive_device)(struct udev_monitor *);79void (*udev_monitor_unref)(struct udev_monitor *);80struct udev *(*udev_new)(void);81void (*udev_unref)(struct udev *);82struct udev_device *(*udev_device_new_from_devnum)(struct udev *udev, char type, dev_t devnum);83dev_t (*udev_device_get_devnum)(struct udev_device *udev_device);84} SDL_UDEV_Symbols;8586typedef struct SDL_UDEV_PrivateData87{88const char *udev_library;89SDL_SharedObject *udev_handle;90struct udev *udev;91struct udev_monitor *udev_mon;92int ref_count;93SDL_UDEV_CallbackList *first, *last;9495// Function pointers96SDL_UDEV_Symbols syms;97} SDL_UDEV_PrivateData;9899extern bool SDL_UDEV_Init(void);100extern void SDL_UDEV_Quit(void);101extern void SDL_UDEV_UnloadLibrary(void);102extern bool SDL_UDEV_LoadLibrary(void);103extern void SDL_UDEV_Poll(void);104extern bool SDL_UDEV_Scan(void);105extern bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class);106extern bool SDL_UDEV_AddCallback(SDL_UDEV_Callback cb);107extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb);108extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void);109extern void SDL_UDEV_ReleaseUdevSyms(void);110111#endif // HAVE_LIBUDEV_H && HAVE_LINUX_INPUT_H112113#endif // SDL_udev_h_114115116