scs-sdk-sys 0.1.0

Raw x86-64 ABI bindings for the SCS Software Telemetry and Input SDKs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
//! Raw configuration identifiers and attribute names from the SCS Telemetry SDK.
//!
//! Values and documentation mirror `scssdk_telemetry_common_configs.h`. All
//! string constants are NUL-terminated for direct use with the C ABI.

/// Maximum number of trailers reported by the SDK.
pub const MAX_TRAILERS: usize = 10;

/// Configuration group identifiers.
pub mod ids {
    /// Number of configuration IDs declared by the official header.
    pub const COUNT: usize = 6;

    /// Configuration of the substances.
    ///
    /// Attribute index is index of the substance.
    ///
    /// Supported attributes:
    /// - `id`
    ///
    /// The upstream SDK header leaves the remaining substance attributes as a
    /// TODO, so version 1.14 does not define any additional public names here.
    pub const SUBSTANCES: &[u8] = b"substances\0";

    /// Static configuration of the controls.
    ///
    /// - `shifter_type`
    pub const CONTROLS: &[u8] = b"controls\0";

    /// Configuration of the h-shifter.
    ///
    /// When evaluating the selected gear, find slot which matches
    /// the handle position and bitmask of on/off state of selectors.
    /// If one is found, it contains the resulting gear. Otherwise
    /// a neutral is assumed.
    ///
    /// Supported attributes:
    /// - `selector_count`
    /// - resulting gear index for each slot
    /// - handle position index for each slot
    /// - bitmask of selectors for each slot
    pub const HSHIFTER: &[u8] = b"hshifter\0";

    /// Static configuration of the truck.
    ///
    /// If empty set of attributes is returned, there is no configured truck.
    ///
    /// Supported attributes:
    /// - `brand_id`
    /// - brand
    /// - id
    /// - name
    /// - `fuel_capacity`
    /// - `fuel_warning_factor`
    /// - `adblue_capacity`
    /// - `ablue_warning_factor`
    /// - `air_pressure_warning`
    /// - `air_pressure_emergency`
    /// - `oil_pressure_warning`
    /// - `water_temperature_warning`
    /// - `battery_voltage_warning`
    /// - `rpm_limit`
    /// - `foward_gear_count`
    /// - `reverse_gear_count`
    /// - `retarder_step_count`
    /// - `cabin_position`
    /// - `head_position`
    /// - `hook_position`
    /// - `license_plate`
    /// - `license_plate_country`
    /// - `license_plate_country_id`
    /// - `wheel_count`
    /// - wheel positions for `wheel_count` wheels
    pub const TRUCK: &[u8] = b"truck\0";

    /// Backward compatibility static configuration of the first trailer (attributes are equal to trailer.0).
    ///
    /// The trailers configurations are returned using `trailer.[index]`
    /// (e.g. trailer.0, trailer.1, ... trailer.9 ...)
    ///
    /// SDK currently can return up to `SCS_TELEMETRY_trailers_count` trailers.
    ///
    /// If there are less trailers in game than `SCS_TELEMETRY_trailers_count`
    /// telemetry will return all configurations however starting from the trailer after last
    /// existing one its attributes will be empty.
    ///
    /// Supported attributes:
    /// - id
    /// - `cargo_accessory_id`
    /// - `hook_position`
    /// - `brand_id`
    /// - brand
    /// - name
    /// - `chain_type` (reported only for first trailer)
    /// - `body_type` (reported only for first trailer)
    /// - `license_plate`
    /// - `license_plate_country`
    /// - `license_plate_country_id`
    /// - `wheel_count`
    /// - wheel offsets for `wheel_count` wheels
    pub const TRAILER: &[u8] = b"trailer\0";

