SDL 2.0
SDL_udev.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
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 HAVE_LIBUDEV_H
28
29#ifndef SDL_USE_LIBUDEV
30#define SDL_USE_LIBUDEV 1
31#endif
32
33#include "SDL_loadso.h"
34#include "SDL_events.h"
35#include <libudev.h>
36#include <sys/time.h>
37#include <sys/types.h>
38
39/**
40 * \brief Device type
41 */
42
43typedef enum
44{
45 SDL_UDEV_DEVICEADDED = 1,
46 SDL_UDEV_DEVICEREMOVED
47} SDL_UDEV_deviceevent;
48
49/* A device can be any combination of these classes */
50typedef enum
51{
52 SDL_UDEV_DEVICE_UNKNOWN = 0x0000,
53 SDL_UDEV_DEVICE_MOUSE = 0x0001,
54 SDL_UDEV_DEVICE_KEYBOARD = 0x0002,
55 SDL_UDEV_DEVICE_JOYSTICK = 0x0004,
56 SDL_UDEV_DEVICE_SOUND = 0x0008,
57 SDL_UDEV_DEVICE_TOUCHSCREEN = 0x0010
58} SDL_UDEV_deviceclass;
59
60typedef void (*SDL_UDEV_Callback)(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath);
61
62typedef struct SDL_UDEV_CallbackList {
63 SDL_UDEV_Callback callback;
64 struct SDL_UDEV_CallbackList *next;
65} SDL_UDEV_CallbackList;
66
67typedef struct SDL_UDEV_Symbols {
68 const char *(*udev_device_get_action)(struct udev_device *);
69 const char *(*udev_device_get_devnode)(struct udev_device *);
70 const char *(*udev_device_get_subsystem)(struct udev_device *);
71 struct udev_device *(*udev_device_get_parent_with_subsystem_devtype)(struct udev_device *udev_device, const char *subsystem, const char *devtype);
72 const char *(*udev_device_get_property_value)(struct udev_device *, const char *);
73 const char *(*udev_device_get_sysattr_value)(struct udev_device *udev_device, const char *sysattr);
74 struct udev_device *(*udev_device_new_from_syspath)(struct udev *, const char *);
75 void (*udev_device_unref)(struct udev_device *);
76 int (*udev_enumerate_add_match_property)(struct udev_enumerate *, const char *, const char *);
77 int (*udev_enumerate_add_match_subsystem)(struct udev_enumerate *, const char *);
78 struct udev_list_entry *(*udev_enumerate_get_list_entry)(struct udev_enumerate *);
79 struct udev_enumerate *(*udev_enumerate_new)(struct udev *);
80 int (*udev_enumerate_scan_devices)(struct udev_enumerate *);
81 void (*udev_enumerate_unref)(struct udev_enumerate *);
82 const char *(*udev_list_entry_get_name)(struct udev_list_entry *);
83 struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *);
84 int (*udev_monitor_enable_receiving)(struct udev_monitor *);
85 int (*udev_monitor_filter_add_match_subsystem_devtype)(struct udev_monitor *, const char *, const char *);
86 int (*udev_monitor_get_fd)(struct udev_monitor *);
87 struct udev_monitor *(*udev_monitor_new_from_netlink)(struct udev *, const char *);
88 struct udev_device *(*udev_monitor_receive_device)(struct udev_monitor *);
89 void (*udev_monitor_unref)(struct udev_monitor *);
90 struct udev *(*udev_new)(void);
91 void (*udev_unref)(struct udev *);
92 struct udev_device * (*udev_device_new_from_devnum)(struct udev *udev, char type, dev_t devnum);
93 dev_t (*udev_device_get_devnum) (struct udev_device *udev_device);
94} SDL_UDEV_Symbols;
95
96typedef struct SDL_UDEV_PrivateData
97{
98 const char *udev_library;
99 void *udev_handle;
100 struct udev *udev;
101 struct udev_monitor *udev_mon;
102 int ref_count;
103 SDL_UDEV_CallbackList *first, *last;
104
105 /* Function pointers */
106 SDL_UDEV_Symbols syms;
107} SDL_UDEV_PrivateData;
108
109extern int SDL_UDEV_Init(void);
110extern void SDL_UDEV_Quit(void);
111extern void SDL_UDEV_UnloadLibrary(void);
112extern int SDL_UDEV_LoadLibrary(void);
113extern void SDL_UDEV_Poll(void);
114extern void SDL_UDEV_Scan(void);
115extern int 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
121#endif /* HAVE_LIBUDEV_H */
122
123#endif /* SDL_udev_h_ */
124
125/* vi: set ts=4 sw=4 expandtab: */
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
const GLint * first
static Uint32 callback(Uint32 interval, void *param)
Definition: testtimer.c:34