|
30 | 30 | * https://developer.android.com/reference/android/hardware/SensorEvent.html#values |
31 | 31 | *} |
32 | 32 | type |
33 | | - TSDL_SensorType = type cint32; |
| 33 | + TSDL_SensorType = type cint; |
34 | 34 |
|
35 | 35 | const |
36 | 36 | SDL_SENSOR_INVALID = TSDL_SensorType(-1); {**< Returned for an invalid sensor *} |
37 | 37 | SDL_SENSOR_UNKNOWN = TSDL_SensorType(0); {**< Unknown sensor type *} |
38 | 38 | SDL_SENSOR_ACCEL = TSDL_SensorType(1); {**< Accelerometer *} |
39 | 39 | SDL_SENSOR_GYRO = TSDL_SensorType(2); {**< Gyroscope *} |
| 40 | + SDL_SENSOR_ACCEL_L = TSDL_SensorType(3); {**< Accelerometer for left Joy-Con controller and Wii nunchuk *} |
| 41 | + SDL_SENSOR_GYRO_L = TSDL_SensorType(4); {**< Gyroscope for left Joy-Con controller *} |
| 42 | + SDL_SENSOR_ACCEL_R = TSDL_SensorType(5); {**< Accelerometer for right Joy-Con controller *} |
| 43 | + SDL_SENSOR_GYRO_R = TSDL_SensorType(6); {**< Gyroscope for right Joy-Con controller *} |
40 | 44 |
|
41 | 45 | {** |
42 | 46 | * Accelerometer sensor |
@@ -98,138 +102,190 @@ const |
98 | 102 | * In particular, you are guaranteed that the sensor list won't change, so |
99 | 103 | * the API functions that take a sensor index will be valid, and sensor |
100 | 104 | * events will not be delivered. |
| 105 | + * |
| 106 | + * \since This function is available since SDL 2.0.14. |
101 | 107 | *} |
102 | 108 | procedure SDL_LockSensors(); cdecl; |
103 | 109 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LockSensors' {$ENDIF} {$ENDIF}; |
104 | 110 | procedure SDL_UnlockSensors(); cdecl; |
105 | 111 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UnlockSensors' {$ENDIF} {$ENDIF}; |
106 | 112 |
|
107 | 113 | {** |
108 | | - * \brief Count the number of sensors attached to the system right now |
| 114 | + * Count the number of sensors attached to the system right now. |
| 115 | + * |
| 116 | + * \returns the number of sensors detected. |
| 117 | + * |
| 118 | + * \since This function is available since SDL 2.0.9. |
109 | 119 | *} |
110 | | -function SDL_NumSensors(): cint32; cdecl; |
| 120 | +function SDL_NumSensors(): cint; cdecl; |
111 | 121 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_NumSensors' {$ENDIF} {$ENDIF}; |
112 | 122 |
|
113 | 123 | {** |
114 | | - * \brief Get the implementation dependent name of a sensor. |
| 124 | + * Get the implementation dependent name of a sensor. |
115 | 125 | * |
116 | | - * This can be called before any sensors are opened. |
| 126 | + * \param device_index The sensor to obtain name from |
| 127 | + * \returns the sensor name, or NIL if `device_index` is out of range. |
117 | 128 | * |
118 | | - * \return The sensor name, or NIL if device_index is out of range. |
| 129 | + * \since This function is available since SDL 2.0.9. |
119 | 130 | *} |
120 | | -function SDL_SensorGetDeviceName(device_index: cint32): PChar; cdecl; |
| 131 | +function SDL_SensorGetDeviceName(device_index: cint): PAnsiChar; cdecl; |
121 | 132 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetDeviceName' {$ENDIF} {$ENDIF}; |
122 | 133 |
|
123 | 134 | {** |
124 | | - * \brief Get the type of a sensor. |
| 135 | + * Get the type of a sensor. |
125 | 136 | * |
126 | | - * This can be called before any sensors are opened. |
| 137 | + * \param device_index The sensor to get the type from |
| 138 | + * \returns the SDL_SensorType, or `SDL_SENSOR_INVALID` if `device_index` is |
| 139 | + * out of range. |
127 | 140 | * |
128 | | - * \return The sensor type, or SDL_SENSOR_INVALID if device_index is out of range. |
| 141 | + * \since This function is available since SDL 2.0.9. |
129 | 142 | *} |
130 | | -function SDL_SensorGetDeviceType(device_index: cint32): TSDL_SensorType; cdecl; |
| 143 | +function SDL_SensorGetDeviceType(device_index: cint): TSDL_SensorType; cdecl; |
131 | 144 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetDeviceType' {$ENDIF} {$ENDIF}; |
132 | 145 |
|
133 | 146 | {** |
134 | | - * \brief Get the platform dependent type of a sensor. |
| 147 | + * Get the platform dependent type of a sensor. |
135 | 148 | * |
136 | | - * This can be called before any sensors are opened. |
| 149 | + * \param device_index The sensor to check |
| 150 | + * \returns the sensor platform dependent type, or -1 if `device_index` is out |
| 151 | + * of range. |
137 | 152 | * |
138 | | - * \return The sensor platform dependent type, or -1 if device_index is out of range. |
| 153 | + * \since This function is available since SDL 2.0.9. |
139 | 154 | *} |
140 | | -function SDL_SensorGetDeviceNonPortableType(device_index: cint32): cint32; cdecl; |
| 155 | +function SDL_SensorGetDeviceNonPortableType(device_index: cint): cint; cdecl; |
141 | 156 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetDeviceNonPortableType' {$ENDIF} {$ENDIF}; |
142 | 157 |
|
143 | 158 | {** |
144 | | - * \brief Get the instance ID of a sensor. |
| 159 | + * Get the instance ID of a sensor. |
145 | 160 | * |
146 | | - * This can be called before any sensors are opened. |
| 161 | + * \param device_index The sensor to get instance id from |
| 162 | + * \returns the sensor instance ID, or -1 if `device_index` is out of range. |
147 | 163 | * |
148 | | - * \return The sensor instance ID, or -1 if device_index is out of range. |
| 164 | + * \since This function is available since SDL 2.0.9. |
149 | 165 | *} |
150 | | -function SDL_SensorGetDeviceInstanceID(device_index: cint32): TSDL_SensorID; cdecl; |
| 166 | +function SDL_SensorGetDeviceInstanceID(device_index: cint): TSDL_SensorID; cdecl; |
151 | 167 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetDeviceInstanceID' {$ENDIF} {$ENDIF}; |
152 | 168 |
|
153 | 169 | {** |
154 | | - * \brief Open a sensor for use. |
| 170 | + * Open a sensor for use. |
155 | 171 | * |
156 | | - * The index passed as an argument refers to the N'th sensor on the system. |
| 172 | + * \param device_index The sensor to open |
| 173 | + * \returns an SDL_Sensor sensor object, or NIL if an error occurred. |
157 | 174 | * |
158 | | - * \return A sensor identifier, or NIL if an error occurred. |
| 175 | + * \since This function is available since SDL 2.0.9. |
159 | 176 | *} |
160 | | -function SDL_SensorOpen(device_index: cint32): PSDL_Sensor; cdecl; |
| 177 | +function SDL_SensorOpen(device_index: cint): PSDL_Sensor; cdecl; |
161 | 178 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorOpen' {$ENDIF} {$ENDIF}; |
162 | 179 |
|
163 | 180 | {** |
164 | 181 | * Return the SDL_Sensor associated with an instance id. |
| 182 | + * |
| 183 | + * \param instance_id The sensor from instance id |
| 184 | + * \returns an SDL_Sensor object. |
| 185 | + * |
| 186 | + * \since This function is available since SDL 2.0.9. |
165 | 187 | *} |
166 | 188 | function SDL_SensorFromInstanceID(instance_id: TSDL_SensorID): PSDL_Sensor; cdecl; |
167 | 189 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorFromInstanceID' {$ENDIF} {$ENDIF}; |
168 | 190 |
|
169 | 191 | {** |
170 | | - * \brief Get the implementation dependent name of a sensor. |
| 192 | + * Get the implementation dependent name of a sensor |
| 193 | + * |
| 194 | + * \param sensor The SDL_Sensor object |
| 195 | + * \returns the sensor name, or NIL if `sensor` is NIL. |
171 | 196 | * |
172 | | - * \return The sensor name, or NIL if the sensor is NIL. |
| 197 | + * \since This function is available since SDL 2.0.9. |
173 | 198 | *} |
174 | | -function SDL_SensorGetName(sensor: PSDL_Sensor): PChar; cdecl; |
| 199 | +function SDL_SensorGetName(sensor: PSDL_Sensor): PAnsiChar; cdecl; |
175 | 200 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetName' {$ENDIF} {$ENDIF}; |
176 | 201 |
|
177 | 202 | {** |
178 | | - * \brief Get the type of a sensor. |
| 203 | + * Get the type of a sensor. |
179 | 204 | * |
180 | | - * This can be called before any sensors are opened. |
| 205 | + * \param sensor The SDL_Sensor object to inspect |
| 206 | + * \returns the SDL_SensorType type, or `SDL_SENSOR_INVALID` |
| 207 | + * if `sensor` is NIL. |
181 | 208 | * |
182 | | - * \return The sensor type, or SDL_SENSOR_INVALID if the sensor is NIL. |
| 209 | + * \since This function is available since SDL 2.0.9. |
183 | 210 | *} |
184 | 211 | function SDL_SensorGetType(sensor: PSDL_Sensor): TSDL_SensorType; cdecl; |
185 | 212 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetType' {$ENDIF} {$ENDIF}; |
186 | 213 |
|
187 | 214 | {** |
188 | | - * \brief Get the platform dependent type of a sensor. |
| 215 | + * Get the platform dependent type of a sensor. |
189 | 216 | * |
190 | | - * This can be called before any sensors are opened. |
| 217 | + * \param sensor The SDL_Sensor object to inspect |
| 218 | + * \returns the sensor platform dependent type, or -1 if `sensor` is NIL. |
191 | 219 | * |
192 | | - * \return The sensor platform dependent type, or -1 if the sensor is NIL. |
| 220 | + * \since This function is available since SDL 2.0.9. |
193 | 221 | *} |
194 | | -function SDL_SensorGetNonPortableType(sensor: PSDL_Sensor): cint32; cdecl; |
| 222 | +function SDL_SensorGetNonPortableType(sensor: PSDL_Sensor): cint; cdecl; |
195 | 223 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetNonPortableType' {$ENDIF} {$ENDIF}; |
196 | 224 |
|
197 | 225 | {** |
198 | | - * \brief Get the instance ID of a sensor. |
| 226 | + * Get the instance ID of a sensor. |
199 | 227 | * |
200 | | - * This can be called before any sensors are opened. |
| 228 | + * \param sensor The SDL_Sensor object to inspect |
| 229 | + * \returns the sensor instance ID, or -1 if `sensor` is NIL. |
201 | 230 | * |
202 | | - * \return The sensor instance ID, or -1 if the sensor is NIL. |
| 231 | + * \since This function is available since SDL 2.0.9. |
203 | 232 | *} |
204 | 233 | function SDL_SensorGetInstanceID(sensor: PSDL_Sensor): TSDL_SensorID; cdecl; |
205 | 234 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetInstanceID' {$ENDIF} {$ENDIF}; |
206 | 235 |
|
207 | 236 | {** |
208 | | - * Get the current state of an opened sensor. |
| 237 | + * Get the current state of an opened sensor. |
209 | 238 | * |
210 | | - * The number of values and interpretation of the data is sensor dependent. |
| 239 | + * The number of values and interpretation of the data is sensor dependent. |
211 | 240 | * |
212 | | - * \param sensor The sensor to query |
213 | | - * \param data A pointer filled with the current sensor state |
214 | | - * \param num_values The number of values to write to data |
| 241 | + * \param sensor The SDL_Sensor object to query |
| 242 | + * \param data A pointer filled with the current sensor state |
| 243 | + * \param num_values The number of values to write to data |
| 244 | + * \returns 0 or -1 if an error occurred. |
215 | 245 | * |
216 | | - * \return 0 or -1 if an error occurred. |
| 246 | + * \since This function is available since SDL 2.0.9. |
217 | 247 | *} |
218 | | -function SDL_SensorGetData(sensor: PSDL_Sensor; data: pcfloat; num_values: cint32): cint32; cdecl; |
| 248 | +function SDL_SensorGetData(sensor: PSDL_Sensor; data: pcfloat; num_values: cint): cint; cdecl; |
219 | 249 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetData' {$ENDIF} {$ENDIF}; |
220 | 250 |
|
221 | 251 | {** |
222 | | - * Close a sensor previously opened with SDL_SensorOpen() |
| 252 | + * Get the current state of an opened sensor with the timestamp of the last |
| 253 | + * update. |
| 254 | + * |
| 255 | + * The number of values and interpretation of the data is sensor dependent. |
| 256 | + * |
| 257 | + * \param sensor The SDL_Sensor object to query |
| 258 | + * \param timestamp A pointer filled with the timestamp in microseconds of the |
| 259 | + * current sensor reading if available, or 0 if not |
| 260 | + * \param data A pointer filled with the current sensor state |
| 261 | + * \param num_values The number of values to write to data |
| 262 | + * \returns 0 or -1 if an error occurred. |
| 263 | + * |
| 264 | + * \since This function is available since SDL 2.26.0. |
| 265 | + *} |
| 266 | +function SDL_SensorGetDataWithTimestamp(sensor: PSDL_Sensor; timestamp: pcuint64; data: pcfloat; num_values: cint): cint; cdecl; |
| 267 | + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetDataWithTimestamp' {$ENDIF} {$ENDIF}; |
| 268 | + |
| 269 | +{** |
| 270 | + * Close a sensor previously opened with SDL_SensorOpen(). |
| 271 | + * |
| 272 | + * \param sensor The SDL_Sensor object to close |
| 273 | + * |
| 274 | + * \since This function is available since SDL 2.0.9. |
223 | 275 | *} |
224 | 276 | procedure SDL_SensorClose(sensor: PSDL_Sensor); cdecl; |
225 | 277 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorClose' {$ENDIF} {$ENDIF}; |
226 | 278 |
|
227 | 279 | {** |
228 | | - * Update the current state of the open sensors. |
| 280 | + * Update the current state of the open sensors. |
| 281 | + * |
| 282 | + * This is called automatically by the event loop if sensor events are |
| 283 | + * enabled. |
229 | 284 | * |
230 | | - * This is called automatically by the event loop if sensor events are enabled. |
| 285 | + * This needs to be called from the thread that initialized the sensor |
| 286 | + * subsystem. |
231 | 287 | * |
232 | | - * This needs to be called from the thread that initialized the sensor subsystem. |
| 288 | + * \since This function is available since SDL 2.0.9. |
233 | 289 | *} |
234 | 290 | procedure SDL_SensorUpdate(); cdecl; |
235 | 291 | external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorUpdate' {$ENDIF} {$ENDIF}; |
0 commit comments