Skip to content

Commit f933108

Browse files
Merge pull request #107 from suve/update-sdlsensor.inc-to-2.26.0
Update sdlsensor.inc to 2.26.0
2 parents 1235372 + 0361475 commit f933108

File tree

2 files changed

+104
-48
lines changed

2 files changed

+104
-48
lines changed

units/sdl2.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ interface
181181
{$I sdlmouse.inc} // 2.0.24
182182
{$I sdlguid.inc} // 2.24.0
183183
{$I sdljoystick.inc} // 2.24.0
184-
{$I sdlsensor.inc}
184+
{$I sdlsensor.inc} // 2.26.0
185185
{$I sdlgamecontroller.inc} // 2.24.0
186186
{$I sdlhaptic.inc}
187187
{$I sdltouch.inc} // 2.24.0

units/sdlsensor.inc

Lines changed: 103 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ type
3030
* https://developer.android.com/reference/android/hardware/SensorEvent.html#values
3131
*}
3232
type
33-
TSDL_SensorType = type cint32;
33+
TSDL_SensorType = type cint;
3434

3535
const
3636
SDL_SENSOR_INVALID = TSDL_SensorType(-1); {**< Returned for an invalid sensor *}
3737
SDL_SENSOR_UNKNOWN = TSDL_SensorType(0); {**< Unknown sensor type *}
3838
SDL_SENSOR_ACCEL = TSDL_SensorType(1); {**< Accelerometer *}
3939
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 *}
4044

4145
{**
4246
* Accelerometer sensor
@@ -98,138 +102,190 @@ const
98102
* In particular, you are guaranteed that the sensor list won't change, so
99103
* the API functions that take a sensor index will be valid, and sensor
100104
* events will not be delivered.
105+
*
106+
* \since This function is available since SDL 2.0.14.
101107
*}
102108
procedure SDL_LockSensors(); cdecl;
103109
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LockSensors' {$ENDIF} {$ENDIF};
104110
procedure SDL_UnlockSensors(); cdecl;
105111
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UnlockSensors' {$ENDIF} {$ENDIF};
106112

107113
{**
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.
109119
*}
110-
function SDL_NumSensors(): cint32; cdecl;
120+
function SDL_NumSensors(): cint; cdecl;
111121
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_NumSensors' {$ENDIF} {$ENDIF};
112122

113123
{**
114-
* \brief Get the implementation dependent name of a sensor.
124+
* Get the implementation dependent name of a sensor.
115125
*
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.
117128
*
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.
119130
*}
120-
function SDL_SensorGetDeviceName(device_index: cint32): PChar; cdecl;
131+
function SDL_SensorGetDeviceName(device_index: cint): PAnsiChar; cdecl;
121132
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetDeviceName' {$ENDIF} {$ENDIF};
122133

123134
{**
124-
* \brief Get the type of a sensor.
135+
* Get the type of a sensor.
125136
*
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.
127140
*
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.
129142
*}
130-
function SDL_SensorGetDeviceType(device_index: cint32): TSDL_SensorType; cdecl;
143+
function SDL_SensorGetDeviceType(device_index: cint): TSDL_SensorType; cdecl;
131144
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetDeviceType' {$ENDIF} {$ENDIF};
132145

133146
{**
134-
* \brief Get the platform dependent type of a sensor.
147+
* Get the platform dependent type of a sensor.
135148
*
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.
137152
*
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.
139154
*}
140-
function SDL_SensorGetDeviceNonPortableType(device_index: cint32): cint32; cdecl;
155+
function SDL_SensorGetDeviceNonPortableType(device_index: cint): cint; cdecl;
141156
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetDeviceNonPortableType' {$ENDIF} {$ENDIF};
142157

143158
{**
144-
* \brief Get the instance ID of a sensor.
159+
* Get the instance ID of a sensor.
145160
*
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.
147163
*
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.
149165
*}
150-
function SDL_SensorGetDeviceInstanceID(device_index: cint32): TSDL_SensorID; cdecl;
166+
function SDL_SensorGetDeviceInstanceID(device_index: cint): TSDL_SensorID; cdecl;
151167
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetDeviceInstanceID' {$ENDIF} {$ENDIF};
152168

153169
{**
154-
* \brief Open a sensor for use.
170+
* Open a sensor for use.
155171
*
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.
157174
*
158-
* \return A sensor identifier, or NIL if an error occurred.
175+
* \since This function is available since SDL 2.0.9.
159176
*}
160-
function SDL_SensorOpen(device_index: cint32): PSDL_Sensor; cdecl;
177+
function SDL_SensorOpen(device_index: cint): PSDL_Sensor; cdecl;
161178
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorOpen' {$ENDIF} {$ENDIF};
162179

163180
{**
164181
* 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.
165187
*}
166188
function SDL_SensorFromInstanceID(instance_id: TSDL_SensorID): PSDL_Sensor; cdecl;
167189
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorFromInstanceID' {$ENDIF} {$ENDIF};
168190

169191
{**
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.
171196
*
172-
* \return The sensor name, or NIL if the sensor is NIL.
197+
* \since This function is available since SDL 2.0.9.
173198
*}
174-
function SDL_SensorGetName(sensor: PSDL_Sensor): PChar; cdecl;
199+
function SDL_SensorGetName(sensor: PSDL_Sensor): PAnsiChar; cdecl;
175200
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetName' {$ENDIF} {$ENDIF};
176201

177202
{**
178-
* \brief Get the type of a sensor.
203+
* Get the type of a sensor.
179204
*
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.
181208
*
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.
183210
*}
184211
function SDL_SensorGetType(sensor: PSDL_Sensor): TSDL_SensorType; cdecl;
185212
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetType' {$ENDIF} {$ENDIF};
186213

187214
{**
188-
* \brief Get the platform dependent type of a sensor.
215+
* Get the platform dependent type of a sensor.
189216
*
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.
191219
*
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.
193221
*}
194-
function SDL_SensorGetNonPortableType(sensor: PSDL_Sensor): cint32; cdecl;
222+
function SDL_SensorGetNonPortableType(sensor: PSDL_Sensor): cint; cdecl;
195223
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetNonPortableType' {$ENDIF} {$ENDIF};
196224

197225
{**
198-
* \brief Get the instance ID of a sensor.
226+
* Get the instance ID of a sensor.
199227
*
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.
201230
*
202-
* \return The sensor instance ID, or -1 if the sensor is NIL.
231+
* \since This function is available since SDL 2.0.9.
203232
*}
204233
function SDL_SensorGetInstanceID(sensor: PSDL_Sensor): TSDL_SensorID; cdecl;
205234
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetInstanceID' {$ENDIF} {$ENDIF};
206235

207236
{**
208-
* Get the current state of an opened sensor.
237+
* Get the current state of an opened sensor.
209238
*
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.
211240
*
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.
215245
*
216-
* \return 0 or -1 if an error occurred.
246+
* \since This function is available since SDL 2.0.9.
217247
*}
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;
219249
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorGetData' {$ENDIF} {$ENDIF};
220250

221251
{**
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.
223275
*}
224276
procedure SDL_SensorClose(sensor: PSDL_Sensor); cdecl;
225277
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorClose' {$ENDIF} {$ENDIF};
226278

227279
{**
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.
229284
*
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.
231287
*
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.
233289
*}
234290
procedure SDL_SensorUpdate(); cdecl;
235291
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SensorUpdate' {$ENDIF} {$ENDIF};

0 commit comments

Comments
 (0)