src/core/linux/SDL_udev.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 24 Sep 2018 11:49:25 -0700
changeset 12201 8bdc4d340419
parent 11811 5d94cb6b24d3
child 12203 b527a6a49bfd
permissions -rw-r--r--
Fixed whitespace
gabomdq@7753
     1
/*
gabomdq@7753
     2
  Simple DirectMedia Layer
slouken@11811
     3
  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
gabomdq@7753
     4
gabomdq@7753
     5
  This software is provided 'as-is', without any express or implied
gabomdq@7753
     6
  warranty.  In no event will the authors be held liable for any damages
gabomdq@7753
     7
  arising from the use of this software.
gabomdq@7753
     8
gabomdq@7753
     9
  Permission is granted to anyone to use this software for any purpose,
gabomdq@7753
    10
  including commercial applications, and to alter it and redistribute it
gabomdq@7753
    11
  freely, subject to the following restrictions:
gabomdq@7753
    12
gabomdq@7753
    13
  1. The origin of this software must not be misrepresented; you must not
gabomdq@7753
    14
     claim that you wrote the original software. If you use this software
gabomdq@7753
    15
     in a product, an acknowledgment in the product documentation would be
gabomdq@7753
    16
     appreciated but is not required.
gabomdq@7753
    17
  2. Altered source versions must be plainly marked as such, and must not be
gabomdq@7753
    18
     misrepresented as being the original software.
gabomdq@7753
    19
  3. This notice may not be removed or altered from any source distribution.
gabomdq@7753
    20
*/
gabomdq@7753
    21
icculus@8093
    22
#include "../../SDL_internal.h"
gabomdq@7753
    23
slouken@10638
    24
#ifndef SDL_udev_h_
slouken@10638
    25
#define SDL_udev_h_
gabomdq@7753
    26
gabomdq@7753
    27
#if HAVE_LIBUDEV_H
gabomdq@7753
    28
gabomdq@7753
    29
#ifndef SDL_USE_LIBUDEV
gabomdq@7753
    30
#define SDL_USE_LIBUDEV 1
gabomdq@7753
    31
#endif
gabomdq@7753
    32
gabomdq@7753
    33
#include "SDL_loadso.h"
gabomdq@7753
    34
#include "SDL_events.h"
gabomdq@7753
    35
#include <libudev.h>
gabomdq@7753
    36
#include <sys/time.h>
gabomdq@7753
    37
#include <sys/types.h>
gabomdq@7753
    38
gabomdq@7753
    39
/**
gabomdq@7753
    40
 *  \brief Device type
gabomdq@7753
    41
 */
gabomdq@7753
    42
gabomdq@7753
    43
typedef enum
gabomdq@7753
    44
{
slouken@10433
    45
    SDL_UDEV_DEVICEADDED = 1,
gabomdq@7753
    46
    SDL_UDEV_DEVICEREMOVED
gabomdq@7753
    47
} SDL_UDEV_deviceevent;
gabomdq@7753
    48
slouken@7788
    49
/* A device can be any combination of these classes */
gabomdq@7753
    50
typedef enum
gabomdq@7753
    51
{
slouken@10433
    52
    SDL_UDEV_DEVICE_UNKNOWN     = 0x0000,
slouken@7788
    53
    SDL_UDEV_DEVICE_MOUSE       = 0x0001,
slouken@7788
    54
    SDL_UDEV_DEVICE_KEYBOARD    = 0x0002,
slouken@7788
    55
    SDL_UDEV_DEVICE_JOYSTICK    = 0x0004,
slouken@10433
    56
    SDL_UDEV_DEVICE_SOUND       = 0x0008,
slouken@10433
    57
    SDL_UDEV_DEVICE_TOUCHSCREEN = 0x0010
gabomdq@7753
    58
} SDL_UDEV_deviceclass;
gabomdq@7753
    59
slouken@7788
    60
typedef void (*SDL_UDEV_Callback)(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath);
gabomdq@7753
    61
gabomdq@7753
    62
typedef struct SDL_UDEV_CallbackList {
gabomdq@7753
    63
    SDL_UDEV_Callback callback;
gabomdq@7753
    64
    struct SDL_UDEV_CallbackList *next;
gabomdq@7753
    65
} SDL_UDEV_CallbackList;
gabomdq@7753
    66
gabomdq@7753
    67
