src/sensor/SDL_syssensor.h
author Sam Lantinga <slouken@libsdl.org>
Fri, 04 Jan 2019 22:01:14 -0800
changeset 12503 806492103856
parent 12366 c46e72bd9950
permissions -rw-r--r--
Updated copyright for 2019
slouken@12130
     1
/*
slouken@12130
     2
  Simple DirectMedia Layer
slouken@12503
     3
  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
slouken@12130
     4
slouken@12130
     5
  This software is provided 'as-is', without any express or implied
slouken@12130
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@12130
     7
  arising from the use of this software.
slouken@12130
     8
slouken@12130
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@12130
    10
  including commercial applications, and to alter it and redistribute it
slouken@12130
    11
  freely, subject to the following restrictions:
slouken@12130
    12
slouken@12130
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@12130
    14
     claim that you wrote the original software. If you use this software
slouken@12130
    15
     in a product, an acknowledgment in the product documentation would be
slouken@12130
    16
     appreciated but is not required.
slouken@12130
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@12130
    18
     misrepresented as being the original software.
slouken@12130
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@12130
    20
*/
janisozaur+sdl2image@12366
    21
janisozaur+sdl2image@12366
    22
#ifndef SDL_syssensor_c_h_
janisozaur+sdl2image@12366
    23
#define SDL_syssensor_c_h_
janisozaur+sdl2image@12366
    24
slouken@12130
    25
#include "SDL_config.h"
slouken@12130
    26
slouken@12130
    27
/* This is the system specific header for the SDL sensor API */
slouken@12130
    28
slouken@12130
    29
#include "SDL_sensor.h"
slouken@12130
    30
#include "SDL_sensor_c.h"
slouken@12130
    31
slouken@12130
    32
/* The SDL sensor structure */
slouken@12130
    33
struct _SDL_Sensor
slouken@12130
    34
{
slouken@12130
    35
    SDL_SensorID instance_id;       /* Device instance, monotonically increasing from 0 */
slouken@12130
    36
    char *name;                     /* Sensor name - system dependent */
slouken@12130
    37
    SDL_SensorType type;            /* Type of the sensor */
slouken@12130
    38
    int non_portable_type;          /* Platform dependent type of the sensor */
slouken@12130
    39
slouken@12130
    40
    float data[16];                 /* The current state of the sensor */
slouken@12130
    41
slouken@12130
    42
    struct _SDL_SensorDriver *driver;
slouken@12130
    43
slouken@12130
    44
    struct sensor_hwdata *hwdata;   /* Driver dependent information */
slouken@12130
    45
slouken@12130
    46
    int ref_count;                  /* Reference count for multiple opens */
slouken@12130
    47
slouken@12130
    48
    struct _SDL_Sensor *next;       /* pointer to next sensor we have allocated */
slouken@12130
    49
};
slouken@12130
    50
slouken@12130
    51
typedef struct _SDL_SensorDriver
slouken@12130
    52
{
slouken@12130
    53
    /* Function to scan the system for sensors.
slouken@12130
    54
     * sensor 0 should be the system default sensor.
slouken@12130
    55
     * This function should return 0, or -1 on an unrecoverable fatal error.
slouken@12130
    56
     */
slouken@12130
    57
    int (*Init)(void);
slouken@12130
    58
slouken@12130
    59
    /* Function to return the number of sensors available right now */
slouken@12130
    60
    int (*GetCount)(void);
slouken@12130
    61
slouken@12130
    62
    /* Function to check to see if the available sensors have changed */
slouken@12130
    63
    void (*Detect)(void);
slouken@12130
    64
slouken@12130
    65
    /* Function to get the device-dependent name of a sensor */
slouken@12130
    66
    const char *(*GetDeviceName)(int device_index);
slouken@12130
    67
slouken@12130
    68
    /* Function to get the type of a sensor */
slouken@12130
    69
    SDL_SensorType (*GetDeviceType)(int device_index);
slouken@12130
    70
slouken@12130
    71
    /* Function to get the platform dependent type of a sensor */
slouken@12130
    72
    int (*GetDeviceNonPortableType)(int device_index);
slouken@12130
    73
slouken@12130
    74
    /* Function to get the current instance id of the sensor located at device_index */
slouken@12130
    75
    SDL_SensorID (*GetDeviceInstanceID)(int device_index);
slouken@12130
    76
slouken@12130
    77
    /* Function to open a sensor for use.
slouken@12130
    78
       The sensor to open is specified by the device index.
slouken@12130
    79
       It returns 0, or -1 if there is an error.
slouken@12130
    80
     */
slouken@12130
    81
    int (*Open)(SDL_Sensor * sensor, int device_index);
slouken@12130
    82
slouken@12130
    83
    /* Function to update the state of a sensor - called as a device poll.
slouken@12130
    84
     * This function shouldn't update the sensor structure directly,
slouken@12130
    85
     * but instead should call SDL_PrivateSensorUpdate() to deliver events
slouken@12130
    86
     * and update sensor device state.
slouken@12130
    87
     */
slouken@12130
    88
    void (*Update)(SDL_Sensor * sensor);
slouken@12130
    89
slouken@12130
    90
    /* Function to close a sensor after use */
slouken@12130
    91
    void (*Close)(SDL_Sensor * sensor);
slouken@12130
    92
slouken@12130
    93
    /* Function to perform any system-specific sensor related cleanup */
slouken@12130
    94
    void (*Quit)(void);
slouken@12130
    95
slouken@12130
    96
} SDL_SensorDriver;
slouken@12130
    97
slouken@12130
    98
/* The available sensor drivers */
slouken@12130
    99
extern SDL_SensorDriver SDL_ANDROID_SensorDriver;
slouken@12135
   100
extern SDL_SensorDriver SDL_COREMOTION_SensorDriver;
slouken@12131
   101
extern SDL_SensorDriver SDL_DUMMY_SensorDriver;
slouken@12130
   102
janisozaur+sdl2image@12366
   103
#endif /* SDL_syssensor_c_h_ */
janisozaur+sdl2image@12366
   104
slouken@12130
   105
/* vi: set ts=4 sw=4 expandtab: */