    /// Static configuration of the job.
    ///
    /// If empty set of attributes is returned, there is no job.
    ///
    /// Supported attributes:
    /// - `cargo_id`
    /// - cargo
    /// - `cargo_mass`
    /// - `destination_city_id`
    /// - `destination_city`
    /// - `source_city_id`
    /// - `source_city`
    /// - `destination_company_id` (only available for non special transport jobs)
    /// - `destination_company` (only available for non special transport jobs)
    /// - `source_company_id` (only available for non special transport jobs)
    /// - `source_company` (only available for non special transport jobs)
    /// - income - represents expected income for the job without any penalties
    /// - `delivery_time`
    /// - `is_cargo_loaded`
    /// - `job_market`
    /// - `special_job`
    /// - `planned_distance_km`
    pub const JOB: &[u8] = b"job\0";

    /// All raw configuration identifiers in official header order.
    pub const ALL: [&[u8]; COUNT] = [SUBSTANCES, CONTROLS, HSHIFTER, TRUCK, TRAILER, JOB];
}

/// Attribute names used by configuration events.
pub mod attributes {
    /// Number of configuration attributes declared by the official header.
    pub const COUNT: usize = 60;

    /// Brand id for configuration purposes.
    ///
    /// Limited to C-identifier characters.
    ///
    /// Type: string
    pub const BRAND_ID: &[u8] = b"brand_id\0";

    /// Brand for display purposes.
    ///
    /// Localized using the current in-game language.
    ///
    /// Type: string
    pub const BRAND: &[u8] = b"brand\0";

    /// Name for internal use by code.
    ///
    /// Limited to C-identifier characters and dots.
    ///
    /// Type: string
    pub const ID: &[u8] = b"id\0";

    /// Name of cargo accessory for internal use by code.
    ///
    /// Limited to C-identifier characters and dots.
    ///
    /// Type: string
    pub const CARGO_ACCESSORY_ID: &[u8] = b"cargo.accessory.id\0";

    /// Name of trailer chain type.
    ///
    /// Limited to C-identifier characters and dots.
    ///
    /// Type: string
    pub const CHAIN_TYPE: &[u8] = b"chain.type\0";

    /// Name of trailer body type.
    ///
    /// Limited to C-identifier characters and dots.
    ///
    /// Type: string
    pub const BODY_TYPE: &[u8] = b"body.type\0";

    /// Vehicle license plate.
    ///
    /// Type: string
    pub const LICENSE_PLATE: &[u8] = b"license.plate\0";

    /// The id representing license plate country.
    ///
    /// Type: string
    pub const LICENSE_PLATE_COUNTRY_ID: &[u8] = b"license.plate.country.id\0";

    /// The name of the license plate country.
    ///
    /// Type: string
    pub const LICENSE_PLATE_COUNTRY: &[u8] = b"license.plate.country\0";

    /// Name for display purposes.
    ///
    /// Localized using the current in-game language.
    ///
    /// Type: string
    pub const NAME: &[u8] = b"name\0";

    /// Fuel tank capacity in litres.
    ///
    /// Type: float
    pub const FUEL_CAPACITY: &[u8] = b"fuel.capacity\0";

    /// Fraction of the fuel capacity below which
    /// is activated the fuel warning.
    ///
    /// Type: float
    pub const FUEL_WARNING_FACTOR: &[u8] = b"fuel.warning.factor\0";

    /// `AdBlue` tank capacity in litres.
    ///
    /// Type: float
    pub const ADBLUE_CAPACITY: &[u8] = b"adblue.capacity\0";

    /// Fraction of the adblue capacity below which
    /// is activated the adblue warning.
    ///
    /// Type: float
    pub const ADBLUE_WARNING_FACTOR: &[u8] = b"adblue.warning.factor\0";

    /// Pressure of the air in the tank below which
    /// the warning activates.
    ///
    /// Type: float
    pub const AIR_PRESSURE_WARNING: &[u8] = b"brake.air.pressure.warning\0";

    /// Pressure of the air in the tank below which
    /// the emergency brakes activate.
    ///
    /// Type: float
    pub const AIR_PRESSURE_EMERGENCY: &[u8] = b"brake.air.pressure.emergency\0";

    /// Pressure of the oil below which the warning activates.
    ///
    /// Type: float
    pub const OIL_PRESSURE_WARNING: &[u8] = b"oil.pressure.warning\0";