typedef struct SDL_UDEV_PrivateData
gabomdq@7753
    68
{
gabomdq@7753
    69
    const char *udev_library;
gabomdq@7753
    70
    void *udev_handle;
gabomdq@7753
    71
    struct udev *udev;
gabomdq@7753
    72
    struct udev_monitor *udev_mon;
gabomdq@7753
    73
    int ref_count;
gabomdq@7753
    74
    SDL_UDEV_CallbackList *first, *last;
gabomdq@7753
    75
    
gabomdq@7753
    76
    /* Function pointers */
gabomdq@7753
    77
    const char *(*udev_device_get_action)(struct udev_device *);
gabomdq@7753
    78
    const char *(*udev_device_get_devnode)(struct udev_device *);
gabomdq@7753
    79
    const char *(*udev_device_get_subsystem)(struct udev_device *);
slouken@12201
    80
    struct udev_device *(*udev_device_get_parent_with_subsystem_devtype)(struct udev_device *udev_device, const char *subsystem, const char *devtype);
gabomdq@7753
    81
    const char *(*udev_device_get_property_value)(struct udev_device *, const char *);
slouken@12201
    82
    const char *(*udev_device_get_sysattr_value)(struct udev_device *udev_device, const char *sysattr);
gabomdq@7753
    83
    struct udev_device *(*udev_device_new_from_syspath)(struct udev *, const char *);
gabomdq@7753
    84
    void (*udev_device_unref)(struct udev_device *);
gabomdq@7753
    85
    int (*udev_enumerate_add_match_property)(struct udev_enumerate *, const char *, const char *);
gabomdq@7753
    86
    int (*udev_enumerate_add_match_subsystem)(struct udev_enumerate *, const char *);
gabomdq@7753
    87
    struct udev_list_entry *(*udev_enumerate_get_list_entry)(struct udev_enumerate *);
gabomdq@7753
    88
    struct udev_enumerate *(*udev_enumerate_new)(struct udev *);
gabomdq@7753
    89
    int (*udev_enumerate_scan_devices)(struct udev_enumerate *);
gabomdq@7753
    90
    void (*udev_enumerate_unref)(struct udev_enumerate *);
gabomdq@7753
    91
    const char *(*udev_list_entry_get_name)(struct udev_list_entry *);
gabomdq@7753
    92
    struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *);
gabomdq@7753
    93
    int (*udev_monitor_enable_receiving)(struct udev_monitor *);
gabomdq@7753
    94
    int (*udev_monitor_filter_add_match_subsystem_devtype)(struct udev_monitor *, const char *, const char *);
gabomdq@7753
    95
    int (*udev_monitor_get_fd)(struct udev_monitor *);
gabomdq@7753
    96
    struct udev_monitor *(*udev_monitor_new_from_netlink)(struct udev *, const char *);
gabomdq@7753
    97
    struct udev_device *(*udev_monitor_receive_device)(struct udev_monitor *);
gabomdq@7753
    98
    void (*udev_monitor_unref)(struct udev_monitor *);
gabomdq@7753
    99
    struct udev *(*udev_new)(void);
gabomdq@7753
   100
    void (*udev_unref)(struct udev *);
gabomdq@7753
   101
    struct udev_device * (*udev_device_new_from_devnum)(struct udev *udev, char type, dev_t devnum);
gabomdq@7753
   102
    dev_t (*udev_device_get_devnum) (struct udev_device *udev_device);
gabomdq@7753
   103
} SDL_UDEV_PrivateData;
gabomdq@7753
   104
gabomdq@7753
   105
extern int SDL_UDEV_Init(void);
gabomdq@7753
   106
extern void SDL_UDEV_Quit(void);
gabomdq@7753
   107
extern void SDL_UDEV_UnloadLibrary(void);
gabomdq@7753
   108
extern int SDL_UDEV_LoadLibrary(void);
gabomdq@7753
   109
extern void SDL_UDEV_Poll(void);
gabomdq@7753
   110
extern void SDL_UDEV_Scan(void);
gabomdq@7753
   111
extern int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb);
gabomdq@7753
   112
extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb);
gabomdq@7753
   113
gabomdq@7753
   114
gabomdq@7753
   115
gabomdq@7753
   116
gabomdq@7753
   117
#endif /* HAVE_LIBUDEV_H */
gabomdq@7753
   118
slouken@10638
   119
#endif /* SDL_udev_h_ */
slouken@11296
   120
slouken@11296
   121
/* vi: set ts=4 sw=4 expandtab: */