| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
SDL3.Sys.Sensor
Contents
Description
SDL sensor management.
These APIs grant access to gyros and accelerometers on various platforms.
In order to use these functions, init must have been called with the SDL_INIT_SENSOR flag. This causes SDL to scan the system for sensors, and load appropriate drivers. The opaque structure used to identify an opened SDL sensor.
FFI conventions
Unsuffixed aliases are unsafe foreign imports; aliases suffixed Safe are safe. Functions whose callbacks fire during the call export only the Safe alias (the genuine unsafe import stays reachable under SDL3.Sys.Bindgen.Sensor.Unsafe); functions curated unsafe-only export only the unsuffixed one. Each alias's documentation records its flavor and rationale.
Full conventions: SDL3.Sys.
Since: 3.2.0
Synopsis
- module SDL3.Sys.Bindgen.Sensor
- getSensors :: Ptr CInt -> IO (Ptr SDL_SensorID)
- getSensorsSafe :: Ptr CInt -> IO (Ptr SDL_SensorID)
- getSensorNameForID :: SDL_SensorID -> IO (PtrConst CChar)
- getSensorNameForIDSafe :: SDL_SensorID -> IO (PtrConst CChar)
- getSensorTypeForID :: SDL_SensorID -> IO SDL_SensorType
- getSensorTypeForIDSafe :: SDL_SensorID -> IO SDL_SensorType
- getSensorNonPortableTypeForID :: SDL_SensorID -> IO Int32
- getSensorNonPortableTypeForIDSafe :: SDL_SensorID -> IO Int32
- openSensor :: SDL_SensorID -> IO (Ptr SDL_Sensor)
- openSensorSafe :: SDL_SensorID -> IO (Ptr SDL_Sensor)
- getSensorFromID :: SDL_SensorID -> IO (Ptr SDL_Sensor)
- getSensorFromIDSafe :: SDL_SensorID -> IO (Ptr SDL_Sensor)
- getSensorProperties :: Ptr SDL_Sensor -> IO SDL_PropertiesID
- getSensorPropertiesSafe :: Ptr SDL_Sensor -> IO SDL_PropertiesID
- getSensorName :: Ptr SDL_Sensor -> IO (PtrConst CChar)
- getSensorNameSafe :: Ptr SDL_Sensor -> IO (PtrConst CChar)
- getSensorType :: Ptr SDL_Sensor -> IO SDL_SensorType
- getSensorTypeSafe :: Ptr SDL_Sensor -> IO SDL_SensorType
- getSensorNonPortableType :: Ptr SDL_Sensor -> IO Int32
- getSensorNonPortableTypeSafe :: Ptr SDL_Sensor -> IO Int32
- getSensorID :: Ptr SDL_Sensor -> IO SDL_SensorID
- getSensorIDSafe :: Ptr SDL_Sensor -> IO SDL_SensorID
- getSensorData :: Ptr SDL_Sensor -> Ptr CFloat -> Int32 -> IO Bool
- getSensorDataSafe :: Ptr SDL_Sensor -> Ptr CFloat -> Int32 -> IO Bool
- closeSensor :: Ptr SDL_Sensor -> IO ()
- closeSensorSafe :: Ptr SDL_Sensor -> IO ()
- updateSensors :: IO ()
- updateSensorsSafe :: IO ()
Documentation
module SDL3.Sys.Bindgen.Sensor
Function aliases
Arguments
| :: Ptr CInt |
|
| -> IO (Ptr SDL_SensorID) |
Get a list of currently connected sensors.
- Returns
- a 0 terminated array of sensor instance IDs or NULL on failure; call
getErrorfor more information. This should be freed withfreewhen it is no longer needed.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetSensors. The safe flavor isgetSensorsSafe. - C declaration
SDL_GetSensors, defined atSDL3/SDL_sensor.h 159:44
Since: 3.2.0
Arguments
| :: Ptr CInt |
|
| -> IO (Ptr SDL_SensorID) |
Get a list of currently connected sensors.
- Returns
- a 0 terminated array of sensor instance IDs or NULL on failure; call
getErrorfor more information. This should be freed withfreewhen it is no longer needed.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetSensors. The unsafe flavor isgetSensors. - C declaration
SDL_GetSensors, defined atSDL3/SDL_sensor.h 159:44
Since: 3.2.0
Arguments
| :: SDL_SensorID |
|
| -> IO (PtrConst CChar) |
Get the implementation dependent name of a sensor.
This can be called before any sensors are opened.
- Returns
- the sensor name, or NULL if
instance_idis not valid.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetSensorNameForID. The safe flavor isgetSensorNameForIDSafe. - C declaration
SDL_GetSensorNameForID, defined atSDL3/SDL_sensor.h 171:42
Since: 3.2.0
getSensorNameForIDSafe Source #
Arguments
| :: SDL_SensorID |
|
| -> IO (PtrConst CChar) |
Get the implementation dependent name of a sensor.
This can be called before any sensors are opened.
- Returns
- the sensor name, or NULL if
instance_idis not valid.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetSensorNameForID. The unsafe flavor isgetSensorNameForID. - C declaration
SDL_GetSensorNameForID, defined atSDL3/SDL_sensor.h 171:42
Since: 3.2.0
Arguments
| :: SDL_SensorID |
|
| -> IO SDL_SensorType |
Get the type of a sensor.
This can be called before any sensors are opened.
- Returns
- the
SDL_SensorType, orSDL_SENSOR_INVALIDifinstance_idis not valid.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetSensorTypeForID. The safe flavor isgetSensorTypeForIDSafe. - C declaration
SDL_GetSensorTypeForID, defined atSDL3/SDL_sensor.h 184:44
Since: 3.2.0
getSensorTypeForIDSafe Source #
Arguments
| :: SDL_SensorID |
|
| -> IO SDL_SensorType |
Get the type of a sensor.
This can be called before any sensors are opened.
- Returns
- the
SDL_SensorType, orSDL_SENSOR_INVALIDifinstance_idis not valid.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetSensorTypeForID. The unsafe flavor isgetSensorTypeForID. - C declaration
SDL_GetSensorTypeForID, defined atSDL3/SDL_sensor.h 184:44
Since: 3.2.0
getSensorNonPortableTypeForID Source #
Arguments
| :: SDL_SensorID |
|
| -> IO Int32 |
Get the platform dependent type of a sensor.
This can be called before any sensors are opened.
- Returns
- the sensor platform dependent type, or -1 if
instance_idis not valid.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetSensorNonPortableTypeForID. The safe flavor isgetSensorNonPortableTypeForIDSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetSensorNonPortableTypeForID, defined atSDL3/SDL_sensor.h 197:33
Since: 3.2.0
getSensorNonPortableTypeForIDSafe Source #
Arguments
| :: SDL_SensorID |
|
| -> IO Int32 |
Get the platform dependent type of a sensor.
This can be called before any sensors are opened.
- Returns
- the sensor platform dependent type, or -1 if
instance_idis not valid.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetSensorNonPortableTypeForID. The unsafe flavor isgetSensorNonPortableTypeForID. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetSensorNonPortableTypeForID, defined atSDL3/SDL_sensor.h 197:33
Since: 3.2.0
Arguments
| :: SDL_SensorID |
|
| -> IO (Ptr SDL_Sensor) |
Open a sensor for use.
- Returns
- an
SDL_Sensorobject or NULL on failure; callgetErrorfor more information.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_OpenSensor. The safe flavor isopenSensorSafe. - C declaration
SDL_OpenSensor, defined atSDL3/SDL_sensor.h 208:42
Since: 3.2.0
Arguments
| :: SDL_SensorID |
|
| -> IO (Ptr SDL_Sensor) |
Open a sensor for use.
- Returns
- an
SDL_Sensorobject or NULL on failure; callgetErrorfor more information.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_OpenSensor. The unsafe flavor isopenSensor. - C declaration
SDL_OpenSensor, defined atSDL3/SDL_sensor.h 208:42
Since: 3.2.0
Arguments
| :: SDL_SensorID |
|
| -> IO (Ptr SDL_Sensor) |
Return the SDL_Sensor associated with an instance ID.
- Returns
- an
SDL_Sensorobject or NULL on failure; callgetErrorfor more information.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetSensorFromID. The safe flavor isgetSensorFromIDSafe. - C declaration
SDL_GetSensorFromID, defined atSDL3/SDL_sensor.h 219:42
Since: 3.2.0
Arguments
| :: SDL_SensorID |
|
| -> IO (Ptr SDL_Sensor) |
Return the SDL_Sensor associated with an instance ID.
- Returns
- an
SDL_Sensorobject or NULL on failure; callgetErrorfor more information.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetSensorFromID. The unsafe flavor isgetSensorFromID. - C declaration
SDL_GetSensorFromID, defined atSDL3/SDL_sensor.h 219:42
Since: 3.2.0
Arguments
| :: Ptr SDL_Sensor |
|
| -> IO SDL_PropertiesID |
Get the properties associated with a sensor.
- Returns
- a valid property ID on success or 0 on failure; call
getErrorfor more information.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetSensorProperties. The safe flavor isgetSensorPropertiesSafe. - C declaration
SDL_GetSensorProperties, defined atSDL3/SDL_sensor.h 230:46
Since: 3.2.0
getSensorPropertiesSafe Source #
Arguments
| :: Ptr SDL_Sensor |
|
| -> IO SDL_PropertiesID |
Get the properties associated with a sensor.
- Returns
- a valid property ID on success or 0 on failure; call
getErrorfor more information.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetSensorProperties. The unsafe flavor isgetSensorProperties. - C declaration
SDL_GetSensorProperties, defined atSDL3/SDL_sensor.h 230:46
Since: 3.2.0
Arguments
| :: Ptr SDL_Sensor |
|
| -> IO (PtrConst CChar) |
Get the implementation dependent name of a sensor.
- Returns
- the sensor name or NULL on failure; call
getErrorfor more information.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetSensorName. The safe flavor isgetSensorNameSafe. - C declaration
SDL_GetSensorName, defined atSDL3/SDL_sensor.h 241:42
Since: 3.2.0
Arguments
| :: Ptr SDL_Sensor |
|
| -> IO (PtrConst CChar) |
Get the implementation dependent name of a sensor.
- Returns
- the sensor name or NULL on failure; call
getErrorfor more information.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetSensorName. The unsafe flavor isgetSensorName. - C declaration
SDL_GetSensorName, defined atSDL3/SDL_sensor.h 241:42
Since: 3.2.0
Arguments
| :: Ptr SDL_Sensor |
|
| -> IO SDL_SensorType |
Get the type of a sensor.
- Returns
- the
SDL_SensorTypetype, orSDL_SENSOR_INVALIDifsensoris NULL.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetSensorType. The safe flavor isgetSensorTypeSafe. - C declaration
SDL_GetSensorType, defined atSDL3/SDL_sensor.h 252:44
Since: 3.2.0
Arguments
| :: Ptr SDL_Sensor |
|
| -> IO SDL_SensorType |
Get the type of a sensor.
- Returns
- the
SDL_SensorTypetype, orSDL_SENSOR_INVALIDifsensoris NULL.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetSensorType. The unsafe flavor isgetSensorType. - C declaration
SDL_GetSensorType, defined atSDL3/SDL_sensor.h 252:44
Since: 3.2.0
getSensorNonPortableType Source #
Arguments
| :: Ptr SDL_Sensor |
|
| -> IO Int32 |
Get the platform dependent type of a sensor.
- Returns
- the sensor platform dependent type, or -1 if
sensoris NULL.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetSensorNonPortableType. The safe flavor isgetSensorNonPortableTypeSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetSensorNonPortableType, defined atSDL3/SDL_sensor.h 262:33
Since: 3.2.0
getSensorNonPortableTypeSafe Source #
Arguments
| :: Ptr SDL_Sensor |
|
| -> IO Int32 |
Get the platform dependent type of a sensor.
- Returns
- the sensor platform dependent type, or -1 if
sensoris NULL.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetSensorNonPortableType. The unsafe flavor isgetSensorNonPortableType. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetSensorNonPortableType, defined atSDL3/SDL_sensor.h 262:33
Since: 3.2.0
Arguments
| :: Ptr SDL_Sensor |
|
| -> IO SDL_SensorID |
Get the instance ID of a sensor.
- Returns
- the sensor instance ID, or 0 on failure; call
getErrorfor more information.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetSensorID. The safe flavor isgetSensorIDSafe. - C declaration
SDL_GetSensorID, defined atSDL3/SDL_sensor.h 273:42
Since: 3.2.0
Arguments
| :: Ptr SDL_Sensor |
|
| -> IO SDL_SensorID |
Get the instance ID of a sensor.
- Returns
- the sensor instance ID, or 0 on failure; call
getErrorfor more information.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetSensorID. The unsafe flavor isgetSensorID. - C declaration
SDL_GetSensorID, defined atSDL3/SDL_sensor.h 273:42
Since: 3.2.0
Arguments
| :: Ptr SDL_Sensor |
|
| -> Ptr CFloat |
|
| -> Int32 |
|
| -> IO Bool |
Get the current state of an opened sensor.
The number of values and interpretation of the data is sensor dependent.
- Returns
- true on success or false on failure; call
getErrorfor more information.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetSensorData. The safe flavor isgetSensorDataSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetSensorData, defined atSDL3/SDL_sensor.h 288:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Sensor |
|
| -> Ptr CFloat |
|
| -> Int32 |
|
| -> IO Bool |
Get the current state of an opened sensor.
The number of values and interpretation of the data is sensor dependent.
- Returns
- true on success or false on failure; call
getErrorfor more information.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetSensorData. The unsafe flavor isgetSensorData. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetSensorData, defined atSDL3/SDL_sensor.h 288:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Sensor |
|
| -> IO () |
Close a sensor previously opened with .openSensor
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_CloseSensor. The safe flavor iscloseSensorSafe. - C declaration
SDL_CloseSensor, defined atSDL3/SDL_sensor.h 297:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Sensor |
|
| -> IO () |
Close a sensor previously opened with .openSensor
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_CloseSensor. The unsafe flavor iscloseSensor. - C declaration
SDL_CloseSensor, defined atSDL3/SDL_sensor.h 297:34
Since: 3.2.0
updateSensors :: IO () Source #
Update the current state of the open sensors.
This is called automatically by the event loop if sensor events are enabled.
This needs to be called from the thread that initialized the sensor subsystem.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_UpdateSensors. The safe flavor isupdateSensorsSafe: routes through joystick update; virtual-device callbacks run synchronously. - C declaration
SDL_UpdateSensors, defined atSDL3/SDL_sensor.h 310:34
Since: 3.2.0
updateSensorsSafe :: IO () Source #
Update the current state of the open sensors.
This is called automatically by the event loop if sensor events are enabled.
This needs to be called from the thread that initialized the sensor subsystem.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_UpdateSensors. The unsafe flavor isupdateSensors: routes through joystick update; virtual-device callbacks run synchronously. - C declaration
SDL_UpdateSensors, defined atSDL3/SDL_sensor.h 310:34
Since: 3.2.0