    /// Temperature of the water above which the warning activates.
    ///
    /// Type: float
    pub const WATER_TEMPERATURE_WARNING: &[u8] = b"water.temperature.warning\0";

    /// Voltage of the battery below which the warning activates.
    ///
    /// Type: float
    pub const BATTERY_VOLTAGE_WARNING: &[u8] = b"battery.voltage.warning\0";

    /// Maximum rpm value.
    ///
    /// Type: float
    pub const RPM_LIMIT: &[u8] = b"rpm.limit\0";

    /// Number of forward gears on undamaged truck.
    ///
    /// Type: u32
    pub const FORWARD_GEAR_COUNT: &[u8] = b"gears.forward\0";

    /// Number of reversee gears on undamaged truck.
    ///
    /// Type: u32
    pub const REVERSE_GEAR_COUNT: &[u8] = b"gears.reverse\0";

    /// Differential ratio of the truck.
    ///
    /// Type: float
    pub const DIFFERENTIAL_RATIO: &[u8] = b"differential.ratio\0";

    /// Number of steps in the retarder.
    ///
    /// Set to zero if retarder is not mounted to the truck.
    ///
    /// Type: u32
    pub const RETARDER_STEP_COUNT: &[u8] = b"retarder.steps\0";

    /// Forward transmission ratios.
    ///
    /// Type: indexed float
    pub const FORWARD_RATIO: &[u8] = b"forward.ratio\0";

    /// Reverse transmission ratios.
    ///
    /// Type: indexed float
    pub const REVERSE_RATIO: &[u8] = b"reverse.ratio\0";

    /// Position of the cabin in the vehicle space.
    ///
    /// This is position of the joint around which the cabin rotates.
    /// This attribute might be not present if the vehicle does not
    /// have a separate cabin.
    ///
    /// Type: fvector
    pub const CABIN_POSITION: &[u8] = b"cabin.position\0";

    /// Default position of the head in the cabin space.
    ///
    /// Type: fvector
    pub const HEAD_POSITION: &[u8] = b"head.position\0";

    /// Position of the trailer connection hook in vehicle
    /// space.
    ///
    /// Type: fvector
    pub const HOOK_POSITION: &[u8] = b"hook.position\0";

    /// Number of wheels
    ///
    /// Type: u32
    pub const WHEEL_COUNT: &[u8] = b"wheels.count\0";

    /// Position of respective wheels in the vehicle space.
    ///
    /// Type: indexed fvector
    pub const WHEEL_POSITION: &[u8] = b"wheel.position\0";

    /// Is the wheel steerable?
    ///
    /// Type: indexed bool
    pub const WHEEL_STEERABLE: &[u8] = b"wheel.steerable\0";

    /// Is the wheel physicaly simulated?
    ///
    /// Type: indexed bool
    pub const WHEEL_SIMULATED: &[u8] = b"wheel.simulated\0";

    /// Radius of the wheel
    ///
    /// Type: indexed float
    pub const WHEEL_RADIUS: &[u8] = b"wheel.radius\0";

    /// Is the wheel powered?
    ///
    /// Type: indexed bool
    pub const WHEEL_POWERED: &[u8] = b"wheel.powered\0";

    /// Is the wheel liftable?
    ///
    /// Type: indexed bool
    pub const WHEEL_LIFTABLE: &[u8] = b"wheel.liftable\0";

    /// Number of selectors (e.g. range/splitter toggles).
    ///
    /// Type: u32
    pub const SELECTOR_COUNT: &[u8] = b"selector.count\0";

    /// Gear selected when requirements for this h-shifter slot are meet.
    ///
    /// Type: indexed s32
    pub const SLOT_GEAR: &[u8] = b"slot.gear\0";

    /// Position of h-shifter handle.
    ///
    /// Zero corresponds to neutral position. Mapping to physical position of
    /// the handle depends on input setup.
    ///
    /// Type: indexed u32
    pub const SLOT_HANDLE_POSITION: &[u8] = b"slot.handle.position\0";

