| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
SDL3.Sys.Touch
Contents
Description
SDL offers touch input, on platforms that support it. It can manage multiple touch devices and track multiple fingers on those devices.
Touches are mostly dealt with through the event system, in the SDL_EVENT_FINGER_DOWN, SDL_EVENT_FINGER_MOTION, and SDL_EVENT_FINGER_UP events, but there are also functions to query for hardware details, etc.
The touch system, by default, will also send virtual mouse events; this can be useful for making a some desktop apps work on a phone without significant changes. For apps that care about mouse and touch input separately, they should ignore mouse events that have a which field of SDL_TOUCH_MOUSEID. A unique ID for a touch device.
This ID is valid for the time the device is connected to the system, and is never reused for the lifetime of the application.
The value 0 is an invalid ID.
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.Touch.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.Touch
- pattern SDL_MOUSE_TOUCHID :: SDL_TouchID
- pattern SDL_PEN_TOUCHID :: SDL_TouchID
- getTouchDevices :: Ptr CInt -> IO (Ptr SDL_TouchID)
- getTouchDevicesSafe :: Ptr CInt -> IO (Ptr SDL_TouchID)
- getTouchDeviceName :: SDL_TouchID -> IO (PtrConst CChar)
- getTouchDeviceNameSafe :: SDL_TouchID -> IO (PtrConst CChar)
- getTouchDeviceType :: SDL_TouchID -> IO SDL_TouchDeviceType
- getTouchDeviceTypeSafe :: SDL_TouchID -> IO SDL_TouchDeviceType
- getTouchFingers :: SDL_TouchID -> Ptr CInt -> IO (Ptr (Ptr SDL_Finger))
- getTouchFingersSafe :: SDL_TouchID -> Ptr CInt -> IO (Ptr (Ptr SDL_Finger))
Documentation
module SDL3.Sys.Bindgen.Touch
Typed constants
pattern SDL_MOUSE_TOUCHID :: SDL_TouchID Source #
Typed constant for macro SDL_MOUSE_TOUCHID.
pattern SDL_PEN_TOUCHID :: SDL_TouchID Source #
Typed constant for macro SDL_PEN_TOUCHID (declared in SDL_pen.h).
Function aliases
Arguments
| :: Ptr CInt |
|
| -> IO (Ptr SDL_TouchID) |
Get a list of registered touch devices.
On some platforms SDL first sees the touch device if it was actually used. Therefore the returned list might be empty, although devices are available. After using all devices at least once the number will be correct.
- Returns
- a 0 terminated array of touch device 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_GetTouchDevices. The safe flavor isgetTouchDevicesSafe. - C declaration
SDL_GetTouchDevices, defined atSDL3/SDL_touch.h 140:43
Since: 3.2.0
Arguments
| :: Ptr CInt |
|
| -> IO (Ptr SDL_TouchID) |
Get a list of registered touch devices.
On some platforms SDL first sees the touch device if it was actually used. Therefore the returned list might be empty, although devices are available. After using all devices at least once the number will be correct.
- Returns
- a 0 terminated array of touch device 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_GetTouchDevices. The unsafe flavor isgetTouchDevices. - C declaration
SDL_GetTouchDevices, defined atSDL3/SDL_touch.h 140:43
Since: 3.2.0
Arguments
| :: SDL_TouchID |
|
| -> IO (PtrConst CChar) |
Get the touch device name as reported from the driver.
- Returns
- touch device name, or NULL on failure; call
getErrorfor more information.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetTouchDeviceName. The safe flavor isgetTouchDeviceNameSafe. - C declaration
SDL_GetTouchDeviceName, defined atSDL3/SDL_touch.h 151:42
Since: 3.2.0
getTouchDeviceNameSafe Source #
Arguments
| :: SDL_TouchID |
|
| -> IO (PtrConst CChar) |
Get the touch device name as reported from the driver.
- Returns
- touch device name, or NULL on failure; call
getErrorfor more information.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetTouchDeviceName. The unsafe flavor isgetTouchDeviceName. - C declaration
SDL_GetTouchDeviceName, defined atSDL3/SDL_touch.h 151:42
Since: 3.2.0
Arguments
| :: SDL_TouchID |
|
| -> IO SDL_TouchDeviceType |
Get the type of the given touch device.
- Returns
- touch device type.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetTouchDeviceType. The safe flavor isgetTouchDeviceTypeSafe. - C declaration
SDL_GetTouchDeviceType, defined atSDL3/SDL_touch.h 161:49
Since: 3.2.0
getTouchDeviceTypeSafe Source #
Arguments
| :: SDL_TouchID |
|
| -> IO SDL_TouchDeviceType |
Get the type of the given touch device.
- Returns
- touch device type.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetTouchDeviceType. The unsafe flavor isgetTouchDeviceType. - C declaration
SDL_GetTouchDeviceType, defined atSDL3/SDL_touch.h 161:49
Since: 3.2.0
Arguments
| :: SDL_TouchID |
|
| -> Ptr CInt |
|
| -> IO (Ptr (Ptr SDL_Finger)) |
Get a list of active fingers for a given touch device.
- Returns
- a NULL terminated array of
SDL_Fingerpointers or NULL on failure; callgetErrorfor more information. This is a single allocation that should be freed withfreewhen it is no longer needed.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetTouchFingers. The safe flavor isgetTouchFingersSafe. - C declaration
SDL_GetTouchFingers, defined atSDL3/SDL_touch.h 176:43
Since: 3.2.0
Arguments
| :: SDL_TouchID |
|
| -> Ptr CInt |
|
| -> IO (Ptr (Ptr SDL_Finger)) |
Get a list of active fingers for a given touch device.
- Returns
- a NULL terminated array of
SDL_Fingerpointers or NULL on failure; callgetErrorfor more information. This is a single allocation that should be freed withfreewhen it is no longer needed.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetTouchFingers. The unsafe flavor isgetTouchFingers. - C declaration
SDL_GetTouchFingers, defined atSDL3/SDL_touch.h 176:43
Since: 3.2.0