    /// Bitmask of required on/off state of selectors.
    ///
    /// Only first `selector_count` bits are relevant.
    ///
    /// Type: indexed u32
    pub const SLOT_SELECTORS: &[u8] = b"slot.selectors\0";

    /// Type of the shifter.
    ///
    /// One from `SCS_SHIFTER_TYPE`_* values.
    ///
    /// Type: string
    pub const SHIFTER_TYPE: &[u8] = b"shifter.type\0";

    /// Id of the cargo for internal use by code.
    ///
    /// Limited to C-identifier characters and dots.
    ///
    /// Type: string
    pub const CARGO_ID: &[u8] = b"cargo.id\0";

    /// Name of the cargo for display purposes.
    ///
    /// Localized using the current in-game language.
    ///
    /// Type: string
    pub const CARGO: &[u8] = b"cargo\0";

    /// Mass of the cargo in kilograms.
    ///
    /// Type: float
    pub const CARGO_MASS: &[u8] = b"cargo.mass\0";

    /// Mass of the single unit of the cargo in kilograms.
    ///
    /// Type: float
    pub const CARGO_UNIT_MASS: &[u8] = b"cargo.unit.mass\0";

    /// How many units of the cargo the job consist of.
    ///
    /// Type: u32
    pub const CARGO_UNIT_COUNT: &[u8] = b"cargo.unit.count\0";

    /// Id of the destination city for internal use by code.
    ///
    /// Limited to C-identifier characters and dots.
    ///
    /// Type: string
    pub const DESTINATION_CITY_ID: &[u8] = b"destination.city.id\0";

    /// Name of the destination city for display purposes.
    ///
    /// Localized using the current in-game language.
    ///
    /// Type: string
    pub const DESTINATION_CITY: &[u8] = b"destination.city\0";

    /// Id of the destination company for internal use by code.
    ///
    /// Limited to C-identifier characters and dots.
    ///
    /// Type: string
    pub const DESTINATION_COMPANY_ID: &[u8] = b"destination.company.id\0";

    /// Name of the destination company for display purposes.
    ///
    /// Localized using the current in-game language.
    ///
    /// Type: string
    pub const DESTINATION_COMPANY: &[u8] = b"destination.company\0";

    /// Id of the source city for internal use by code.
    ///
    /// Limited to C-identifier characters and dots.
    ///
    /// Type: string
    pub const SOURCE_CITY_ID: &[u8] = b"source.city.id\0";

    /// Name of the source city for display purposes.
    ///
    /// Localized using the current in-game language.
    ///
    /// Type: string
    pub const SOURCE_CITY: &[u8] = b"source.city\0";

    /// Id of the source company for internal use by code.
    ///
    /// Limited to C-identifier characters and dots.
    ///
    /// Type: string
    pub const SOURCE_COMPANY_ID: &[u8] = b"source.company.id\0";

    /// Name of the source company for display purposes.
    ///
    /// Localized using the current in-game language.
    ///
    /// Type: string
    pub const SOURCE_COMPANY: &[u8] = b"source.company\0";

    /// Reward in internal game-specific currency.
    ///
    /// For detailed information about the currency see "Game specific units"
    /// documentation in `scssdk_telemetry`_<`game_id>.h`
    ///
    /// Type: u64
    pub const INCOME: &[u8] = b"income\0";

    /// Absolute in-game time of end of job delivery window.
    ///
    /// Delivering the job after this time will cause it be late.
    ///
    /// See `SCS_TELEMETRY_CHANNEL_game_time` for more info about absolute time.
    /// Time remaining for delivery can be obtained like (`delivery_time` - `game_time`).
    ///
    /// Type: u32
    pub const DELIVERY_TIME: &[u8] = b"delivery.time\0";

    /// Planned job distance in simulated kilometers.
    ///
    /// Does not include distance driven using ferry.
    ///
    /// Type: u32
    pub const PLANNED_DISTANCE_KM: &[u8] = b"planned_distance.km\0";

    /// Is cargo loaded on the trailer?
    ///
    /// For non cargo market jobs this is always true
    ///
    /// Type: bool
    pub const IS_CARGO_LOADED: &[u8] = b"cargo.loaded\0";

    /// The job market this job is from.
    ///
    /// The value is a string representing the type of the job market.
    /// Possible values:
    /// - `cargo_market`
    /// - `quick_job`
    /// - `freight_market`
    /// - `external_contracts`
    /// - `external_market`
    ///
    /// Type: string
    pub const JOB_MARKET: &[u8] = b"job.market\0";

    /// Flag indicating that the job is special transport job.
    ///
    /// Type: bool
    pub const SPECIAL_JOB: &[u8] = b"is.special.job\0";

    /// All raw configuration attribute names in official header order.
    pub const ALL: [&[u8]; COUNT] = [
        BRAND_ID,
        BRAND,
        ID,
        CARGO_ACCESSORY_ID,
        CHAIN_TYPE,
        BODY_TYPE,
        LICENSE_PLATE,
        LICENSE_PLATE_COUNTRY_ID,
        LICENSE_PLATE_COUNTRY,
        NAME,
        FUEL_CAPACITY,
        FUEL_WARNING_FACTOR,
        ADBLUE_CAPACITY,
        ADBLUE_WARNING_FACTOR,
        AIR_PRESSURE_WARNING,
        AIR_PRESSURE_EMERGENCY,
        OIL_PRESSURE_WARNING,
        WATER_TEMPERATURE_WARNING,
        BATTERY_VOLTAGE_WARNING,
        RPM_LIMIT,
        FORWARD_GEAR_COUNT,
        REVERSE_GEAR_COUNT,
        DIFFERENTIAL_RATIO,
        RETARDER_STEP_COUNT,
        FORWARD_RATIO,
        REVERSE_RATIO,
        CABIN_POSITION,
        HEAD_POSITION,
        HOOK_POSITION,
        WHEEL_COUNT,
        WHEEL_POSITION,
        WHEEL_STEERABLE,
        WHEEL_SIMULATED,
        WHEEL_RADIUS,
        WHEEL_POWERED,
        WHEEL_LIFTABLE,
        SELECTOR_COUNT,
        SLOT_GEAR,
        SLOT_HANDLE_POSITION,
        SLOT_SELECTORS,
        SHIFTER_TYPE,
        CARGO_ID,
        CARGO,
        CARGO_MASS,
        CARGO_UNIT_MASS,
        CARGO_UNIT_COUNT,
        DESTINATION_CITY_ID,
        DESTINATION_CITY,
        DESTINATION_COMPANY_ID,
        DESTINATION_COMPANY,
        SOURCE_CITY_ID,
        SOURCE_CITY,
        SOURCE_COMPANY_ID,
        SOURCE_COMPANY,
        INCOME,
        DELIVERY_TIME,
        PLANNED_DISTANCE_KM,
        IS_CARGO_LOADED,
        JOB_MARKET,
        SPECIAL_JOB,
    ];
}

/// Values of the shifter.type configuration attribute.
pub mod shifter_types {
    /// Number of documented shifter type values.
    pub const COUNT: usize = 4;

    /// Documented shifter type ARCADE.
    pub const ARCADE: &[u8] = b"arcade\0";

    /// Documented shifter type AUTOMATIC.
    pub const AUTOMATIC: &[u8] = b"automatic\0";

    /// Documented shifter type MANUAL.
    pub const MANUAL: &[u8] = b"manual\0";

    /// Documented shifter type HSHIFTER.
    pub const HSHIFTER: &[u8] = b"hshifter\0";

    /// All documented raw shifter-type values in official header order.
    pub const ALL: [&[u8]; COUNT] = [ARCADE, AUTOMATIC, MANUAL, HSHIFTER];
}

/// Total number of string macros covered by this module.
pub const STRING_COUNT: usize = ids::COUNT + attributes::COUNT + shifter_types::COUNT;

const _: [(); 70] = [(); STRING_COUNT];